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>
This commit is contained in:
Ard Biesheuvel 2020-01-22 15:05:12 +01:00
parent 5d288dbd88
commit a17e809ea5
4 changed files with 11 additions and 10 deletions

View File

@ -83,7 +83,7 @@ static const unsigned long * const efi_tables[] = {
&efi.config_table, &efi.config_table,
&efi.esrt, &efi.esrt,
&prop_phys, &prop_phys,
&efi.mem_attr_table, &efi_mem_attr_table,
#ifdef CONFIG_EFI_RCI2_TABLE #ifdef CONFIG_EFI_RCI2_TABLE
&rci2_table_phys, &rci2_table_phys,
#endif #endif

View File

@ -43,7 +43,6 @@ struct efi __read_mostly efi = {
.runtime = EFI_INVALID_TABLE_ADDR, .runtime = EFI_INVALID_TABLE_ADDR,
.config_table = EFI_INVALID_TABLE_ADDR, .config_table = EFI_INVALID_TABLE_ADDR,
.esrt = EFI_INVALID_TABLE_ADDR, .esrt = EFI_INVALID_TABLE_ADDR,
.mem_attr_table = EFI_INVALID_TABLE_ADDR,
.tpm_log = EFI_INVALID_TABLE_ADDR, .tpm_log = EFI_INVALID_TABLE_ADDR,
.tpm_final_log = EFI_INVALID_TABLE_ADDR, .tpm_final_log = EFI_INVALID_TABLE_ADDR,
.mem_reserve = EFI_INVALID_TABLE_ADDR, .mem_reserve = EFI_INVALID_TABLE_ADDR,
@ -467,7 +466,7 @@ static __initdata efi_config_table_type_t common_tables[] = {
{SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios}, {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios},
{SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3}, {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3},
{EFI_SYSTEM_RESOURCE_TABLE_GUID, "ESRT", &efi.esrt}, {EFI_SYSTEM_RESOURCE_TABLE_GUID, "ESRT", &efi.esrt},
{EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi.mem_attr_table}, {EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi_mem_attr_table},
{LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &rng_seed}, {LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &rng_seed},
{LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log}, {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log},
{LINUX_EFI_TPM_FINAL_LOG_GUID, "TPMFinalLog", &efi.tpm_final_log}, {LINUX_EFI_TPM_FINAL_LOG_GUID, "TPMFinalLog", &efi.tpm_final_log},

View File

@ -13,6 +13,7 @@
#include <asm/early_ioremap.h> #include <asm/early_ioremap.h>
static int __initdata tbl_size; static int __initdata tbl_size;
unsigned long __ro_after_init efi_mem_attr_table = EFI_INVALID_TABLE_ADDR;
/* /*
* Reserve the memory associated with the Memory Attributes configuration * Reserve the memory associated with the Memory Attributes configuration
@ -22,13 +23,13 @@ int __init efi_memattr_init(void)
{ {
efi_memory_attributes_table_t *tbl; efi_memory_attributes_table_t *tbl;
if (efi.mem_attr_table == EFI_INVALID_TABLE_ADDR) if (efi_mem_attr_table == EFI_INVALID_TABLE_ADDR)
return 0; return 0;
tbl = early_memremap(efi.mem_attr_table, sizeof(*tbl)); tbl = early_memremap(efi_mem_attr_table, sizeof(*tbl));
if (!tbl) { if (!tbl) {
pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
efi.mem_attr_table); efi_mem_attr_table);
return -ENOMEM; return -ENOMEM;
} }
@ -39,7 +40,7 @@ int __init efi_memattr_init(void)
} }
tbl_size = sizeof(*tbl) + tbl->num_entries * tbl->desc_size; tbl_size = sizeof(*tbl) + tbl->num_entries * tbl->desc_size;
memblock_reserve(efi.mem_attr_table, tbl_size); memblock_reserve(efi_mem_attr_table, tbl_size);
set_bit(EFI_MEM_ATTR, &efi.flags); set_bit(EFI_MEM_ATTR, &efi.flags);
unmap: unmap:
@ -147,10 +148,10 @@ int __init efi_memattr_apply_permissions(struct mm_struct *mm,
if (WARN_ON(!efi_enabled(EFI_MEMMAP))) if (WARN_ON(!efi_enabled(EFI_MEMMAP)))
return 0; return 0;
tbl = memremap(efi.mem_attr_table, tbl_size, MEMREMAP_WB); tbl = memremap(efi_mem_attr_table, tbl_size, MEMREMAP_WB);
if (!tbl) { if (!tbl) {
pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
efi.mem_attr_table); efi_mem_attr_table);
return -ENOMEM; return -ENOMEM;
} }

View File

@ -539,7 +539,6 @@ extern struct efi {
unsigned long runtime; /* runtime table */ unsigned long runtime; /* runtime table */
unsigned long config_table; /* config tables */ unsigned long config_table; /* config tables */
unsigned long esrt; /* ESRT table */ unsigned long esrt; /* ESRT table */
unsigned long mem_attr_table; /* memory attributes table */
unsigned long tpm_log; /* TPM2 Event Log table */ unsigned long tpm_log; /* TPM2 Event Log table */
unsigned long tpm_final_log; /* TPM2 Final Events Log table */ unsigned long tpm_final_log; /* TPM2 Final Events Log table */
unsigned long mem_reserve; /* Linux EFI memreserve table */ unsigned long mem_reserve; /* Linux EFI memreserve table */
@ -641,6 +640,8 @@ extern void __init efi_fake_memmap(void);
static inline void efi_fake_memmap(void) { } static inline void efi_fake_memmap(void) { }
#endif #endif
extern unsigned long efi_mem_attr_table;
/* /*
* efi_memattr_perm_setter - arch specific callback function passed into * efi_memattr_perm_setter - arch specific callback function passed into
* efi_memattr_apply_permissions() that updates the * efi_memattr_apply_permissions() that updates the