From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Matt Fleming <matt@codeblueprint.co.uk>
Cc: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
Matt Fleming <matt.fleming@intel.com>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Will Deacon <will.deacon@arm.com>,
Grant Likely <grant.likely@linaro.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Leif Lindholm <leif.lindholm@linaro.org>,
Roy Franz <roy.franz@linaro.org>,
Mark Salter <msalter@redhat.com>,
Ryan Harkin <ryan.harkin@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH v2 04/12] arm64/efi: split off EFI init and runtime code for reuse by 32-bit ARM
Date: Fri, 20 Nov 2015 07:31:35 +0100 [thread overview]
Message-ID: <CAKv+Gu8X5RCb+yZhLhxFsWZX=Pcrv=44v5w=3Gynwws8ucSPsQ@mail.gmail.com> (raw)
In-Reply-To: <20151119223430.GB2577@codeblueprint.co.uk>
Hi Matt,
Thanks for taking a look. Note that this patch only moves code from
one file to the other, and I am reluctant to fix bugs at the same
time. Most of your comments deserve a followup however, so I will make
sure this gets addressed at some point.
On 19 November 2015 at 23:34, Matt Fleming <matt@codeblueprint.co.uk> wrote:
> On Mon, 16 Nov, at 07:32:29PM, Ard Biesheuvel wrote:
>> +
>> + pr_info("EFI v%u.%.02u by %s\n",
>> + efi.systab->hdr.revision >> 16,
>> + efi.systab->hdr.revision & 0xffff, vendor);
>> +
>> + table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables;
>> + config_tables = early_memremap(efi_to_phys(efi.systab->tables),
>> + table_size);
>
> You should probably check the return value of early_memremap().
>
Indeed.
>> +
>> + retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables,
>> + sizeof(efi_config_table_64_t), NULL);
>> +
>> + early_memunmap(config_tables, table_size);
>> +out:
>> + early_memunmap(efi.systab, sizeof(efi_system_table_t));
>> + return retval;
>> +}
>> +
>> +/*
>> + * Return true for RAM regions we want to permanently reserve.
>> + */
>> +static __init int is_reserve_region(efi_memory_desc_t *md)
>> +{
>> + switch (md->type) {
>> + case EFI_LOADER_CODE:
>> + case EFI_LOADER_DATA:
>> + case EFI_BOOT_SERVICES_CODE:
>> + case EFI_BOOT_SERVICES_DATA:
>> + case EFI_CONVENTIONAL_MEMORY:
>> + case EFI_PERSISTENT_MEMORY:
>> + return 0;
>> + default:
>> + break;
>> + }
>> + return is_normal_ram(md);
>> +}
>> +
>> +static __init void reserve_regions(void)
>> +{
>> + efi_memory_desc_t *md;
>> + u64 paddr, npages, size;
>> +
>> + if (efi_enabled(EFI_DBG))
>> + pr_info("Processing EFI memory map:\n");
>> +
>> + for_each_efi_memory_desc(&memmap, md) {
>> + paddr = md->phys_addr;
>> + npages = md->num_pages;
>> +
>> + if (efi_enabled(EFI_DBG)) {
>> + char buf[64];
>> +
>> + pr_info(" 0x%012llx-0x%012llx %s",
>> + paddr, paddr + (npages << EFI_PAGE_SHIFT) - 1,
>> + efi_md_typeattr_format(buf, sizeof(buf), md));
>> + }
>> +
>> + memrange_efi_to_native(&paddr, &npages);
>> + size = npages << PAGE_SHIFT;
>
> The use of EFI_PAGE_SHIFT and PAGE_SHIFT seem to get mingled in this
> code. What's the correct constant to use throughout, because it
> doesn't look like PAGE_SHIFT == EFI_PAGE_SHIFT always?
>
No, this is correct (although confusing). npages has been converted to
native page size, so PAGE_SHIFT is appropriate here
>> +
>> + if (is_normal_ram(md))
>> + early_init_dt_add_memory_arch(paddr, size);
>> +
>> + if (is_reserve_region(md)) {
>> + memblock_mark_nomap(paddr, size);
>
> Hmm.. I was going to point out the fact that you're not checking the
> return value of memblock_mark_nomap() which can fail if you run out of
> memory when resizing the memblock arrays, until I realised that you
> haven't called memblock_allow_resize() yet. Oh well.
>
Hmm, right. I wasn't even aware that memblock could resize itself in
the first place.
>> + if (efi_enabled(EFI_DBG))
>> + pr_cont("*");
>> + }
>> +
>> + if (efi_enabled(EFI_DBG))
>> + pr_cont("\n");
>> + }
>> +
>> + set_bit(EFI_MEMMAP, &efi.flags);
>> +}
>> +
>> +void __init efi_init(void)
>> +{
>> + struct efi_fdt_params params;
>> +
>> + /* Grab UEFI information placed in FDT by stub */
>> + if (!efi_get_fdt_params(¶ms))
>> + return;
>> +
>> + efi_system_table = params.system_table;
>> +
>> + memmap.phys_map = params.mmap;
>> + memmap.map = early_memremap(params.mmap, params.mmap_size);
>
> Better check the return value?
Yep,
Thanks,
Ard.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-11-20 6:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-16 18:32 [PATCH v2 00/12] UEFI boot and runtime services support for " Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 01/12] mm/memblock: add MEMBLOCK_NOMAP attribute to memblock memory table Ard Biesheuvel
2015-11-16 18:58 ` Russell King - ARM Linux
2015-11-16 19:09 ` Ard Biesheuvel
2015-11-16 19:49 ` Russell King - ARM Linux
2015-11-16 20:33 ` Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 02/12] arm64: only consider memblocks with NOMAP cleared for linear mapping Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 03/12] arm64/efi: mark UEFI reserved regions as MEMBLOCK_NOMAP Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 04/12] arm64/efi: split off EFI init and runtime code for reuse by 32-bit ARM Ard Biesheuvel
2015-11-16 18:48 ` Russell King - ARM Linux
2015-11-17 9:21 ` Ard Biesheuvel
2015-11-19 22:34 ` Matt Fleming
2015-11-20 6:31 ` Ard Biesheuvel [this message]
2015-11-16 18:32 ` [PATCH v2 05/12] arm64/efi: refactor " Ard Biesheuvel
2015-11-16 18:49 ` Russell King - ARM Linux
2015-11-17 9:18 ` Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 06/12] ARM: add support for generic early_ioremap/early_memremap Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 07/12] ARM: split off core mapping logic from create_mapping Ard Biesheuvel
2015-11-16 18:55 ` Russell King - ARM Linux
2015-11-16 19:01 ` Ard Biesheuvel
2015-11-16 19:45 ` Russell King - ARM Linux
2015-11-16 18:32 ` [PATCH v2 08/12] ARM: factor out allocation routine from __create_mapping() Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 09/12] ARM: implement create_mapping_late() for EFI use Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 10/12] ARM: only consider memblocks with NOMAP cleared for linear mapping Ard Biesheuvel
2015-11-16 19:00 ` Russell King - ARM Linux
2015-11-16 19:02 ` Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 11/12] ARM: wire up UEFI init and runtime support Ard Biesheuvel
2015-11-16 19:01 ` Russell King - ARM Linux
2015-11-16 19:04 ` Ard Biesheuvel
2015-11-16 19:48 ` Russell King - ARM Linux
2015-11-17 5:33 ` Ard Biesheuvel
2015-11-16 18:32 ` [PATCH v2 12/12] ARM: add UEFI stub support Ard Biesheuvel
2015-11-16 19:50 ` [PATCH v2 00/12] UEFI boot and runtime services support for 32-bit ARM Ryan Harkin
2015-11-17 9:26 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKv+Gu8X5RCb+yZhLhxFsWZX=Pcrv=44v5w=3Gynwws8ucSPsQ@mail.gmail.com' \
--to=ard.biesheuvel@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=grant.likely@linaro.org \
--cc=leif.lindholm@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=matt.fleming@intel.com \
--cc=matt@codeblueprint.co.uk \
--cc=msalter@redhat.com \
--cc=roy.franz@linaro.org \
--cc=ryan.harkin@linaro.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox