On Tue, 01 Mar, at 01:03:22AM, Alexis Murzeau wrote: > > I've updated my additional debug code to dump all entries of virtual_map > when calling SetVirtualAddressMap. (new diff of my changes in attachment: > additionnal_printk_dump_SetVirtualAddressMap.diff) > > I've run 3 tests with and without > patch_x86-efi-build-our-own-page-table-structures: > - Without the patch and with "efi=debug" kernel command line > (attachment: dmesg_without_patch_efi_debug.txt) > > - With the patch and with "efi=no_map,debug" command line (no crash) > (attachment: dmesg_with_patch_efi_old_map_debug.txt) > > - With the patch with "efi=debug earlyprintk=efi,keep" (crash but > with logs) > (attachment: dmesg_with_patch_efi_debug_photos.zip) > > All of these tests are using kernels with CONFIG_EFI_PGT_DUMP enabled > but "efi=no_map" seems to make efi_dump_pagetable not printing anything. > > There is a difference in the page table dump, not sure if could be the > cause of the crash: > Without the patch (in dmesg_without_patch_efi_debug.txt): > 0x00000000aa200000-0x00000000aa7bf000 5884K RW GLB x pte > 0x00000000aa7bf000-0x00000000aaabf000 3M RW x pte > With the patch (in dmesg_with_patch_efi_debug_08.png in the zip file): > 0x00000000aa200000-0x00000000aaabf000 8956K RW x pte
It must have been a herculean effort to take photos of the screen while the buggy kernel booted. Thank you! I'm not really seeing anything jumping out as obviously wrong apart from the fact that we don't have all of EFI_CONVENTIONAL_MEMORY mapped in the buggy kernel. Could you try this patch? --- diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 49e4dd4a1f58..f5e77d240ff1 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -241,15 +241,6 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) efi_scratch.use_pgd = true; /* - * When making calls to the firmware everything needs to be 1:1 - * mapped and addressable with 32-bit pointers. Map the kernel - * text and allocate a new stack because we can't rely on the - * stack pointer being < 4GB. - */ - if (!IS_ENABLED(CONFIG_EFI_MIXED)) - return 0; - - /* * Map all of RAM so that we can access arguments in the 1:1 * mapping when making EFI runtime calls. */ @@ -268,6 +259,15 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) } } + /* + * When making calls to the firmware everything needs to be 1:1 + * mapped and addressable with 32-bit pointers. Map the kernel + * text and allocate a new stack because we can't rely on the + * stack pointer being < 4GB. + */ + if (!IS_ENABLED(CONFIG_EFI_MIXED)) + return 0; + page = alloc_page(GFP_KERNEL|__GFP_DMA32); if (!page) panic("Unable to allocate EFI runtime stack < 4GB\n");