hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/firmware/efi/memattr.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * 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.
74 */
85
96 #define pr_fmt(fmt) "efi: memattr: " fmt
....@@ -16,6 +13,7 @@
1613 #include <asm/early_ioremap.h>
1714
1815 static int __initdata tbl_size;
16
+unsigned long __ro_after_init efi_mem_attr_table = EFI_INVALID_TABLE_ADDR;
1917
2018 /*
2119 * Reserve the memory associated with the Memory Attributes configuration
....@@ -25,24 +23,24 @@
2523 {
2624 efi_memory_attributes_table_t *tbl;
2725
28
- if (efi.mem_attr_table == EFI_INVALID_TABLE_ADDR)
26
+ if (efi_mem_attr_table == EFI_INVALID_TABLE_ADDR)
2927 return 0;
3028
31
- tbl = early_memremap(efi.mem_attr_table, sizeof(*tbl));
29
+ tbl = early_memremap(efi_mem_attr_table, sizeof(*tbl));
3230 if (!tbl) {
3331 pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
34
- efi.mem_attr_table);
32
+ efi_mem_attr_table);
3533 return -ENOMEM;
3634 }
3735
38
- if (tbl->version > 1) {
36
+ if (tbl->version > 2) {
3937 pr_warn("Unexpected EFI Memory Attributes table version %d\n",
4038 tbl->version);
4139 goto unmap;
4240 }
4341
4442 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);
4644 set_bit(EFI_MEM_ATTR, &efi.flags);
4745
4846 unmap:
....@@ -145,10 +143,10 @@
145143 if (WARN_ON(!efi_enabled(EFI_MEMMAP)))
146144 return 0;
147145
148
- tbl = memremap(efi.mem_attr_table, tbl_size, MEMREMAP_WB);
146
+ tbl = memremap(efi_mem_attr_table, tbl_size, MEMREMAP_WB);
149147 if (!tbl) {
150148 pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
151
- efi.mem_attr_table);
149
+ efi_mem_attr_table);
152150 return -ENOMEM;
153151 }
154152