linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/efi: update e820 about reserved EFI boot services data to fix kexec breakage
@ 2019-12-04  7:52 Dave Young
  2019-12-04  7:59 ` Dave Young
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Dave Young @ 2019-12-04  7:52 UTC (permalink / raw)
  To: linux-efi, x86, linux-kernel
  Cc: Michael Weiser, Ard Biesheuvel, kexec, Ingo Molnar,
	Borislav Petkov, Eric W. Biederman, H. Peter Anvin,
	Thomas Gleixner

Michael Weiser reported he got below error during a kexec rebooting:
esrt: Unsupported ESRT version 2904149718861218184.

The ESRT memory stays in EFI boot services data, and it was reserved
in kernel via efi_mem_reserve().  The initial purpose of the reservation
is to reuse the EFI boot services data across kexec reboot. For example
the BGRT image data and some ESRT memory like Michael reported. 

But although the memory is reserved it is not updated in X86 e820 table.
And kexec_file_load iterate system ram in io resource list to find places
for kernel, initramfs and other stuff. In Michael's case the kexec loaded
initramfs overwritten the ESRT memory and then the failure happened.

Since kexec_file_load depends on the e820 to be updated, just fix this
by updating the reserved EFI boot services memory as reserved type in e820.

Originally any memory descriptors with EFI_MEMORY_RUNTIME attribute are
bypassed in the reservation code path because they are assumed as reserved.
But the reservation is still needed for multiple kexec reboot.
And it is the only possible case we come here thus just drop the code
chunk then everything works without side effects. 

On my machine the ESRT memory sits in an EFI runtime data range, it does
not trigger the problem, but I successfully tested with BGRT instead.
both kexec_load and kexec_file_load work and kdump works as well.

Signed-off-by: Dave Young <dyoung@redhat.com>
---
 arch/x86/platform/efi/quirks.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- linux-x86.orig/arch/x86/platform/efi/quirks.c
+++ linux-x86/arch/x86/platform/efi/quirks.c
@@ -260,10 +260,6 @@ void __init efi_arch_mem_reserve(phys_ad
 		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);
@@ -293,6 +289,8 @@ void __init efi_arch_mem_reserve(phys_ad
 	early_memunmap(new, new_size);
 
 	efi_memmap_install(new_phys, num_entries);
+	e820__range_update(addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED);
+	e820__update_table(e820_table);
 }
 
 /*


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-12-30 20:16 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04  7:52 [PATCH] x86/efi: update e820 about reserved EFI boot services data to fix kexec breakage Dave Young
2019-12-04  7:59 ` Dave Young
2019-12-04 10:09   ` Ingo Molnar
2019-12-04 10:14   ` Ingo Molnar
2019-12-04 10:24     ` Ard Biesheuvel
2019-12-05 10:55     ` Dave Young
2019-12-05 21:15       ` Michael Weiser
2019-12-04 11:31   ` Michael Weiser
2019-12-04 10:21 ` [tip: x86/urgent] x86/efi: Update e820 with " tip-bot2 for Dave Young
2019-12-28 20:54 ` [PATCH] x86/efi: update e820 about " Dan Williams
2019-12-29  6:13   ` Dan Williams
2019-12-29 14:24     ` Dave Young
2019-12-30  3:32       ` Dave Young
2019-12-30  5:55         ` Dave Young
2019-12-30  9:42     ` Dan Williams
2019-12-30 10:49       ` Dave Young
2019-12-30 20:16       ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).