History

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.

Ard Biesheuvel committed 6 years ago

Commit a17e8091 parent 5d288db4 files · +11 −10Browse files

Unified · Split

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