x86/efi: Extend CONFIG_EFI_PGT_DUMP support to x86_32 and kexec as well
authorSai Praneeth <sai.praneeth.prakhya@intel.com>
Fri, 2 Jun 2017 13:52:06 +0000 (13:52 +0000)
committerIngo Molnar <mingo@kernel.org>
Mon, 5 Jun 2017 15:50:43 +0000 (17:50 +0200)
CONFIG_EFI_PGT_DUMP=y, as the name suggests, dumps EFI page tables to the
kernel log during kernel boot.

This feature is very useful while debugging page faults/null pointer
dereferences to EFI related addresses.

Presently, this feature is limited only to x86_64, so let's extend it to
other EFI configurations like kexec kernel, efi=old_map and to x86_32 as well.

This doesn't effect normal boot path because this config option should
be used only for debug purposes.

Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Cc: Ricardo Neri <ricardo.neri@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-13-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/platform/efi/efi.c
arch/x86/platform/efi/efi_32.c
arch/x86/platform/efi/efi_64.c

index 43b96f5..f084d87 100644 (file)
@@ -1014,7 +1014,6 @@ static void __init __efi_enter_virtual_mode(void)
         * necessary relocation fixups for the new virtual addresses.
         */
        efi_runtime_update_mappings();
-       efi_dump_pagetable();
 
        /* clean DUMMY object */
        efi_delete_dummy_variable();
@@ -1029,6 +1028,8 @@ void __init efi_enter_virtual_mode(void)
                kexec_enter_virtual_mode();
        else
                __efi_enter_virtual_mode();
+
+       efi_dump_pagetable();
 }
 
 /*
index 3481268..52f7faa 100644 (file)
@@ -44,7 +44,14 @@ int __init efi_alloc_page_tables(void)
 }
 
 void efi_sync_low_kernel_mappings(void) {}
-void __init efi_dump_pagetable(void) {}
+
+void __init efi_dump_pagetable(void)
+{
+#ifdef CONFIG_EFI_PGT_DUMP
+       ptdump_walk_pgd_level(NULL, swapper_pg_dir);
+#endif
+}
+
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
        return 0;
index eb8dff1..8ff1f95 100644 (file)
@@ -589,7 +589,10 @@ void __init efi_runtime_update_mappings(void)
 void __init efi_dump_pagetable(void)
 {
 #ifdef CONFIG_EFI_PGT_DUMP
-       ptdump_walk_pgd_level(NULL, efi_pgd);
+       if (efi_enabled(EFI_OLD_MEMMAP))
+               ptdump_walk_pgd_level(NULL, swapper_pg_dir);
+       else
+               ptdump_walk_pgd_level(NULL, efi_pgd);
 #endif
 }