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
8383 &efi.config_table,
8484 &efi.esrt,
8585 &prop_phys,
86− &efi.mem_attr_table,
86+ &efi_mem_attr_table,
8787 #ifdef CONFIG_EFI_RCI2_TABLE
8888 &rci2_table_phys,
8989 #endif
drivers/firmware/efi/efi.c+1−2
@@ -43,7 +43,6 @@ struct efi __read_mostly efi = { · 42 unmodified lines
4343 .runtime = EFI_INVALID_TABLE_ADDR,
4444 .config_table = EFI_INVALID_TABLE_ADDR,
4545 .esrt = EFI_INVALID_TABLE_ADDR,
46− .mem_attr_table = EFI_INVALID_TABLE_ADDR,
4746 .tpm_log = EFI_INVALID_TABLE_ADDR,
4847 .tpm_final_log = EFI_INVALID_TABLE_ADDR,
4948 .mem_reserve = EFI_INVALID_TABLE_ADDR,
@@ -467,7 +466,7 @@ static __initdata efi_config_table_type_t common_tables[] = { · 417 unmodified lines
467466 {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios},
468467 {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3},
469468 {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},
471470 {LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &rng_seed},
472471 {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log},
473472 {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
1313 #include <asm/early_ioremap.h>
1414
1515 static int __initdata tbl_size;
16+unsigned long __ro_after_init efi_mem_attr_table = EFI_INVALID_TABLE_ADDR;
1617
1718 /*
1819 * Reserve the memory associated with the Memory Attributes configuration
@@ -22,13 +23,13 @@ int __init efi_memattr_init(void) · 3 unmodified lines
2223 {
2324 efi_memory_attributes_table_t *tbl;
2425
25− if (efi.mem_attr_table == EFI_INVALID_TABLE_ADDR)
26+ if (efi_mem_attr_table == EFI_INVALID_TABLE_ADDR)
2627 return 0;
2728
28− tbl = early_memremap(efi.mem_attr_table, sizeof(*tbl));
29+ tbl = early_memremap(efi_mem_attr_table, sizeof(*tbl));
2930 if (!tbl) {
3031 pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
31− efi.mem_attr_table);
32+ efi_mem_attr_table);
3233 return -ENOMEM;
3334 }
3435
@@ -39,7 +40,7 @@ int __init efi_memattr_init(void) · 4 unmodified lines
3940 }
4041
4142 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);
4344 set_bit(EFI_MEM_ATTR, &efi.flags);
4445
4546 unmap:
@@ -147,10 +148,10 @@ int __init efi_memattr_apply_permissions(struct mm_struct *mm, · 101 unmodified lines
147148 if (WARN_ON(!efi_enabled(EFI_MEMMAP)))
148149 return 0;
149150
150− tbl = memremap(efi.mem_attr_table, tbl_size, MEMREMAP_WB);
151+ tbl = memremap(efi_mem_attr_table, tbl_size, MEMREMAP_WB);
151152 if (!tbl) {
152153 pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
153− efi.mem_attr_table);
154+ efi_mem_attr_table);
154155 return -ENOMEM;
155156 }
156157
include/linux/efi.h+2−1
@@ -539,7 +539,6 @@ extern struct efi { · 538 unmodified lines
539539 unsigned long runtime; /* runtime table */
540540 unsigned long config_table; /* config tables */
541541 unsigned long esrt; /* ESRT table */
542− unsigned long mem_attr_table; /* memory attributes table */
543542 unsigned long tpm_log; /* TPM2 Event Log table */
544543 unsigned long tpm_final_log; /* TPM2 Final Events Log table */
545544 unsigned long mem_reserve; /* Linux EFI memreserve table */
@@ -641,6 +640,8 @@ extern void __init efi_fake_memmap(void); · 95 unmodified lines
641640 static inline void efi_fake_memmap(void) { }
642641 #endif
643642
643+extern unsigned long efi_mem_attr_table;
644+
644645 /*
645646 * efi_memattr_perm_setter - arch specific callback function passed into
646647 * efi_memattr_apply_permissions() that updates the