Re: [PATCH] x86/efi: don't try to reserve runtime regions

From: Matt Fleming
Date: Sun Apr 09 2017 - 18:22:32 EST


On Tue, 04 Apr, at 04:41:55PM, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@xxxxxx>
>
> Reserving a runtime region results in splitting the efi memory
> descriptors for the runtime region. This results in runtime region
> descriptors with bogus memory mappings, leading to interesting crashes
> like the following during a kexec:

[...]

> Runtime regions will not be freed and do not need to be reserved, so
> skip the memmap modification in this case.
>
> Fixes: 8e80632fb23f ("efi/esrt: Use efi_mem_reserve() and avoid a kmalloc()")
> Signed-off-by: Omar Sandoval <osandov@xxxxxx>
> ---
> arch/x86/platform/efi/quirks.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> index 30031d5293c4..cdfe8c628959 100644
> --- a/arch/x86/platform/efi/quirks.c
> +++ b/arch/x86/platform/efi/quirks.c
> @@ -201,6 +201,10 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
> return;
> }
>
> + /* No need to reserve regions that will never be freed. */
> + if (md.attribute & EFI_MEMORY_RUNTIME)
> + return;
> +
> size += addr % EFI_PAGE_SIZE;
> size = round_up(size, EFI_PAGE_SIZE);
> addr = round_down(addr, EFI_PAGE_SIZE);

Thanks Omar, I've picked this up for the urgent branch.