hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/firmware/efi/arm-runtime.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Extensible Firmware Interface
34 *
45 * Based on Extensible Firmware Interface Specification version 2.4
56 *
67 * Copyright (C) 2013, 2014 Linaro Ltd.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
11
- *
128 */
139
1410 #include <linux/dmi.h>
....@@ -22,33 +18,32 @@
2218 #include <linux/sched.h>
2319 #include <linux/slab.h>
2420 #include <linux/spinlock.h>
21
+#include <linux/pgtable.h>
2522
2623 #include <asm/cacheflush.h>
2724 #include <asm/efi.h>
2825 #include <asm/mmu.h>
2926 #include <asm/pgalloc.h>
30
-#include <asm/pgtable.h>
3127
32
-extern u64 efi_system_table;
33
-
34
-#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS
28
+#if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64)
3529 #include <asm/ptdump.h>
3630
3731 static struct ptdump_info efi_ptdump_info = {
3832 .mm = &efi_mm,
3933 .markers = (struct addr_marker[]){
40
- { 0, "UEFI runtime start" },
41
- { TASK_SIZE_64, "UEFI runtime end" }
34
+ { 0, "UEFI runtime start" },
35
+ { DEFAULT_MAP_WINDOW_64, "UEFI runtime end" },
36
+ { -1, NULL }
4237 },
4338 .base_addr = 0,
4439 };
4540
4641 static int __init ptdump_init(void)
4742 {
48
- if (!efi_enabled(EFI_RUNTIME_SERVICES))
49
- return 0;
43
+ if (efi_enabled(EFI_RUNTIME_SERVICES))
44
+ ptdump_debugfs_register(&efi_ptdump_info, "efi_page_tables");
5045
51
- return ptdump_debugfs_register(&efi_ptdump_info, "efi_page_tables");
46
+ return 0;
5247 }
5348 device_initcall(ptdump_init);
5449
....@@ -57,13 +52,11 @@
5752 static bool __init efi_virtmap_init(void)
5853 {
5954 efi_memory_desc_t *md;
60
- bool systab_found;
6155
6256 efi_mm.pgd = pgd_alloc(&efi_mm);
6357 mm_init_cpumask(&efi_mm);
6458 init_new_context(NULL, &efi_mm);
6559
66
- systab_found = false;
6760 for_each_efi_memory_desc(md) {
6861 phys_addr_t phys = md->phys_addr;
6962 int ret;
....@@ -79,20 +72,6 @@
7972 &phys, ret);
8073 return false;
8174 }
82
- /*
83
- * If this entry covers the address of the UEFI system table,
84
- * calculate and record its virtual address.
85
- */
86
- if (efi_system_table >= phys &&
87
- efi_system_table < phys + (md->num_pages * EFI_PAGE_SIZE)) {
88
- efi.systab = (void *)(unsigned long)(efi_system_table -
89
- phys + md->virt_addr);
90
- systab_found = true;
91
- }
92
- }
93
- if (!systab_found) {
94
- pr_err("No virtual mapping found for the UEFI System Table\n");
95
- return false;
9675 }
9776
9877 if (efi_memattr_apply_permissions(&efi_mm, efi_set_mapping_permissions))
....@@ -122,6 +101,30 @@
122101 if (efi_memmap_init_late(efi.memmap.phys_map, mapsize)) {
123102 pr_err("Failed to remap EFI memory map\n");
124103 return 0;
104
+ }
105
+
106
+ if (efi_soft_reserve_enabled()) {
107
+ efi_memory_desc_t *md;
108
+
109
+ for_each_efi_memory_desc(md) {
110
+ int md_size = md->num_pages << EFI_PAGE_SHIFT;
111
+ struct resource *res;
112
+
113
+ if (!(md->attribute & EFI_MEMORY_SP))
114
+ continue;
115
+
116
+ res = kzalloc(sizeof(*res), GFP_KERNEL);
117
+ if (WARN_ON(!res))
118
+ break;
119
+
120
+ res->start = md->phys_addr;
121
+ res->end = md->phys_addr + md_size - 1;
122
+ res->name = "Soft Reserved";
123
+ res->flags = IORESOURCE_MEM;
124
+ res->desc = IORES_DESC_SOFT_RESERVED;
125
+
126
+ insert_resource(&iomem_resource, res);
127
+ }
125128 }
126129
127130 if (efi_runtime_disabled()) {
....@@ -165,13 +168,11 @@
165168 static int __init arm_dmi_init(void)
166169 {
167170 /*
168
- * On arm64/ARM, DMI depends on UEFI, and dmi_scan_machine() needs to
171
+ * On arm64/ARM, DMI depends on UEFI, and dmi_setup() needs to
169172 * be called early because dmi_id_init(), which is an arch_initcall
170173 * itself, depends on dmi_scan_machine() having been called already.
171174 */
172
- dmi_scan_machine();
173
- if (dmi_available)
174
- dmi_set_dump_stack_arch_desc();
175
+ dmi_setup();
175176 return 0;
176177 }
177178 core_initcall(arm_dmi_init);