x86/efi: Dump the EFI page table
authorBorislav Petkov <bp@suse.de>
Sat, 18 Jan 2014 11:48:15 +0000 (12:48 +0100)
committerMatt Fleming <matt.fleming@intel.com>
Tue, 4 Mar 2014 16:17:17 +0000 (16:17 +0000)
This is very useful for debugging issues with the recently added
pagetable switching code for EFI virtual mode.

Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
arch/x86/Kconfig.debug
arch/x86/include/asm/efi.h
arch/x86/platform/efi/efi.c
arch/x86/platform/efi/efi_32.c
arch/x86/platform/efi/efi_64.c

index 321a52ccf63ad58c982f5e8f6588f70267aae947..61bd2ad94281884f13b70f3bb9e397fdcef9338a 100644 (file)
@@ -81,6 +81,15 @@ config X86_PTDUMP
          kernel.
          If in doubt, say "N"
 
+config EFI_PGT_DUMP
+       bool "Dump the EFI pagetable"
+       depends on EFI && X86_PTDUMP
+       ---help---
+         Enable this if you want to dump the EFI page table before
+         enabling virtual mode. This can be used to debug miscellaneous
+         issues with the mapping of the EFI runtime regions into that
+         table.
+
 config DEBUG_RODATA
        bool "Write protect kernel read-only data structures"
        default y
index a7a8bd89024e0b2a4fa07abf5effdef9ffe8c3c4..4afd3b3b658fa09a7dc931f0416b66a0757533b9 100644 (file)
@@ -133,6 +133,7 @@ extern void efi_setup_page_tables(void);
 extern void __init old_map_region(efi_memory_desc_t *md);
 extern void __init runtime_code_page_mkexec(void);
 extern void __init efi_runtime_mkexec(void);
+extern void __init efi_dump_pagetable(void);
 
 struct efi_setup_data {
        u64 fw_vendor;
index 876dc5b9e4a3dbb8e6d4387413e55b1825e19f28..37f20d71ec4bd6a310559adaeaf755939a97639b 100644 (file)
@@ -1021,6 +1021,7 @@ void __init efi_enter_virtual_mode(void)
 
        efi_setup_page_tables();
        efi_sync_low_kernel_mappings();
+       efi_dump_pagetable();
 
        if (!efi_setup) {
                status = phys_efi_set_virtual_address_map(
index 0b74cdf7f816aa0e4e6f26c020821266f51aefdb..39496ae3928a964199f142ec66cee29d4b53caa8 100644 (file)
@@ -41,6 +41,7 @@ static unsigned long efi_rt_eflags;
 
 void efi_sync_low_kernel_mappings(void) {}
 void efi_setup_page_tables(void) {}
+void __init efi_dump_pagetable(void) {}
 
 void __init efi_map_region(efi_memory_desc_t *md)
 {
index 0c2a234fef1e48794a14e13aad812a5b468c6605..e05c69b46f05af55c92a5e560dba7ad83b2c1d0b 100644 (file)
@@ -242,3 +242,12 @@ void __init efi_runtime_mkexec(void)
        if (__supported_pte_mask & _PAGE_NX)
                runtime_code_page_mkexec();
 }
+
+void __init efi_dump_pagetable(void)
+{
+#ifdef CONFIG_EFI_PGT_DUMP
+       pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
+
+       ptdump_walk_pgd_level(NULL, pgd);
+#endif
+}