.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Extensible Firmware Interface |
---|
3 | 4 | * |
---|
4 | 5 | * Based on Extensible Firmware Interface Specification version 2.4 |
---|
5 | 6 | * |
---|
6 | 7 | * 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 | | - * |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #include <linux/dmi.h> |
---|
.. | .. |
---|
22 | 18 | #include <linux/sched.h> |
---|
23 | 19 | #include <linux/slab.h> |
---|
24 | 20 | #include <linux/spinlock.h> |
---|
| 21 | +#include <linux/pgtable.h> |
---|
25 | 22 | |
---|
26 | 23 | #include <asm/cacheflush.h> |
---|
27 | 24 | #include <asm/efi.h> |
---|
28 | 25 | #include <asm/mmu.h> |
---|
29 | 26 | #include <asm/pgalloc.h> |
---|
30 | | -#include <asm/pgtable.h> |
---|
31 | 27 | |
---|
32 | | -extern u64 efi_system_table; |
---|
33 | | - |
---|
34 | | -#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS |
---|
| 28 | +#if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64) |
---|
35 | 29 | #include <asm/ptdump.h> |
---|
36 | 30 | |
---|
37 | 31 | static struct ptdump_info efi_ptdump_info = { |
---|
38 | 32 | .mm = &efi_mm, |
---|
39 | 33 | .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 } |
---|
42 | 37 | }, |
---|
43 | 38 | .base_addr = 0, |
---|
44 | 39 | }; |
---|
45 | 40 | |
---|
46 | 41 | static int __init ptdump_init(void) |
---|
47 | 42 | { |
---|
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"); |
---|
50 | 45 | |
---|
51 | | - return ptdump_debugfs_register(&efi_ptdump_info, "efi_page_tables"); |
---|
| 46 | + return 0; |
---|
52 | 47 | } |
---|
53 | 48 | device_initcall(ptdump_init); |
---|
54 | 49 | |
---|
.. | .. |
---|
57 | 52 | static bool __init efi_virtmap_init(void) |
---|
58 | 53 | { |
---|
59 | 54 | efi_memory_desc_t *md; |
---|
60 | | - bool systab_found; |
---|
61 | 55 | |
---|
62 | 56 | efi_mm.pgd = pgd_alloc(&efi_mm); |
---|
63 | 57 | mm_init_cpumask(&efi_mm); |
---|
64 | 58 | init_new_context(NULL, &efi_mm); |
---|
65 | 59 | |
---|
66 | | - systab_found = false; |
---|
67 | 60 | for_each_efi_memory_desc(md) { |
---|
68 | 61 | phys_addr_t phys = md->phys_addr; |
---|
69 | 62 | int ret; |
---|
.. | .. |
---|
79 | 72 | &phys, ret); |
---|
80 | 73 | return false; |
---|
81 | 74 | } |
---|
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; |
---|
96 | 75 | } |
---|
97 | 76 | |
---|
98 | 77 | if (efi_memattr_apply_permissions(&efi_mm, efi_set_mapping_permissions)) |
---|
.. | .. |
---|
122 | 101 | if (efi_memmap_init_late(efi.memmap.phys_map, mapsize)) { |
---|
123 | 102 | pr_err("Failed to remap EFI memory map\n"); |
---|
124 | 103 | 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 | + } |
---|
125 | 128 | } |
---|
126 | 129 | |
---|
127 | 130 | if (efi_runtime_disabled()) { |
---|
.. | .. |
---|
165 | 168 | static int __init arm_dmi_init(void) |
---|
166 | 169 | { |
---|
167 | 170 | /* |
---|
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 |
---|
169 | 172 | * be called early because dmi_id_init(), which is an arch_initcall |
---|
170 | 173 | * itself, depends on dmi_scan_machine() having been called already. |
---|
171 | 174 | */ |
---|
172 | | - dmi_scan_machine(); |
---|
173 | | - if (dmi_available) |
---|
174 | | - dmi_set_dump_stack_arch_desc(); |
---|
| 175 | + dmi_setup(); |
---|
175 | 176 | return 0; |
---|
176 | 177 | } |
---|
177 | 178 | core_initcall(arm_dmi_init); |
---|