Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/efi: Dump the EFI page table

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>

authored by

Borislav Petkov and committed by
Matt Fleming
11cc8512 ef6bea6d

+21
+9
arch/x86/Kconfig.debug
··· 81 81 kernel. 82 82 If in doubt, say "N" 83 83 84 + config EFI_PGT_DUMP 85 + bool "Dump the EFI pagetable" 86 + depends on EFI && X86_PTDUMP 87 + ---help--- 88 + Enable this if you want to dump the EFI page table before 89 + enabling virtual mode. This can be used to debug miscellaneous 90 + issues with the mapping of the EFI runtime regions into that 91 + table. 92 + 84 93 config DEBUG_RODATA 85 94 bool "Write protect kernel read-only data structures" 86 95 default y
+1
arch/x86/include/asm/efi.h
··· 133 133 extern void __init old_map_region(efi_memory_desc_t *md); 134 134 extern void __init runtime_code_page_mkexec(void); 135 135 extern void __init efi_runtime_mkexec(void); 136 + extern void __init efi_dump_pagetable(void); 136 137 137 138 struct efi_setup_data { 138 139 u64 fw_vendor;
+1
arch/x86/platform/efi/efi.c
··· 1021 1021 1022 1022 efi_setup_page_tables(); 1023 1023 efi_sync_low_kernel_mappings(); 1024 + efi_dump_pagetable(); 1024 1025 1025 1026 if (!efi_setup) { 1026 1027 status = phys_efi_set_virtual_address_map(
+1
arch/x86/platform/efi/efi_32.c
··· 41 41 42 42 void efi_sync_low_kernel_mappings(void) {} 43 43 void efi_setup_page_tables(void) {} 44 + void __init efi_dump_pagetable(void) {} 44 45 45 46 void __init efi_map_region(efi_memory_desc_t *md) 46 47 {
+9
arch/x86/platform/efi/efi_64.c
··· 242 242 if (__supported_pte_mask & _PAGE_NX) 243 243 runtime_code_page_mkexec(); 244 244 } 245 + 246 + void __init efi_dump_pagetable(void) 247 + { 248 + #ifdef CONFIG_EFI_PGT_DUMP 249 + pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd); 250 + 251 + ptdump_walk_pgd_level(NULL, pgd); 252 + #endif 253 + }