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

efi: Move mem_attr_table out of struct efi

The memory attributes table is only used at init time by the core EFI
code, so there is no need to carry its address in struct efi that is
shared with the world. So move it out, and make it __ro_after_init as
well, considering that the value is set during early boot.

Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

+11 -10
+1 -1
arch/x86/platform/efi/efi.c
··· 83 83 &efi.config_table, 84 84 &efi.esrt, 85 85 &prop_phys, 86 - &efi.mem_attr_table, 86 + &efi_mem_attr_table, 87 87 #ifdef CONFIG_EFI_RCI2_TABLE 88 88 &rci2_table_phys, 89 89 #endif
+1 -2
drivers/firmware/efi/efi.c
··· 43 43 .runtime = EFI_INVALID_TABLE_ADDR, 44 44 .config_table = EFI_INVALID_TABLE_ADDR, 45 45 .esrt = EFI_INVALID_TABLE_ADDR, 46 - .mem_attr_table = EFI_INVALID_TABLE_ADDR, 47 46 .tpm_log = EFI_INVALID_TABLE_ADDR, 48 47 .tpm_final_log = EFI_INVALID_TABLE_ADDR, 49 48 .mem_reserve = EFI_INVALID_TABLE_ADDR, ··· 466 467 {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios}, 467 468 {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3}, 468 469 {EFI_SYSTEM_RESOURCE_TABLE_GUID, "ESRT", &efi.esrt}, 469 - {EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi.mem_attr_table}, 470 + {EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi_mem_attr_table}, 470 471 {LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &rng_seed}, 471 472 {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log}, 472 473 {LINUX_EFI_TPM_FINAL_LOG_GUID, "TPMFinalLog", &efi.tpm_final_log},
+7 -6
drivers/firmware/efi/memattr.c
··· 13 13 #include <asm/early_ioremap.h> 14 14 15 15 static int __initdata tbl_size; 16 + unsigned long __ro_after_init efi_mem_attr_table = EFI_INVALID_TABLE_ADDR; 16 17 17 18 /* 18 19 * Reserve the memory associated with the Memory Attributes configuration ··· 23 22 { 24 23 efi_memory_attributes_table_t *tbl; 25 24 26 - if (efi.mem_attr_table == EFI_INVALID_TABLE_ADDR) 25 + if (efi_mem_attr_table == EFI_INVALID_TABLE_ADDR) 27 26 return 0; 28 27 29 - tbl = early_memremap(efi.mem_attr_table, sizeof(*tbl)); 28 + tbl = early_memremap(efi_mem_attr_table, sizeof(*tbl)); 30 29 if (!tbl) { 31 30 pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", 32 - efi.mem_attr_table); 31 + efi_mem_attr_table); 33 32 return -ENOMEM; 34 33 } 35 34 ··· 40 39 } 41 40 42 41 tbl_size = sizeof(*tbl) + tbl->num_entries * tbl->desc_size; 43 - memblock_reserve(efi.mem_attr_table, tbl_size); 42 + memblock_reserve(efi_mem_attr_table, tbl_size); 44 43 set_bit(EFI_MEM_ATTR, &efi.flags); 45 44 46 45 unmap: ··· 148 147 if (WARN_ON(!efi_enabled(EFI_MEMMAP))) 149 148 return 0; 150 149 151 - tbl = memremap(efi.mem_attr_table, tbl_size, MEMREMAP_WB); 150 + tbl = memremap(efi_mem_attr_table, tbl_size, MEMREMAP_WB); 152 151 if (!tbl) { 153 152 pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", 154 - efi.mem_attr_table); 153 + efi_mem_attr_table); 155 154 return -ENOMEM; 156 155 } 157 156
+2 -1
include/linux/efi.h
··· 539 539 unsigned long runtime; /* runtime table */ 540 540 unsigned long config_table; /* config tables */ 541 541 unsigned long esrt; /* ESRT table */ 542 - unsigned long mem_attr_table; /* memory attributes table */ 543 542 unsigned long tpm_log; /* TPM2 Event Log table */ 544 543 unsigned long tpm_final_log; /* TPM2 Final Events Log table */ 545 544 unsigned long mem_reserve; /* Linux EFI memreserve table */ ··· 639 640 #else 640 641 static inline void efi_fake_memmap(void) { } 641 642 #endif 643 + 644 + extern unsigned long efi_mem_attr_table; 642 645 643 646 /* 644 647 * efi_memattr_perm_setter - arch specific callback function passed into