[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87r348r0k9.fsf@gmail.com>
Date: Thu, 12 Jan 2017 12:15:50 +0100
From: Nicolai Stange <nicstange@...il.com>
To: Dave Young <dyoung@...hat.com>
Cc: Matt Fleming <matt@...eblueprint.co.uk>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org,
x86@...nel.org, Nicolai Stange <nicstange@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, hpa@...or.com,
Dan Williams <dan.j.williams@...el.com>,
mika.penttila@...tfour.com, bhsharma@...hat.com
Subject: Re: [PATCH 1/4] efi/x86: make efi_memmap_reserve only insert into boot mem areas
Hi Dave,
On Thu, Jan 12 2017, Dave Young wrote:
> efi_mem_reserve cares only about boot services regions and maybe loader areas.
> So add a new argument to efi_memmap_insert for this purpose.
Please see below.
> --- linux-x86.orig/drivers/firmware/efi/memmap.c
> +++ linux-x86/drivers/firmware/efi/memmap.c
> @@ -213,7 +213,7 @@ int __init efi_memmap_split_count(efi_me
> * to see how large @buf needs to be.
> */
> void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
> - struct efi_mem_range *mem)
> + struct efi_mem_range *mem, bool boot_only)
> {
> u64 m_start, m_end, m_attr;
> efi_memory_desc_t *md;
> @@ -246,6 +246,12 @@ void __init efi_memmap_insert(struct efi
> start = md->phys_addr;
> end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1;
>
> + if (boot_only && !(md->type == EFI_LOADER_DATA ||
> + md->type == EFI_LOADER_CODE ||
> + md->type == EFI_BOOT_SERVICES_CODE ||
> + md->type == EFI_BOOT_SERVICES_DATA))
> + continue;
> +
Actually, the efi_mem_desc_lookup() called from
efi_arch_memmap_reserve() will only return mds not satisfying the
following condition:
if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
md->type != EFI_BOOT_SERVICES_DATA &&
md->type != EFI_RUNTIME_SERVICES_DATA) {
continue;
}
Furthermore, efi_arch_mem_reserve() will only accept ranges fully
contained within such a region.
I think we can make efi_arch_mem_reserve() return early if
EFI_MEMORY_RUNTIME has been set already and thus, neglect this case in
efi_memmap_insert().
I suppose that we don't want to reserve within EFI_RUNTIME_SERVICES_DATA
regions in efi_mem_reserve() either -- these won't ever get made
available as general memory anyway [1]. So efi_arch_mem_reserve() should
return early here as well imo.
So, what would remain to be handled from efi_memmap_insert() in case of
boot_only would be EFI_BOOT_SERVICES_DATA only?
(As a sidenote, Matt pointed out at [1] that the EFI_LOADER_* regions
should be reserved early through memblock_reserve() and not through
efi_mem_reserve()).
Thanks,
Nicolai
[1] http://lkml.kernel.org/r/20170109130702.GI16838@codeblueprint.co.uk
Powered by blists - more mailing lists