.. | .. |
---|
36 | 36 | #include <linux/efi.h> |
---|
37 | 37 | #include <linux/efi-bgrt.h> |
---|
38 | 38 | #include <linux/export.h> |
---|
39 | | -#include <linux/bootmem.h> |
---|
40 | | -#include <linux/slab.h> |
---|
41 | 39 | #include <linux/memblock.h> |
---|
| 40 | +#include <linux/slab.h> |
---|
42 | 41 | #include <linux/spinlock.h> |
---|
43 | 42 | #include <linux/uaccess.h> |
---|
44 | 43 | #include <linux/time.h> |
---|
.. | .. |
---|
50 | 49 | #include <asm/efi.h> |
---|
51 | 50 | #include <asm/e820/api.h> |
---|
52 | 51 | #include <asm/time.h> |
---|
53 | | -#include <asm/set_memory.h> |
---|
54 | 52 | #include <asm/tlbflush.h> |
---|
55 | 53 | #include <asm/x86_init.h> |
---|
56 | 54 | #include <asm/uv/uv.h> |
---|
57 | 55 | |
---|
58 | | -static struct efi efi_phys __initdata; |
---|
59 | | -static efi_system_table_t efi_systab __initdata; |
---|
| 56 | +static unsigned long efi_systab_phys __initdata; |
---|
| 57 | +static unsigned long prop_phys = EFI_INVALID_TABLE_ADDR; |
---|
| 58 | +static unsigned long uga_phys = EFI_INVALID_TABLE_ADDR; |
---|
| 59 | +static unsigned long efi_runtime, efi_nr_tables; |
---|
60 | 60 | |
---|
61 | | -static efi_config_table_type_t arch_tables[] __initdata = { |
---|
| 61 | +unsigned long efi_fw_vendor, efi_config_table; |
---|
| 62 | + |
---|
| 63 | +static const efi_config_table_type_t arch_tables[] __initconst = { |
---|
| 64 | + {EFI_PROPERTIES_TABLE_GUID, &prop_phys, "PROP" }, |
---|
| 65 | + {UGA_IO_PROTOCOL_GUID, &uga_phys, "UGA" }, |
---|
62 | 66 | #ifdef CONFIG_X86_UV |
---|
63 | | - {UV_SYSTEM_TABLE_GUID, "UVsystab", &efi.uv_systab}, |
---|
| 67 | + {UV_SYSTEM_TABLE_GUID, &uv_systab_phys, "UVsystab" }, |
---|
64 | 68 | #endif |
---|
65 | | - {NULL_GUID, NULL, NULL}, |
---|
| 69 | + {}, |
---|
| 70 | +}; |
---|
| 71 | + |
---|
| 72 | +static const unsigned long * const efi_tables[] = { |
---|
| 73 | + &efi.acpi, |
---|
| 74 | + &efi.acpi20, |
---|
| 75 | + &efi.smbios, |
---|
| 76 | + &efi.smbios3, |
---|
| 77 | + &uga_phys, |
---|
| 78 | +#ifdef CONFIG_X86_UV |
---|
| 79 | + &uv_systab_phys, |
---|
| 80 | +#endif |
---|
| 81 | + &efi_fw_vendor, |
---|
| 82 | + &efi_runtime, |
---|
| 83 | + &efi_config_table, |
---|
| 84 | + &efi.esrt, |
---|
| 85 | + &prop_phys, |
---|
| 86 | + &efi_mem_attr_table, |
---|
| 87 | +#ifdef CONFIG_EFI_RCI2_TABLE |
---|
| 88 | + &rci2_table_phys, |
---|
| 89 | +#endif |
---|
| 90 | + &efi.tpm_log, |
---|
| 91 | + &efi.tpm_final_log, |
---|
| 92 | + &efi_rng_seed, |
---|
| 93 | +#ifdef CONFIG_LOAD_UEFI_KEYS |
---|
| 94 | + &efi.mokvar_table, |
---|
| 95 | +#endif |
---|
66 | 96 | }; |
---|
67 | 97 | |
---|
68 | 98 | u64 efi_setup; /* efi setup_data physical address */ |
---|
.. | .. |
---|
75 | 105 | } |
---|
76 | 106 | early_param("add_efi_memmap", setup_add_efi_memmap); |
---|
77 | 107 | |
---|
78 | | -static efi_status_t __init phys_efi_set_virtual_address_map( |
---|
79 | | - unsigned long memory_map_size, |
---|
80 | | - unsigned long descriptor_size, |
---|
81 | | - u32 descriptor_version, |
---|
82 | | - efi_memory_desc_t *virtual_map) |
---|
83 | | -{ |
---|
84 | | - efi_status_t status; |
---|
85 | | - unsigned long flags; |
---|
86 | | - pgd_t *save_pgd; |
---|
87 | | - |
---|
88 | | - save_pgd = efi_call_phys_prolog(); |
---|
89 | | - |
---|
90 | | - /* Disable interrupts around EFI calls: */ |
---|
91 | | - local_irq_save(flags); |
---|
92 | | - status = efi_call_phys(efi_phys.set_virtual_address_map, |
---|
93 | | - memory_map_size, descriptor_size, |
---|
94 | | - descriptor_version, virtual_map); |
---|
95 | | - local_irq_restore(flags); |
---|
96 | | - |
---|
97 | | - efi_call_phys_epilog(save_pgd); |
---|
98 | | - |
---|
99 | | - return status; |
---|
100 | | -} |
---|
101 | | - |
---|
102 | 108 | void __init efi_find_mirror(void) |
---|
103 | 109 | { |
---|
104 | 110 | efi_memory_desc_t *md; |
---|
105 | 111 | u64 mirror_size = 0, total_size = 0; |
---|
| 112 | + |
---|
| 113 | + if (!efi_enabled(EFI_MEMMAP)) |
---|
| 114 | + return; |
---|
106 | 115 | |
---|
107 | 116 | for_each_efi_memory_desc(md) { |
---|
108 | 117 | unsigned long long start = md->phys_addr; |
---|
.. | .. |
---|
121 | 130 | |
---|
122 | 131 | /* |
---|
123 | 132 | * Tell the kernel about the EFI memory map. This might include |
---|
124 | | - * more than the max 128 entries that can fit in the e820 legacy |
---|
125 | | - * (zeropage) memory map. |
---|
| 133 | + * more than the max 128 entries that can fit in the passed in e820 |
---|
| 134 | + * legacy (zeropage) memory map, but the kernel's e820 table can hold |
---|
| 135 | + * E820_MAX_ENTRIES. |
---|
126 | 136 | */ |
---|
127 | 137 | |
---|
128 | 138 | static void __init do_add_efi_memmap(void) |
---|
129 | 139 | { |
---|
130 | 140 | efi_memory_desc_t *md; |
---|
| 141 | + |
---|
| 142 | + if (!efi_enabled(EFI_MEMMAP)) |
---|
| 143 | + return; |
---|
131 | 144 | |
---|
132 | 145 | for_each_efi_memory_desc(md) { |
---|
133 | 146 | unsigned long long start = md->phys_addr; |
---|
.. | .. |
---|
140 | 153 | case EFI_BOOT_SERVICES_CODE: |
---|
141 | 154 | case EFI_BOOT_SERVICES_DATA: |
---|
142 | 155 | case EFI_CONVENTIONAL_MEMORY: |
---|
143 | | - if (md->attribute & EFI_MEMORY_WB) |
---|
| 156 | + if (efi_soft_reserve_enabled() |
---|
| 157 | + && (md->attribute & EFI_MEMORY_SP)) |
---|
| 158 | + e820_type = E820_TYPE_SOFT_RESERVED; |
---|
| 159 | + else if (md->attribute & EFI_MEMORY_WB) |
---|
144 | 160 | e820_type = E820_TYPE_RAM; |
---|
145 | 161 | else |
---|
146 | 162 | e820_type = E820_TYPE_RESERVED; |
---|
.. | .. |
---|
166 | 182 | e820_type = E820_TYPE_RESERVED; |
---|
167 | 183 | break; |
---|
168 | 184 | } |
---|
| 185 | + |
---|
169 | 186 | e820__range_add(start, size, e820_type); |
---|
170 | 187 | } |
---|
171 | 188 | e820__update_table(e820_table); |
---|
| 189 | +} |
---|
| 190 | + |
---|
| 191 | +/* |
---|
| 192 | + * Given add_efi_memmap defaults to 0 and there there is no alternative |
---|
| 193 | + * e820 mechanism for soft-reserved memory, import the full EFI memory |
---|
| 194 | + * map if soft reservations are present and enabled. Otherwise, the |
---|
| 195 | + * mechanism to disable the kernel's consideration of EFI_MEMORY_SP is |
---|
| 196 | + * the efi=nosoftreserve option. |
---|
| 197 | + */ |
---|
| 198 | +static bool do_efi_soft_reserve(void) |
---|
| 199 | +{ |
---|
| 200 | + efi_memory_desc_t *md; |
---|
| 201 | + |
---|
| 202 | + if (!efi_enabled(EFI_MEMMAP)) |
---|
| 203 | + return false; |
---|
| 204 | + |
---|
| 205 | + if (!efi_soft_reserve_enabled()) |
---|
| 206 | + return false; |
---|
| 207 | + |
---|
| 208 | + for_each_efi_memory_desc(md) |
---|
| 209 | + if (md->type == EFI_CONVENTIONAL_MEMORY && |
---|
| 210 | + (md->attribute & EFI_MEMORY_SP)) |
---|
| 211 | + return true; |
---|
| 212 | + return false; |
---|
172 | 213 | } |
---|
173 | 214 | |
---|
174 | 215 | int __init efi_memblock_x86_reserve_range(void) |
---|
.. | .. |
---|
181 | 222 | if (efi_enabled(EFI_PARAVIRT)) |
---|
182 | 223 | return 0; |
---|
183 | 224 | |
---|
184 | | -#ifdef CONFIG_X86_32 |
---|
185 | | - /* Can't handle data above 4GB at this time */ |
---|
186 | | - if (e->efi_memmap_hi) { |
---|
| 225 | + /* Can't handle firmware tables above 4GB on i386 */ |
---|
| 226 | + if (IS_ENABLED(CONFIG_X86_32) && e->efi_memmap_hi > 0) { |
---|
187 | 227 | pr_err("Memory map is above 4GB, disabling EFI.\n"); |
---|
188 | 228 | return -EINVAL; |
---|
189 | 229 | } |
---|
190 | | - pmap = e->efi_memmap; |
---|
191 | | -#else |
---|
192 | | - pmap = (e->efi_memmap | ((__u64)e->efi_memmap_hi << 32)); |
---|
193 | | -#endif |
---|
| 230 | + pmap = (phys_addr_t)(e->efi_memmap | ((u64)e->efi_memmap_hi << 32)); |
---|
| 231 | + |
---|
194 | 232 | data.phys_map = pmap; |
---|
195 | 233 | data.size = e->efi_memmap_size; |
---|
196 | 234 | data.desc_size = e->efi_memdesc_size; |
---|
.. | .. |
---|
200 | 238 | if (rv) |
---|
201 | 239 | return rv; |
---|
202 | 240 | |
---|
203 | | - if (add_efi_memmap) |
---|
| 241 | + if (add_efi_memmap || do_efi_soft_reserve()) |
---|
204 | 242 | do_add_efi_memmap(); |
---|
| 243 | + |
---|
| 244 | + efi_fake_memmap_early(); |
---|
205 | 245 | |
---|
206 | 246 | WARN(efi.memmap.desc_version != 1, |
---|
207 | 247 | "Unexpected EFI_MEMORY_DESCRIPTOR version %ld", |
---|
208 | 248 | efi.memmap.desc_version); |
---|
209 | 249 | |
---|
210 | 250 | memblock_reserve(pmap, efi.memmap.nr_map * efi.memmap.desc_size); |
---|
| 251 | + set_bit(EFI_PRESERVE_BS_REGIONS, &efi.flags); |
---|
211 | 252 | |
---|
212 | 253 | return 0; |
---|
213 | 254 | } |
---|
.. | .. |
---|
269 | 310 | } |
---|
270 | 311 | |
---|
271 | 312 | if (n_removal > 0) { |
---|
272 | | - u64 size = efi.memmap.nr_map - n_removal; |
---|
| 313 | + struct efi_memory_map_data data = { |
---|
| 314 | + .phys_map = efi.memmap.phys_map, |
---|
| 315 | + .desc_version = efi.memmap.desc_version, |
---|
| 316 | + .desc_size = efi.memmap.desc_size, |
---|
| 317 | + .size = efi.memmap.desc_size * (efi.memmap.nr_map - n_removal), |
---|
| 318 | + .flags = 0, |
---|
| 319 | + }; |
---|
273 | 320 | |
---|
274 | 321 | pr_warn("Removing %d invalid memory map entries.\n", n_removal); |
---|
275 | | - efi_memmap_install(efi.memmap.phys_map, size); |
---|
| 322 | + efi_memmap_install(&data); |
---|
276 | 323 | } |
---|
277 | 324 | } |
---|
278 | 325 | |
---|
.. | .. |
---|
292 | 339 | } |
---|
293 | 340 | } |
---|
294 | 341 | |
---|
295 | | -static int __init efi_systab_init(void *phys) |
---|
| 342 | +static int __init efi_systab_init(unsigned long phys) |
---|
296 | 343 | { |
---|
| 344 | + int size = efi_enabled(EFI_64BIT) ? sizeof(efi_system_table_64_t) |
---|
| 345 | + : sizeof(efi_system_table_32_t); |
---|
| 346 | + const efi_table_hdr_t *hdr; |
---|
| 347 | + bool over4g = false; |
---|
| 348 | + void *p; |
---|
| 349 | + int ret; |
---|
| 350 | + |
---|
| 351 | + hdr = p = early_memremap_ro(phys, size); |
---|
| 352 | + if (p == NULL) { |
---|
| 353 | + pr_err("Couldn't map the system table!\n"); |
---|
| 354 | + return -ENOMEM; |
---|
| 355 | + } |
---|
| 356 | + |
---|
| 357 | + ret = efi_systab_check_header(hdr, 1); |
---|
| 358 | + if (ret) { |
---|
| 359 | + early_memunmap(p, size); |
---|
| 360 | + return ret; |
---|
| 361 | + } |
---|
| 362 | + |
---|
297 | 363 | if (efi_enabled(EFI_64BIT)) { |
---|
298 | | - efi_system_table_64_t *systab64; |
---|
299 | | - struct efi_setup_data *data = NULL; |
---|
300 | | - u64 tmp = 0; |
---|
| 364 | + const efi_system_table_64_t *systab64 = p; |
---|
| 365 | + |
---|
| 366 | + efi_runtime = systab64->runtime; |
---|
| 367 | + over4g = systab64->runtime > U32_MAX; |
---|
301 | 368 | |
---|
302 | 369 | if (efi_setup) { |
---|
303 | | - data = early_memremap(efi_setup, sizeof(*data)); |
---|
304 | | - if (!data) |
---|
| 370 | + struct efi_setup_data *data; |
---|
| 371 | + |
---|
| 372 | + data = early_memremap_ro(efi_setup, sizeof(*data)); |
---|
| 373 | + if (!data) { |
---|
| 374 | + early_memunmap(p, size); |
---|
305 | 375 | return -ENOMEM; |
---|
306 | | - } |
---|
307 | | - systab64 = early_memremap((unsigned long)phys, |
---|
308 | | - sizeof(*systab64)); |
---|
309 | | - if (systab64 == NULL) { |
---|
310 | | - pr_err("Couldn't map the system table!\n"); |
---|
311 | | - if (data) |
---|
312 | | - early_memunmap(data, sizeof(*data)); |
---|
313 | | - return -ENOMEM; |
---|
314 | | - } |
---|
| 376 | + } |
---|
315 | 377 | |
---|
316 | | - efi_systab.hdr = systab64->hdr; |
---|
317 | | - efi_systab.fw_vendor = data ? (unsigned long)data->fw_vendor : |
---|
318 | | - systab64->fw_vendor; |
---|
319 | | - tmp |= data ? data->fw_vendor : systab64->fw_vendor; |
---|
320 | | - efi_systab.fw_revision = systab64->fw_revision; |
---|
321 | | - efi_systab.con_in_handle = systab64->con_in_handle; |
---|
322 | | - tmp |= systab64->con_in_handle; |
---|
323 | | - efi_systab.con_in = systab64->con_in; |
---|
324 | | - tmp |= systab64->con_in; |
---|
325 | | - efi_systab.con_out_handle = systab64->con_out_handle; |
---|
326 | | - tmp |= systab64->con_out_handle; |
---|
327 | | - efi_systab.con_out = systab64->con_out; |
---|
328 | | - tmp |= systab64->con_out; |
---|
329 | | - efi_systab.stderr_handle = systab64->stderr_handle; |
---|
330 | | - tmp |= systab64->stderr_handle; |
---|
331 | | - efi_systab.stderr = systab64->stderr; |
---|
332 | | - tmp |= systab64->stderr; |
---|
333 | | - efi_systab.runtime = data ? |
---|
334 | | - (void *)(unsigned long)data->runtime : |
---|
335 | | - (void *)(unsigned long)systab64->runtime; |
---|
336 | | - tmp |= data ? data->runtime : systab64->runtime; |
---|
337 | | - efi_systab.boottime = (void *)(unsigned long)systab64->boottime; |
---|
338 | | - tmp |= systab64->boottime; |
---|
339 | | - efi_systab.nr_tables = systab64->nr_tables; |
---|
340 | | - efi_systab.tables = data ? (unsigned long)data->tables : |
---|
341 | | - systab64->tables; |
---|
342 | | - tmp |= data ? data->tables : systab64->tables; |
---|
| 378 | + efi_fw_vendor = (unsigned long)data->fw_vendor; |
---|
| 379 | + efi_config_table = (unsigned long)data->tables; |
---|
343 | 380 | |
---|
344 | | - early_memunmap(systab64, sizeof(*systab64)); |
---|
345 | | - if (data) |
---|
| 381 | + over4g |= data->fw_vendor > U32_MAX || |
---|
| 382 | + data->tables > U32_MAX; |
---|
| 383 | + |
---|
346 | 384 | early_memunmap(data, sizeof(*data)); |
---|
347 | | -#ifdef CONFIG_X86_32 |
---|
348 | | - if (tmp >> 32) { |
---|
349 | | - pr_err("EFI data located above 4GB, disabling EFI.\n"); |
---|
350 | | - return -EINVAL; |
---|
| 385 | + } else { |
---|
| 386 | + efi_fw_vendor = systab64->fw_vendor; |
---|
| 387 | + efi_config_table = systab64->tables; |
---|
| 388 | + |
---|
| 389 | + over4g |= systab64->fw_vendor > U32_MAX || |
---|
| 390 | + systab64->tables > U32_MAX; |
---|
351 | 391 | } |
---|
352 | | -#endif |
---|
| 392 | + efi_nr_tables = systab64->nr_tables; |
---|
353 | 393 | } else { |
---|
354 | | - efi_system_table_32_t *systab32; |
---|
| 394 | + const efi_system_table_32_t *systab32 = p; |
---|
355 | 395 | |
---|
356 | | - systab32 = early_memremap((unsigned long)phys, |
---|
357 | | - sizeof(*systab32)); |
---|
358 | | - if (systab32 == NULL) { |
---|
359 | | - pr_err("Couldn't map the system table!\n"); |
---|
360 | | - return -ENOMEM; |
---|
361 | | - } |
---|
362 | | - |
---|
363 | | - efi_systab.hdr = systab32->hdr; |
---|
364 | | - efi_systab.fw_vendor = systab32->fw_vendor; |
---|
365 | | - efi_systab.fw_revision = systab32->fw_revision; |
---|
366 | | - efi_systab.con_in_handle = systab32->con_in_handle; |
---|
367 | | - efi_systab.con_in = systab32->con_in; |
---|
368 | | - efi_systab.con_out_handle = systab32->con_out_handle; |
---|
369 | | - efi_systab.con_out = systab32->con_out; |
---|
370 | | - efi_systab.stderr_handle = systab32->stderr_handle; |
---|
371 | | - efi_systab.stderr = systab32->stderr; |
---|
372 | | - efi_systab.runtime = (void *)(unsigned long)systab32->runtime; |
---|
373 | | - efi_systab.boottime = (void *)(unsigned long)systab32->boottime; |
---|
374 | | - efi_systab.nr_tables = systab32->nr_tables; |
---|
375 | | - efi_systab.tables = systab32->tables; |
---|
376 | | - |
---|
377 | | - early_memunmap(systab32, sizeof(*systab32)); |
---|
| 396 | + efi_fw_vendor = systab32->fw_vendor; |
---|
| 397 | + efi_runtime = systab32->runtime; |
---|
| 398 | + efi_config_table = systab32->tables; |
---|
| 399 | + efi_nr_tables = systab32->nr_tables; |
---|
378 | 400 | } |
---|
379 | 401 | |
---|
380 | | - efi.systab = &efi_systab; |
---|
| 402 | + efi.runtime_version = hdr->revision; |
---|
381 | 403 | |
---|
382 | | - /* |
---|
383 | | - * Verify the EFI Table |
---|
384 | | - */ |
---|
385 | | - if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) { |
---|
386 | | - pr_err("System table signature incorrect!\n"); |
---|
| 404 | + efi_systab_report_header(hdr, efi_fw_vendor); |
---|
| 405 | + early_memunmap(p, size); |
---|
| 406 | + |
---|
| 407 | + if (IS_ENABLED(CONFIG_X86_32) && over4g) { |
---|
| 408 | + pr_err("EFI data located above 4GB, disabling EFI.\n"); |
---|
387 | 409 | return -EINVAL; |
---|
388 | 410 | } |
---|
389 | | - if ((efi.systab->hdr.revision >> 16) == 0) |
---|
390 | | - pr_err("Warning: System table version %d.%02d, expected 1.00 or greater!\n", |
---|
391 | | - efi.systab->hdr.revision >> 16, |
---|
392 | | - efi.systab->hdr.revision & 0xffff); |
---|
393 | 411 | |
---|
394 | 412 | return 0; |
---|
395 | 413 | } |
---|
396 | 414 | |
---|
397 | | -static int __init efi_runtime_init32(void) |
---|
| 415 | +static int __init efi_config_init(const efi_config_table_type_t *arch_tables) |
---|
398 | 416 | { |
---|
399 | | - efi_runtime_services_32_t *runtime; |
---|
| 417 | + void *config_tables; |
---|
| 418 | + int sz, ret; |
---|
400 | 419 | |
---|
401 | | - runtime = early_memremap((unsigned long)efi.systab->runtime, |
---|
402 | | - sizeof(efi_runtime_services_32_t)); |
---|
403 | | - if (!runtime) { |
---|
404 | | - pr_err("Could not map the runtime service table!\n"); |
---|
| 420 | + if (efi_nr_tables == 0) |
---|
| 421 | + return 0; |
---|
| 422 | + |
---|
| 423 | + if (efi_enabled(EFI_64BIT)) |
---|
| 424 | + sz = sizeof(efi_config_table_64_t); |
---|
| 425 | + else |
---|
| 426 | + sz = sizeof(efi_config_table_32_t); |
---|
| 427 | + |
---|
| 428 | + /* |
---|
| 429 | + * Let's see what config tables the firmware passed to us. |
---|
| 430 | + */ |
---|
| 431 | + config_tables = early_memremap(efi_config_table, efi_nr_tables * sz); |
---|
| 432 | + if (config_tables == NULL) { |
---|
| 433 | + pr_err("Could not map Configuration table!\n"); |
---|
405 | 434 | return -ENOMEM; |
---|
406 | 435 | } |
---|
407 | 436 | |
---|
408 | | - /* |
---|
409 | | - * We will only need *early* access to the SetVirtualAddressMap |
---|
410 | | - * EFI runtime service. All other runtime services will be called |
---|
411 | | - * via the virtual mapping. |
---|
412 | | - */ |
---|
413 | | - efi_phys.set_virtual_address_map = |
---|
414 | | - (efi_set_virtual_address_map_t *) |
---|
415 | | - (unsigned long)runtime->set_virtual_address_map; |
---|
416 | | - early_memunmap(runtime, sizeof(efi_runtime_services_32_t)); |
---|
| 437 | + ret = efi_config_parse_tables(config_tables, efi_nr_tables, |
---|
| 438 | + arch_tables); |
---|
417 | 439 | |
---|
418 | | - return 0; |
---|
419 | | -} |
---|
420 | | - |
---|
421 | | -static int __init efi_runtime_init64(void) |
---|
422 | | -{ |
---|
423 | | - efi_runtime_services_64_t *runtime; |
---|
424 | | - |
---|
425 | | - runtime = early_memremap((unsigned long)efi.systab->runtime, |
---|
426 | | - sizeof(efi_runtime_services_64_t)); |
---|
427 | | - if (!runtime) { |
---|
428 | | - pr_err("Could not map the runtime service table!\n"); |
---|
429 | | - return -ENOMEM; |
---|
430 | | - } |
---|
431 | | - |
---|
432 | | - /* |
---|
433 | | - * We will only need *early* access to the SetVirtualAddressMap |
---|
434 | | - * EFI runtime service. All other runtime services will be called |
---|
435 | | - * via the virtual mapping. |
---|
436 | | - */ |
---|
437 | | - efi_phys.set_virtual_address_map = |
---|
438 | | - (efi_set_virtual_address_map_t *) |
---|
439 | | - (unsigned long)runtime->set_virtual_address_map; |
---|
440 | | - early_memunmap(runtime, sizeof(efi_runtime_services_64_t)); |
---|
441 | | - |
---|
442 | | - return 0; |
---|
443 | | -} |
---|
444 | | - |
---|
445 | | -static int __init efi_runtime_init(void) |
---|
446 | | -{ |
---|
447 | | - int rv; |
---|
448 | | - |
---|
449 | | - /* |
---|
450 | | - * Check out the runtime services table. We need to map |
---|
451 | | - * the runtime services table so that we can grab the physical |
---|
452 | | - * address of several of the EFI runtime functions, needed to |
---|
453 | | - * set the firmware into virtual mode. |
---|
454 | | - * |
---|
455 | | - * When EFI_PARAVIRT is in force then we could not map runtime |
---|
456 | | - * service memory region because we do not have direct access to it. |
---|
457 | | - * However, runtime services are available through proxy functions |
---|
458 | | - * (e.g. in case of Xen dom0 EFI implementation they call special |
---|
459 | | - * hypercall which executes relevant EFI functions) and that is why |
---|
460 | | - * they are always enabled. |
---|
461 | | - */ |
---|
462 | | - |
---|
463 | | - if (!efi_enabled(EFI_PARAVIRT)) { |
---|
464 | | - if (efi_enabled(EFI_64BIT)) |
---|
465 | | - rv = efi_runtime_init64(); |
---|
466 | | - else |
---|
467 | | - rv = efi_runtime_init32(); |
---|
468 | | - |
---|
469 | | - if (rv) |
---|
470 | | - return rv; |
---|
471 | | - } |
---|
472 | | - |
---|
473 | | - set_bit(EFI_RUNTIME_SERVICES, &efi.flags); |
---|
474 | | - |
---|
475 | | - return 0; |
---|
| 440 | + early_memunmap(config_tables, efi_nr_tables * sz); |
---|
| 441 | + return ret; |
---|
476 | 442 | } |
---|
477 | 443 | |
---|
478 | 444 | void __init efi_init(void) |
---|
479 | 445 | { |
---|
480 | | - efi_char16_t *c16; |
---|
481 | | - char vendor[100] = "unknown"; |
---|
482 | | - int i = 0; |
---|
483 | | - |
---|
484 | | -#ifdef CONFIG_X86_32 |
---|
485 | | - if (boot_params.efi_info.efi_systab_hi || |
---|
486 | | - boot_params.efi_info.efi_memmap_hi) { |
---|
| 446 | + if (IS_ENABLED(CONFIG_X86_32) && |
---|
| 447 | + (boot_params.efi_info.efi_systab_hi || |
---|
| 448 | + boot_params.efi_info.efi_memmap_hi)) { |
---|
487 | 449 | pr_info("Table located above 4GB, disabling EFI.\n"); |
---|
488 | 450 | return; |
---|
489 | 451 | } |
---|
490 | | - efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab; |
---|
491 | | -#else |
---|
492 | | - efi_phys.systab = (efi_system_table_t *) |
---|
493 | | - (boot_params.efi_info.efi_systab | |
---|
494 | | - ((__u64)boot_params.efi_info.efi_systab_hi<<32)); |
---|
495 | | -#endif |
---|
496 | 452 | |
---|
497 | | - if (efi_systab_init(efi_phys.systab)) |
---|
| 453 | + efi_systab_phys = boot_params.efi_info.efi_systab | |
---|
| 454 | + ((__u64)boot_params.efi_info.efi_systab_hi << 32); |
---|
| 455 | + |
---|
| 456 | + if (efi_systab_init(efi_systab_phys)) |
---|
498 | 457 | return; |
---|
499 | 458 | |
---|
500 | | - efi.config_table = (unsigned long)efi.systab->tables; |
---|
501 | | - efi.fw_vendor = (unsigned long)efi.systab->fw_vendor; |
---|
502 | | - efi.runtime = (unsigned long)efi.systab->runtime; |
---|
503 | | - |
---|
504 | | - /* |
---|
505 | | - * Show what we know for posterity |
---|
506 | | - */ |
---|
507 | | - c16 = early_memremap_ro(efi.systab->fw_vendor, |
---|
508 | | - sizeof(vendor) * sizeof(efi_char16_t)); |
---|
509 | | - if (c16) { |
---|
510 | | - for (i = 0; i < sizeof(vendor) - 1 && c16[i]; ++i) |
---|
511 | | - vendor[i] = c16[i]; |
---|
512 | | - vendor[i] = '\0'; |
---|
513 | | - early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t)); |
---|
514 | | - } else { |
---|
515 | | - pr_err("Could not map the firmware vendor!\n"); |
---|
516 | | - } |
---|
517 | | - |
---|
518 | | - pr_info("EFI v%u.%.02u by %s\n", |
---|
519 | | - efi.systab->hdr.revision >> 16, |
---|
520 | | - efi.systab->hdr.revision & 0xffff, vendor); |
---|
521 | | - |
---|
522 | | - if (efi_reuse_config(efi.systab->tables, efi.systab->nr_tables)) |
---|
| 459 | + if (efi_reuse_config(efi_config_table, efi_nr_tables)) |
---|
523 | 460 | return; |
---|
524 | 461 | |
---|
525 | 462 | if (efi_config_init(arch_tables)) |
---|
.. | .. |
---|
532 | 469 | |
---|
533 | 470 | if (!efi_runtime_supported()) |
---|
534 | 471 | pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n"); |
---|
535 | | - else { |
---|
536 | | - if (efi_runtime_disabled() || efi_runtime_init()) { |
---|
537 | | - efi_memmap_unmap(); |
---|
538 | | - return; |
---|
| 472 | + |
---|
| 473 | + if (!efi_runtime_supported() || efi_runtime_disabled()) { |
---|
| 474 | + efi_memmap_unmap(); |
---|
| 475 | + return; |
---|
| 476 | + } |
---|
| 477 | + |
---|
| 478 | + /* Parse the EFI Properties table if it exists */ |
---|
| 479 | + if (prop_phys != EFI_INVALID_TABLE_ADDR) { |
---|
| 480 | + efi_properties_table_t *tbl; |
---|
| 481 | + |
---|
| 482 | + tbl = early_memremap_ro(prop_phys, sizeof(*tbl)); |
---|
| 483 | + if (tbl == NULL) { |
---|
| 484 | + pr_err("Could not map Properties table!\n"); |
---|
| 485 | + } else { |
---|
| 486 | + if (tbl->memory_protection_attribute & |
---|
| 487 | + EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) |
---|
| 488 | + set_bit(EFI_NX_PE_DATA, &efi.flags); |
---|
| 489 | + |
---|
| 490 | + early_memunmap(tbl, sizeof(*tbl)); |
---|
539 | 491 | } |
---|
540 | 492 | } |
---|
541 | 493 | |
---|
| 494 | + set_bit(EFI_RUNTIME_SERVICES, &efi.flags); |
---|
542 | 495 | efi_clean_memmap(); |
---|
543 | 496 | |
---|
544 | 497 | if (efi_enabled(EFI_DBG)) |
---|
545 | 498 | efi_print_memmap(); |
---|
546 | | -} |
---|
547 | | - |
---|
548 | | -void __init efi_set_executable(efi_memory_desc_t *md, bool executable) |
---|
549 | | -{ |
---|
550 | | - u64 addr, npages; |
---|
551 | | - |
---|
552 | | - addr = md->virt_addr; |
---|
553 | | - npages = md->num_pages; |
---|
554 | | - |
---|
555 | | - memrange_efi_to_native(&addr, &npages); |
---|
556 | | - |
---|
557 | | - if (executable) |
---|
558 | | - set_memory_x(addr, npages); |
---|
559 | | - else |
---|
560 | | - set_memory_nx(addr, npages); |
---|
561 | | -} |
---|
562 | | - |
---|
563 | | -void __init runtime_code_page_mkexec(void) |
---|
564 | | -{ |
---|
565 | | - efi_memory_desc_t *md; |
---|
566 | | - |
---|
567 | | - /* Make EFI runtime service code area executable */ |
---|
568 | | - for_each_efi_memory_desc(md) { |
---|
569 | | - if (md->type != EFI_RUNTIME_SERVICES_CODE) |
---|
570 | | - continue; |
---|
571 | | - |
---|
572 | | - efi_set_executable(md, true); |
---|
573 | | - } |
---|
574 | | -} |
---|
575 | | - |
---|
576 | | -void __init efi_memory_uc(u64 addr, unsigned long size) |
---|
577 | | -{ |
---|
578 | | - unsigned long page_shift = 1UL << EFI_PAGE_SHIFT; |
---|
579 | | - u64 npages; |
---|
580 | | - |
---|
581 | | - npages = round_up(size, page_shift) / page_shift; |
---|
582 | | - memrange_efi_to_native(&addr, &npages); |
---|
583 | | - set_memory_uc(addr, npages); |
---|
584 | | -} |
---|
585 | | - |
---|
586 | | -void __init old_map_region(efi_memory_desc_t *md) |
---|
587 | | -{ |
---|
588 | | - u64 start_pfn, end_pfn, end; |
---|
589 | | - unsigned long size; |
---|
590 | | - void *va; |
---|
591 | | - |
---|
592 | | - start_pfn = PFN_DOWN(md->phys_addr); |
---|
593 | | - size = md->num_pages << PAGE_SHIFT; |
---|
594 | | - end = md->phys_addr + size; |
---|
595 | | - end_pfn = PFN_UP(end); |
---|
596 | | - |
---|
597 | | - if (pfn_range_is_mapped(start_pfn, end_pfn)) { |
---|
598 | | - va = __va(md->phys_addr); |
---|
599 | | - |
---|
600 | | - if (!(md->attribute & EFI_MEMORY_WB)) |
---|
601 | | - efi_memory_uc((u64)(unsigned long)va, size); |
---|
602 | | - } else |
---|
603 | | - va = efi_ioremap(md->phys_addr, size, |
---|
604 | | - md->type, md->attribute); |
---|
605 | | - |
---|
606 | | - md->virt_addr = (u64) (unsigned long) va; |
---|
607 | | - if (!va) |
---|
608 | | - pr_err("ioremap of 0x%llX failed!\n", |
---|
609 | | - (unsigned long long)md->phys_addr); |
---|
610 | 499 | } |
---|
611 | 500 | |
---|
612 | 501 | /* Merge contiguous regions of the same type and attribute */ |
---|
.. | .. |
---|
637 | 526 | continue; |
---|
638 | 527 | } |
---|
639 | 528 | prev_md = md; |
---|
640 | | - } |
---|
641 | | -} |
---|
642 | | - |
---|
643 | | -static void __init get_systab_virt_addr(efi_memory_desc_t *md) |
---|
644 | | -{ |
---|
645 | | - unsigned long size; |
---|
646 | | - u64 end, systab; |
---|
647 | | - |
---|
648 | | - size = md->num_pages << EFI_PAGE_SHIFT; |
---|
649 | | - end = md->phys_addr + size; |
---|
650 | | - systab = (u64)(unsigned long)efi_phys.systab; |
---|
651 | | - if (md->phys_addr <= systab && systab < end) { |
---|
652 | | - systab += md->virt_addr - md->phys_addr; |
---|
653 | | - efi.systab = (efi_system_table_t *)(unsigned long)systab; |
---|
654 | 529 | } |
---|
655 | 530 | } |
---|
656 | 531 | |
---|
.. | .. |
---|
707 | 582 | */ |
---|
708 | 583 | static void *efi_map_next_entry(void *entry) |
---|
709 | 584 | { |
---|
710 | | - if (!efi_enabled(EFI_OLD_MEMMAP) && efi_enabled(EFI_64BIT)) { |
---|
| 585 | + if (efi_enabled(EFI_64BIT)) { |
---|
711 | 586 | /* |
---|
712 | 587 | * Starting in UEFI v2.5 the EFI_PROPERTIES_TABLE |
---|
713 | 588 | * config table feature requires us to map all entries |
---|
.. | .. |
---|
756 | 631 | return false; |
---|
757 | 632 | |
---|
758 | 633 | /* |
---|
| 634 | + * EFI specific purpose memory may be reserved by default |
---|
| 635 | + * depending on kernel config and boot options. |
---|
| 636 | + */ |
---|
| 637 | + if (md->type == EFI_CONVENTIONAL_MEMORY && |
---|
| 638 | + efi_soft_reserve_enabled() && |
---|
| 639 | + (md->attribute & EFI_MEMORY_SP)) |
---|
| 640 | + return false; |
---|
| 641 | + |
---|
| 642 | + /* |
---|
759 | 643 | * Map all of RAM so that we can access arguments in the 1:1 |
---|
760 | 644 | * mapping when making EFI runtime calls. |
---|
761 | 645 | */ |
---|
762 | | - if (IS_ENABLED(CONFIG_EFI_MIXED) && !efi_is_native()) { |
---|
| 646 | + if (efi_is_mixed()) { |
---|
763 | 647 | if (md->type == EFI_CONVENTIONAL_MEMORY || |
---|
764 | 648 | md->type == EFI_LOADER_DATA || |
---|
765 | 649 | md->type == EFI_LOADER_CODE) |
---|
.. | .. |
---|
800 | 684 | continue; |
---|
801 | 685 | |
---|
802 | 686 | efi_map_region(md); |
---|
803 | | - get_systab_virt_addr(md); |
---|
804 | 687 | |
---|
805 | 688 | if (left < desc_size) { |
---|
806 | 689 | new_memmap = realloc_pages(new_memmap, *pg_shift); |
---|
.. | .. |
---|
826 | 709 | efi_memory_desc_t *md; |
---|
827 | 710 | unsigned int num_pages; |
---|
828 | 711 | |
---|
829 | | - efi.systab = NULL; |
---|
830 | | - |
---|
831 | 712 | /* |
---|
832 | 713 | * We don't do virtual mode, since we don't do runtime services, on |
---|
833 | | - * non-native EFI. With efi=old_map, we don't do runtime services in |
---|
834 | | - * kexec kernel because in the initial boot something else might |
---|
835 | | - * have been mapped at these virtual addresses. |
---|
| 714 | + * non-native EFI. |
---|
836 | 715 | */ |
---|
837 | | - if (!efi_is_native() || efi_enabled(EFI_OLD_MEMMAP)) { |
---|
| 716 | + if (efi_is_mixed()) { |
---|
838 | 717 | efi_memmap_unmap(); |
---|
839 | 718 | clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); |
---|
840 | 719 | return; |
---|
.. | .. |
---|
850 | 729 | * Map efi regions which were passed via setup_data. The virt_addr is a |
---|
851 | 730 | * fixed addr which was used in first kernel of a kexec boot. |
---|
852 | 731 | */ |
---|
853 | | - for_each_efi_memory_desc(md) { |
---|
| 732 | + for_each_efi_memory_desc(md) |
---|
854 | 733 | efi_map_region_fixed(md); /* FIXME: add error handling */ |
---|
855 | | - get_systab_virt_addr(md); |
---|
856 | | - } |
---|
857 | 734 | |
---|
858 | 735 | /* |
---|
859 | 736 | * Unregister the early EFI memmap from efi_init() and install |
---|
.. | .. |
---|
868 | 745 | return; |
---|
869 | 746 | } |
---|
870 | 747 | |
---|
871 | | - BUG_ON(!efi.systab); |
---|
872 | | - |
---|
873 | 748 | num_pages = ALIGN(efi.memmap.nr_map * efi.memmap.desc_size, PAGE_SIZE); |
---|
874 | 749 | num_pages >>= PAGE_SHIFT; |
---|
875 | 750 | |
---|
.. | .. |
---|
879 | 754 | } |
---|
880 | 755 | |
---|
881 | 756 | efi_sync_low_kernel_mappings(); |
---|
882 | | - |
---|
883 | | - /* |
---|
884 | | - * Now that EFI is in virtual mode, update the function |
---|
885 | | - * pointers in the runtime service table to the new virtual addresses. |
---|
886 | | - * |
---|
887 | | - * Call EFI services through wrapper functions. |
---|
888 | | - */ |
---|
889 | | - efi.runtime_version = efi_systab.hdr.revision; |
---|
890 | | - |
---|
891 | 757 | efi_native_runtime_setup(); |
---|
892 | | - |
---|
893 | | - efi.set_virtual_address_map = NULL; |
---|
894 | | - |
---|
895 | | - if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX)) |
---|
896 | | - runtime_code_page_mkexec(); |
---|
897 | 758 | #endif |
---|
898 | 759 | } |
---|
899 | 760 | |
---|
.. | .. |
---|
902 | 763 | * Essentially, we look through the EFI memmap and map every region that |
---|
903 | 764 | * has the runtime attribute bit set in its memory descriptor into the |
---|
904 | 765 | * efi_pgd page table. |
---|
905 | | - * |
---|
906 | | - * The old method which used to update that memory descriptor with the |
---|
907 | | - * virtual address obtained from ioremap() is still supported when the |
---|
908 | | - * kernel is booted with efi=old_map on its command line. Same old |
---|
909 | | - * method enabled the runtime services to be called without having to |
---|
910 | | - * thunk back into physical mode for every invocation. |
---|
911 | 766 | * |
---|
912 | 767 | * The new method does a pagetable switch in a preemption-safe manner |
---|
913 | 768 | * so that we're in a different address space when calling a runtime |
---|
.. | .. |
---|
925 | 780 | void *new_memmap = NULL; |
---|
926 | 781 | efi_status_t status; |
---|
927 | 782 | unsigned long pa; |
---|
928 | | - |
---|
929 | | - efi.systab = NULL; |
---|
930 | 783 | |
---|
931 | 784 | if (efi_alloc_page_tables()) { |
---|
932 | 785 | pr_err("Failed to allocate EFI page tables\n"); |
---|
.. | .. |
---|
959 | 812 | efi_print_memmap(); |
---|
960 | 813 | } |
---|
961 | 814 | |
---|
962 | | - if (WARN_ON(!efi.systab)) |
---|
963 | | - goto err; |
---|
964 | | - |
---|
965 | 815 | if (efi_setup_page_tables(pa, 1 << pg_shift)) |
---|
966 | 816 | goto err; |
---|
967 | 817 | |
---|
968 | 818 | efi_sync_low_kernel_mappings(); |
---|
969 | 819 | |
---|
970 | | - if (efi_is_native()) { |
---|
971 | | - status = phys_efi_set_virtual_address_map( |
---|
972 | | - efi.memmap.desc_size * count, |
---|
973 | | - efi.memmap.desc_size, |
---|
974 | | - efi.memmap.desc_version, |
---|
975 | | - (efi_memory_desc_t *)pa); |
---|
976 | | - } else { |
---|
977 | | - status = efi_thunk_set_virtual_address_map( |
---|
978 | | - efi_phys.set_virtual_address_map, |
---|
979 | | - efi.memmap.desc_size * count, |
---|
980 | | - efi.memmap.desc_size, |
---|
981 | | - efi.memmap.desc_version, |
---|
982 | | - (efi_memory_desc_t *)pa); |
---|
983 | | - } |
---|
984 | | - |
---|
| 820 | + status = efi_set_virtual_address_map(efi.memmap.desc_size * count, |
---|
| 821 | + efi.memmap.desc_size, |
---|
| 822 | + efi.memmap.desc_version, |
---|
| 823 | + (efi_memory_desc_t *)pa, |
---|
| 824 | + efi_systab_phys); |
---|
985 | 825 | if (status != EFI_SUCCESS) { |
---|
986 | 826 | pr_err("Unable to switch EFI into virtual mode (status=%lx)!\n", |
---|
987 | 827 | status); |
---|
988 | 828 | goto err; |
---|
989 | 829 | } |
---|
990 | 830 | |
---|
991 | | - /* |
---|
992 | | - * Now that EFI is in virtual mode, update the function |
---|
993 | | - * pointers in the runtime service table to the new virtual addresses. |
---|
994 | | - * |
---|
995 | | - * Call EFI services through wrapper functions. |
---|
996 | | - */ |
---|
997 | | - efi.runtime_version = efi_systab.hdr.revision; |
---|
| 831 | + efi_check_for_embedded_firmwares(); |
---|
| 832 | + efi_free_boot_services(); |
---|
998 | 833 | |
---|
999 | | - if (efi_is_native()) |
---|
| 834 | + if (!efi_is_mixed()) |
---|
1000 | 835 | efi_native_runtime_setup(); |
---|
1001 | 836 | else |
---|
1002 | 837 | efi_thunk_runtime_setup(); |
---|
1003 | | - |
---|
1004 | | - efi.set_virtual_address_map = NULL; |
---|
1005 | 838 | |
---|
1006 | 839 | /* |
---|
1007 | 840 | * Apply more restrictive page table mapping attributes now that |
---|
.. | .. |
---|
1023 | 856 | if (efi_enabled(EFI_PARAVIRT)) |
---|
1024 | 857 | return; |
---|
1025 | 858 | |
---|
| 859 | + efi.runtime = (efi_runtime_services_t *)efi_runtime; |
---|
| 860 | + |
---|
1026 | 861 | if (efi_setup) |
---|
1027 | 862 | kexec_enter_virtual_mode(); |
---|
1028 | 863 | else |
---|
.. | .. |
---|
1031 | 866 | efi_dump_pagetable(); |
---|
1032 | 867 | } |
---|
1033 | 868 | |
---|
1034 | | -static int __init arch_parse_efi_cmdline(char *str) |
---|
| 869 | +bool efi_is_table_address(unsigned long phys_addr) |
---|
1035 | 870 | { |
---|
1036 | | - if (!str) { |
---|
1037 | | - pr_warn("need at least one option\n"); |
---|
1038 | | - return -EINVAL; |
---|
1039 | | - } |
---|
| 871 | + unsigned int i; |
---|
1040 | 872 | |
---|
1041 | | - if (parse_option_str(str, "old_map")) |
---|
1042 | | - set_bit(EFI_OLD_MEMMAP, &efi.flags); |
---|
| 873 | + if (phys_addr == EFI_INVALID_TABLE_ADDR) |
---|
| 874 | + return false; |
---|
1043 | 875 | |
---|
1044 | | - return 0; |
---|
| 876 | + for (i = 0; i < ARRAY_SIZE(efi_tables); i++) |
---|
| 877 | + if (*(efi_tables[i]) == phys_addr) |
---|
| 878 | + return true; |
---|
| 879 | + |
---|
| 880 | + return false; |
---|
1045 | 881 | } |
---|
1046 | | -early_param("efi", arch_parse_efi_cmdline); |
---|
| 882 | + |
---|
| 883 | +char *efi_systab_show_arch(char *str) |
---|
| 884 | +{ |
---|
| 885 | + if (uga_phys != EFI_INVALID_TABLE_ADDR) |
---|
| 886 | + str += sprintf(str, "UGA=0x%lx\n", uga_phys); |
---|
| 887 | + return str; |
---|
| 888 | +} |
---|
| 889 | + |
---|
| 890 | +#define EFI_FIELD(var) efi_ ## var |
---|
| 891 | + |
---|
| 892 | +#define EFI_ATTR_SHOW(name) \ |
---|
| 893 | +static ssize_t name##_show(struct kobject *kobj, \ |
---|
| 894 | + struct kobj_attribute *attr, char *buf) \ |
---|
| 895 | +{ \ |
---|
| 896 | + return sprintf(buf, "0x%lx\n", EFI_FIELD(name)); \ |
---|
| 897 | +} |
---|
| 898 | + |
---|
| 899 | +EFI_ATTR_SHOW(fw_vendor); |
---|
| 900 | +EFI_ATTR_SHOW(runtime); |
---|
| 901 | +EFI_ATTR_SHOW(config_table); |
---|
| 902 | + |
---|
| 903 | +struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor); |
---|
| 904 | +struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime); |
---|
| 905 | +struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table); |
---|
| 906 | + |
---|
| 907 | +umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) |
---|
| 908 | +{ |
---|
| 909 | + if (attr == &efi_attr_fw_vendor.attr) { |
---|
| 910 | + if (efi_enabled(EFI_PARAVIRT) || |
---|
| 911 | + efi_fw_vendor == EFI_INVALID_TABLE_ADDR) |
---|
| 912 | + return 0; |
---|
| 913 | + } else if (attr == &efi_attr_runtime.attr) { |
---|
| 914 | + if (efi_runtime == EFI_INVALID_TABLE_ADDR) |
---|
| 915 | + return 0; |
---|
| 916 | + } else if (attr == &efi_attr_config_table.attr) { |
---|
| 917 | + if (efi_config_table == EFI_INVALID_TABLE_ADDR) |
---|
| 918 | + return 0; |
---|
| 919 | + } |
---|
| 920 | + return attr->mode; |
---|
| 921 | +} |
---|