.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org> |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | 4 | */ |
---|
8 | 5 | |
---|
9 | 6 | #define pr_fmt(fmt) "efi: memattr: " fmt |
---|
.. | .. |
---|
16 | 13 | #include <asm/early_ioremap.h> |
---|
17 | 14 | |
---|
18 | 15 | static int __initdata tbl_size; |
---|
| 16 | +unsigned long __ro_after_init efi_mem_attr_table = EFI_INVALID_TABLE_ADDR; |
---|
19 | 17 | |
---|
20 | 18 | /* |
---|
21 | 19 | * Reserve the memory associated with the Memory Attributes configuration |
---|
.. | .. |
---|
25 | 23 | { |
---|
26 | 24 | efi_memory_attributes_table_t *tbl; |
---|
27 | 25 | |
---|
28 | | - if (efi.mem_attr_table == EFI_INVALID_TABLE_ADDR) |
---|
| 26 | + if (efi_mem_attr_table == EFI_INVALID_TABLE_ADDR) |
---|
29 | 27 | return 0; |
---|
30 | 28 | |
---|
31 | | - tbl = early_memremap(efi.mem_attr_table, sizeof(*tbl)); |
---|
| 29 | + tbl = early_memremap(efi_mem_attr_table, sizeof(*tbl)); |
---|
32 | 30 | if (!tbl) { |
---|
33 | 31 | pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", |
---|
34 | | - efi.mem_attr_table); |
---|
| 32 | + efi_mem_attr_table); |
---|
35 | 33 | return -ENOMEM; |
---|
36 | 34 | } |
---|
37 | 35 | |
---|
38 | | - if (tbl->version > 1) { |
---|
| 36 | + if (tbl->version > 2) { |
---|
39 | 37 | pr_warn("Unexpected EFI Memory Attributes table version %d\n", |
---|
40 | 38 | tbl->version); |
---|
41 | 39 | goto unmap; |
---|
42 | 40 | } |
---|
43 | 41 | |
---|
44 | 42 | tbl_size = sizeof(*tbl) + tbl->num_entries * tbl->desc_size; |
---|
45 | | - memblock_reserve(efi.mem_attr_table, tbl_size); |
---|
| 43 | + memblock_reserve(efi_mem_attr_table, tbl_size); |
---|
46 | 44 | set_bit(EFI_MEM_ATTR, &efi.flags); |
---|
47 | 45 | |
---|
48 | 46 | unmap: |
---|
.. | .. |
---|
145 | 143 | if (WARN_ON(!efi_enabled(EFI_MEMMAP))) |
---|
146 | 144 | return 0; |
---|
147 | 145 | |
---|
148 | | - tbl = memremap(efi.mem_attr_table, tbl_size, MEMREMAP_WB); |
---|
| 146 | + tbl = memremap(efi_mem_attr_table, tbl_size, MEMREMAP_WB); |
---|
149 | 147 | if (!tbl) { |
---|
150 | 148 | pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n", |
---|
151 | | - efi.mem_attr_table); |
---|
| 149 | + efi_mem_attr_table); |
---|
152 | 150 | return -ENOMEM; |
---|
153 | 151 | } |
---|
154 | 152 | |
---|