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.
Unified · Split
| @@ -83,7 +83,7 @@ static const unsigned long * const efi_tables[] = { · 82 unmodified lines | ||
| 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 |
| @@ -43,7 +43,6 @@ struct efi __read_mostly efi = { · 42 unmodified lines | ||
| 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, |
| @@ -467,7 +466,7 @@ static __initdata efi_config_table_type_t common_tables[] = { · 417 unmodified lines | ||
| 467 | 466 | {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios}, |
| 468 | 467 | {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3}, |
| 469 | 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 | 470 | {LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &rng_seed}, |
| 472 | 471 | {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log}, |
| 473 | 472 | {LINUX_EFI_TPM_FINAL_LOG_GUID, "TPMFinalLog", &efi.tpm_final_log}, |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 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 |
| @@ -22,13 +23,13 @@ int __init efi_memattr_init(void) · 3 unmodified lines | ||
| 22 | 23 | { |
| 23 | 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 | 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 | 30 | if (!tbl) { |
| 30 | 31 | pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", |
| 31 | − efi.mem_attr_table); | |
| 32 | + efi_mem_attr_table); | |
| 32 | 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 | 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 | 44 | set_bit(EFI_MEM_ATTR, &efi.flags); |
| 44 | 45 | |
| 45 | 46 | unmap: |
| @@ -147,10 +148,10 @@ int __init efi_memattr_apply_permissions(struct mm_struct *mm, · 101 unmodified lines | ||
| 147 | 148 | if (WARN_ON(!efi_enabled(EFI_MEMMAP))) |
| 148 | 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 | 152 | if (!tbl) { |
| 152 | 153 | pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", |
| 153 | − efi.mem_attr_table); | |
| 154 | + efi_mem_attr_table); | |
| 154 | 155 | return -ENOMEM; |
| 155 | 156 | } |
| 156 | 157 | |
| @@ -539,7 +539,6 @@ extern struct efi { · 538 unmodified lines | ||
| 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 */ |
| @@ -641,6 +640,8 @@ extern void __init efi_fake_memmap(void); · 95 unmodified lines | ||
| 641 | 640 | static inline void efi_fake_memmap(void) { } |
| 642 | 641 | #endif |
| 643 | 642 | |
| 643 | +extern unsigned long efi_mem_attr_table; | |
| 644 | + | |
| 644 | 645 | /* |
| 645 | 646 | * efi_memattr_perm_setter - arch specific callback function passed into |
| 646 | 647 | * efi_memattr_apply_permissions() that updates the |