1 // SPDX-License-Identifier: GPL-2.0
3 * x86_64 specific EFI support functions
4 * Based on Extensible Firmware Interface Specification version 1.0
6 * Copyright (C) 2005-2008 Intel Co.
7 * Fenghua Yu <fenghua.yu@intel.com>
8 * Bibo Mao <bibo.mao@intel.com>
9 * Chandramouli Narayanan <mouli@linux.intel.com>
10 * Huang Ying <ying.huang@intel.com>
12 * Code to convert EFI to E820 map has been implemented in elilo bootloader
13 * based on a EFI patch by Edgar Hucek. Based on the E820 map, the page table
14 * is setup appropriately for EFI runtime code.
19 #define pr_fmt(fmt) "efi: " fmt
21 #include <linux/kernel.h>
22 #include <linux/init.h>
24 #include <linux/types.h>
25 #include <linux/spinlock.h>
26 #include <linux/memblock.h>
27 #include <linux/ioport.h>
28 #include <linux/mc146818rtc.h>
29 #include <linux/efi.h>
30 #include <linux/export.h>
31 #include <linux/uaccess.h>
33 #include <linux/reboot.h>
34 #include <linux/slab.h>
35 #include <linux/ucs2_string.h>
36 #include <linux/cc_platform.h>
37 #include <linux/sched/task.h>
39 #include <asm/setup.h>
41 #include <asm/e820/api.h>
42 #include <asm/tlbflush.h>
43 #include <asm/proto.h>
45 #include <asm/cacheflush.h>
46 #include <asm/fixmap.h>
47 #include <asm/realmode.h>
49 #include <asm/pgalloc.h>
53 * We allocate runtime services regions top-down, starting from -4G, i.e.
54 * 0xffff_ffff_0000_0000 and limit EFI VA mapping space to 64G.
56 static u64 efi_va = EFI_VA_START;
57 static struct mm_struct *efi_prev_mm;
60 * We need our own copy of the higher levels of the page tables
61 * because we want to avoid inserting EFI region mappings (EFI_VA_END
62 * to EFI_VA_START) into the standard kernel page tables. Everything
63 * else can be shared, see efi_sync_low_kernel_mappings().
65 * We don't want the pgd on the pgd_list and cannot use pgd_alloc() for the
68 int __init efi_alloc_page_tables(void)
75 gfp_mask = GFP_KERNEL | __GFP_ZERO;
76 efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, PGD_ALLOCATION_ORDER);
80 pgd = efi_pgd + pgd_index(EFI_VA_END);
81 p4d = p4d_alloc(&init_mm, pgd, EFI_VA_END);
85 pud = pud_alloc(&init_mm, p4d, EFI_VA_END);
90 mm_init_cpumask(&efi_mm);
91 init_new_context(NULL, &efi_mm);
96 if (pgtable_l5_enabled())
97 free_page((unsigned long)pgd_page_vaddr(*pgd));
99 free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER);
105 * Add low kernel mappings for passing arguments to EFI functions.
107 void efi_sync_low_kernel_mappings(void)
109 unsigned num_entries;
110 pgd_t *pgd_k, *pgd_efi;
111 p4d_t *p4d_k, *p4d_efi;
112 pud_t *pud_k, *pud_efi;
113 pgd_t *efi_pgd = efi_mm.pgd;
115 pgd_efi = efi_pgd + pgd_index(PAGE_OFFSET);
116 pgd_k = pgd_offset_k(PAGE_OFFSET);
118 num_entries = pgd_index(EFI_VA_END) - pgd_index(PAGE_OFFSET);
119 memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries);
121 pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
122 pgd_k = pgd_offset_k(EFI_VA_END);
123 p4d_efi = p4d_offset(pgd_efi, 0);
124 p4d_k = p4d_offset(pgd_k, 0);
126 num_entries = p4d_index(EFI_VA_END);
127 memcpy(p4d_efi, p4d_k, sizeof(p4d_t) * num_entries);
130 * We share all the PUD entries apart from those that map the
131 * EFI regions. Copy around them.
133 BUILD_BUG_ON((EFI_VA_START & ~PUD_MASK) != 0);
134 BUILD_BUG_ON((EFI_VA_END & ~PUD_MASK) != 0);
136 p4d_efi = p4d_offset(pgd_efi, EFI_VA_END);
137 p4d_k = p4d_offset(pgd_k, EFI_VA_END);
138 pud_efi = pud_offset(p4d_efi, 0);
139 pud_k = pud_offset(p4d_k, 0);
141 num_entries = pud_index(EFI_VA_END);
142 memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
144 pud_efi = pud_offset(p4d_efi, EFI_VA_START);
145 pud_k = pud_offset(p4d_k, EFI_VA_START);
147 num_entries = PTRS_PER_PUD - pud_index(EFI_VA_START);
148 memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
152 * Wrapper for slow_virt_to_phys() that handles NULL addresses.
154 static inline phys_addr_t
155 virt_to_phys_or_null_size(void *va, unsigned long size)
162 if (virt_addr_valid(va))
163 return virt_to_phys(va);
165 pa = slow_virt_to_phys(va);
167 /* check if the object crosses a page boundary */
168 if (WARN_ON((pa ^ (pa + size - 1)) & PAGE_MASK))
174 #define virt_to_phys_or_null(addr) \
175 virt_to_phys_or_null_size((addr), sizeof(*(addr)))
177 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
179 extern const u8 __efi64_thunk_ret_tramp[];
180 unsigned long pfn, text, pf, rodata, tramp;
183 pgd_t *pgd = efi_mm.pgd;
186 * It can happen that the physical address of new_memmap lands in memory
187 * which is not mapped in the EFI page table. Therefore we need to go
188 * and ident-map those pages containing the map before calling
189 * phys_efi_set_virtual_address_map().
191 pfn = pa_memmap >> PAGE_SHIFT;
192 pf = _PAGE_NX | _PAGE_RW | _PAGE_ENC;
193 if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, pf)) {
194 pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap);
199 * Certain firmware versions are way too sentimental and still believe
200 * they are exclusive and unquestionable owners of the first physical page,
201 * even though they explicitly mark it as EFI_CONVENTIONAL_MEMORY
202 * (but then write-access it later during SetVirtualAddressMap()).
204 * Create a 1:1 mapping for this page, to avoid triple faults during early
205 * boot with such firmware. We are free to hand this page to the BIOS,
206 * as trim_bios_range() will reserve the first page and isolate it away
207 * from memory allocators anyway.
209 if (kernel_map_pages_in_pgd(pgd, 0x0, 0x0, 1, pf)) {
210 pr_err("Failed to create 1:1 mapping for the first page!\n");
215 * When SEV-ES is active, the GHCB as set by the kernel will be used
216 * by firmware. Create a 1:1 unencrypted mapping for each GHCB.
218 if (sev_es_efi_map_ghcbs(pgd)) {
219 pr_err("Failed to create 1:1 mapping for the GHCBs!\n");
224 * When making calls to the firmware everything needs to be 1:1
225 * mapped and addressable with 32-bit pointers. Map the kernel
226 * text and allocate a new stack because we can't rely on the
227 * stack pointer being < 4GB.
232 page = alloc_page(GFP_KERNEL|__GFP_DMA32);
234 pr_err("Unable to allocate EFI runtime stack < 4GB\n");
238 efi_mixed_mode_stack_pa = page_to_phys(page + 1); /* stack grows down */
240 npages = (_etext - _text) >> PAGE_SHIFT;
243 if (kernel_unmap_pages_in_pgd(pgd, text, npages)) {
244 pr_err("Failed to unmap kernel text 1:1 mapping\n");
248 npages = (__end_rodata - __start_rodata) >> PAGE_SHIFT;
249 rodata = __pa(__start_rodata);
250 pfn = rodata >> PAGE_SHIFT;
252 pf = _PAGE_NX | _PAGE_ENC;
253 if (kernel_map_pages_in_pgd(pgd, pfn, rodata, npages, pf)) {
254 pr_err("Failed to map kernel rodata 1:1\n");
258 tramp = __pa(__efi64_thunk_ret_tramp);
259 pfn = tramp >> PAGE_SHIFT;
262 if (kernel_map_pages_in_pgd(pgd, pfn, tramp, 1, pf)) {
263 pr_err("Failed to map mixed mode return trampoline\n");
270 static void __init __map_region(efi_memory_desc_t *md, u64 va)
272 unsigned long flags = _PAGE_RW;
274 pgd_t *pgd = efi_mm.pgd;
277 * EFI_RUNTIME_SERVICES_CODE regions typically cover PE/COFF
278 * executable images in memory that consist of both R-X and
279 * RW- sections, so we cannot apply read-only or non-exec
280 * permissions just yet. However, modern EFI systems provide
281 * a memory attributes table that describes those sections
282 * with the appropriate restricted permissions, which are
283 * applied in efi_runtime_update_mappings() below. All other
284 * regions can be mapped non-executable at this point, with
285 * the exception of boot services code regions, but those will
286 * be unmapped again entirely in efi_free_boot_services().
288 if (md->type != EFI_BOOT_SERVICES_CODE &&
289 md->type != EFI_RUNTIME_SERVICES_CODE)
292 if (!(md->attribute & EFI_MEMORY_WB))
295 if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT) &&
296 md->type != EFI_MEMORY_MAPPED_IO)
299 pfn = md->phys_addr >> PAGE_SHIFT;
300 if (kernel_map_pages_in_pgd(pgd, pfn, va, md->num_pages, flags))
301 pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n",
305 void __init efi_map_region(efi_memory_desc_t *md)
307 unsigned long size = md->num_pages << PAGE_SHIFT;
308 u64 pa = md->phys_addr;
311 * Make sure the 1:1 mappings are present as a catch-all for b0rked
312 * firmware which doesn't update all internal pointers after switching
313 * to virtual mode and would otherwise crap on us.
315 __map_region(md, md->phys_addr);
318 * Enforce the 1:1 mapping as the default virtual address when
319 * booting in EFI mixed mode, because even though we may be
320 * running a 64-bit kernel, the firmware may only be 32-bit.
322 if (efi_is_mixed()) {
323 md->virt_addr = md->phys_addr;
329 /* Is PA 2M-aligned? */
330 if (!(pa & (PMD_SIZE - 1))) {
333 u64 pa_offset = pa & (PMD_SIZE - 1);
334 u64 prev_va = efi_va;
336 /* get us the same offset within this 2M page */
337 efi_va = (efi_va & PMD_MASK) + pa_offset;
339 if (efi_va > prev_va)
343 if (efi_va < EFI_VA_END) {
344 pr_warn(FW_WARN "VA address range overflow!\n");
349 __map_region(md, efi_va);
350 md->virt_addr = efi_va;
354 * kexec kernel will use efi_map_region_fixed to map efi runtime memory ranges.
355 * md->virt_addr is the original virtual address which had been mapped in kexec
358 void __init efi_map_region_fixed(efi_memory_desc_t *md)
360 __map_region(md, md->phys_addr);
361 __map_region(md, md->virt_addr);
364 void __init parse_efi_setup(u64 phys_addr, u32 data_len)
366 efi_setup = phys_addr + sizeof(struct setup_data);
369 static int __init efi_update_mappings(efi_memory_desc_t *md, unsigned long pf)
372 pgd_t *pgd = efi_mm.pgd;
375 /* Update the 1:1 mapping */
376 pfn = md->phys_addr >> PAGE_SHIFT;
377 err1 = kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, md->num_pages, pf);
379 pr_err("Error while updating 1:1 mapping PA 0x%llx -> VA 0x%llx!\n",
380 md->phys_addr, md->virt_addr);
383 err2 = kernel_map_pages_in_pgd(pgd, pfn, md->virt_addr, md->num_pages, pf);
385 pr_err("Error while updating VA mapping PA 0x%llx -> VA 0x%llx!\n",
386 md->phys_addr, md->virt_addr);
392 static int __init efi_update_mem_attr(struct mm_struct *mm, efi_memory_desc_t *md)
394 unsigned long pf = 0;
396 if (md->attribute & EFI_MEMORY_XP)
399 if (!(md->attribute & EFI_MEMORY_RO))
402 if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
405 return efi_update_mappings(md, pf);
408 void __init efi_runtime_update_mappings(void)
410 efi_memory_desc_t *md;
413 * Use the EFI Memory Attribute Table for mapping permissions if it
414 * exists, since it is intended to supersede EFI_PROPERTIES_TABLE.
416 if (efi_enabled(EFI_MEM_ATTR)) {
417 efi_memattr_apply_permissions(NULL, efi_update_mem_attr);
422 * EFI_MEMORY_ATTRIBUTES_TABLE is intended to replace
423 * EFI_PROPERTIES_TABLE. So, use EFI_PROPERTIES_TABLE to update
424 * permissions only if EFI_MEMORY_ATTRIBUTES_TABLE is not
425 * published by the firmware. Even if we find a buggy implementation of
426 * EFI_MEMORY_ATTRIBUTES_TABLE, don't fall back to
427 * EFI_PROPERTIES_TABLE, because of the same reason.
430 if (!efi_enabled(EFI_NX_PE_DATA))
433 for_each_efi_memory_desc(md) {
434 unsigned long pf = 0;
436 if (!(md->attribute & EFI_MEMORY_RUNTIME))
439 if (!(md->attribute & EFI_MEMORY_WB))
442 if ((md->attribute & EFI_MEMORY_XP) ||
443 (md->type == EFI_RUNTIME_SERVICES_DATA))
446 if (!(md->attribute & EFI_MEMORY_RO) &&
447 (md->type != EFI_RUNTIME_SERVICES_CODE))
450 if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
453 efi_update_mappings(md, pf);
457 void __init efi_dump_pagetable(void)
459 #ifdef CONFIG_EFI_PGT_DUMP
460 ptdump_walk_pgd_level(NULL, &efi_mm);
465 * Makes the calling thread switch to/from efi_mm context. Can be used
466 * in a kernel thread and user context. Preemption needs to remain disabled
467 * while the EFI-mm is borrowed. mmgrab()/mmdrop() is not used because the mm
468 * can not change under us.
469 * It should be ensured that there are no concurrent calls to this function.
471 void efi_enter_mm(void)
473 efi_prev_mm = current->active_mm;
474 current->active_mm = &efi_mm;
475 switch_mm(efi_prev_mm, &efi_mm, NULL);
478 void efi_leave_mm(void)
480 current->active_mm = efi_prev_mm;
481 switch_mm(&efi_mm, efi_prev_mm, NULL);
484 static DEFINE_SPINLOCK(efi_runtime_lock);
487 * DS and ES contain user values. We need to save them.
488 * The 32-bit EFI code needs a valid DS, ES, and SS. There's no
489 * need to save the old SS: __KERNEL_DS is always acceptable.
491 #define __efi_thunk(func, ...) \
493 unsigned short __ds, __es; \
494 efi_status_t ____s; \
496 savesegment(ds, __ds); \
497 savesegment(es, __es); \
499 loadsegment(ss, __KERNEL_DS); \
500 loadsegment(ds, __KERNEL_DS); \
501 loadsegment(es, __KERNEL_DS); \
503 ____s = efi64_thunk(efi.runtime->mixed_mode.func, __VA_ARGS__); \
505 loadsegment(ds, __ds); \
506 loadsegment(es, __es); \
508 ____s ^= (____s & BIT(31)) | (____s & BIT_ULL(31)) << 32; \
513 * Switch to the EFI page tables early so that we can access the 1:1
514 * runtime services mappings which are not mapped in any other page
517 * Also, disable interrupts because the IDT points to 64-bit handlers,
518 * which aren't going to function correctly when we switch to 32-bit.
520 #define efi_thunk(func...) \
524 arch_efi_call_virt_setup(); \
526 __s = __efi_thunk(func); \
528 arch_efi_call_virt_teardown(); \
533 static efi_status_t __init __no_sanitize_address
534 efi_thunk_set_virtual_address_map(unsigned long memory_map_size,
535 unsigned long descriptor_size,
536 u32 descriptor_version,
537 efi_memory_desc_t *virtual_map)
542 efi_sync_low_kernel_mappings();
543 local_irq_save(flags);
547 status = __efi_thunk(set_virtual_address_map, memory_map_size,
548 descriptor_size, descriptor_version, virtual_map);
551 local_irq_restore(flags);
556 static efi_status_t efi_thunk_get_time(efi_time_t *tm, efi_time_cap_t *tc)
558 return EFI_UNSUPPORTED;
561 static efi_status_t efi_thunk_set_time(efi_time_t *tm)
563 return EFI_UNSUPPORTED;
567 efi_thunk_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
570 return EFI_UNSUPPORTED;
574 efi_thunk_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
576 return EFI_UNSUPPORTED;
579 static unsigned long efi_name_size(efi_char16_t *name)
581 return ucs2_strsize(name, EFI_VAR_NAME_LEN) + 1;
585 efi_thunk_get_variable(efi_char16_t *name, efi_guid_t *vendor,
586 u32 *attr, unsigned long *data_size, void *data)
588 u8 buf[24] __aligned(8);
589 efi_guid_t *vnd = PTR_ALIGN((efi_guid_t *)buf, sizeof(*vnd));
591 u32 phys_name, phys_vendor, phys_attr;
592 u32 phys_data_size, phys_data;
595 spin_lock_irqsave(&efi_runtime_lock, flags);
599 phys_data_size = virt_to_phys_or_null(data_size);
600 phys_vendor = virt_to_phys_or_null(vnd);
601 phys_name = virt_to_phys_or_null_size(name, efi_name_size(name));
602 phys_attr = virt_to_phys_or_null(attr);
603 phys_data = virt_to_phys_or_null_size(data, *data_size);
605 if (!phys_name || (data && !phys_data))
606 status = EFI_INVALID_PARAMETER;
608 status = efi_thunk(get_variable, phys_name, phys_vendor,
609 phys_attr, phys_data_size, phys_data);
611 spin_unlock_irqrestore(&efi_runtime_lock, flags);
617 efi_thunk_set_variable(efi_char16_t *name, efi_guid_t *vendor,
618 u32 attr, unsigned long data_size, void *data)
620 u8 buf[24] __aligned(8);
621 efi_guid_t *vnd = PTR_ALIGN((efi_guid_t *)buf, sizeof(*vnd));
622 u32 phys_name, phys_vendor, phys_data;
626 spin_lock_irqsave(&efi_runtime_lock, flags);
630 phys_name = virt_to_phys_or_null_size(name, efi_name_size(name));
631 phys_vendor = virt_to_phys_or_null(vnd);
632 phys_data = virt_to_phys_or_null_size(data, data_size);
634 if (!phys_name || (data && !phys_data))
635 status = EFI_INVALID_PARAMETER;
637 status = efi_thunk(set_variable, phys_name, phys_vendor,
638 attr, data_size, phys_data);
640 spin_unlock_irqrestore(&efi_runtime_lock, flags);
646 efi_thunk_set_variable_nonblocking(efi_char16_t *name, efi_guid_t *vendor,
647 u32 attr, unsigned long data_size,
650 u8 buf[24] __aligned(8);
651 efi_guid_t *vnd = PTR_ALIGN((efi_guid_t *)buf, sizeof(*vnd));
652 u32 phys_name, phys_vendor, phys_data;
656 if (!spin_trylock_irqsave(&efi_runtime_lock, flags))
657 return EFI_NOT_READY;
661 phys_name = virt_to_phys_or_null_size(name, efi_name_size(name));
662 phys_vendor = virt_to_phys_or_null(vnd);
663 phys_data = virt_to_phys_or_null_size(data, data_size);
665 if (!phys_name || (data && !phys_data))
666 status = EFI_INVALID_PARAMETER;
668 status = efi_thunk(set_variable, phys_name, phys_vendor,
669 attr, data_size, phys_data);
671 spin_unlock_irqrestore(&efi_runtime_lock, flags);
677 efi_thunk_get_next_variable(unsigned long *name_size,
681 u8 buf[24] __aligned(8);
682 efi_guid_t *vnd = PTR_ALIGN((efi_guid_t *)buf, sizeof(*vnd));
684 u32 phys_name_size, phys_name, phys_vendor;
687 spin_lock_irqsave(&efi_runtime_lock, flags);
691 phys_name_size = virt_to_phys_or_null(name_size);
692 phys_vendor = virt_to_phys_or_null(vnd);
693 phys_name = virt_to_phys_or_null_size(name, *name_size);
696 status = EFI_INVALID_PARAMETER;
698 status = efi_thunk(get_next_variable, phys_name_size,
699 phys_name, phys_vendor);
701 spin_unlock_irqrestore(&efi_runtime_lock, flags);
708 efi_thunk_get_next_high_mono_count(u32 *count)
710 return EFI_UNSUPPORTED;
714 efi_thunk_reset_system(int reset_type, efi_status_t status,
715 unsigned long data_size, efi_char16_t *data)
720 spin_lock_irqsave(&efi_runtime_lock, flags);
722 phys_data = virt_to_phys_or_null_size(data, data_size);
724 efi_thunk(reset_system, reset_type, status, data_size, phys_data);
726 spin_unlock_irqrestore(&efi_runtime_lock, flags);
730 efi_thunk_update_capsule(efi_capsule_header_t **capsules,
731 unsigned long count, unsigned long sg_list)
734 * To properly support this function we would need to repackage
735 * 'capsules' because the firmware doesn't understand 64-bit
738 return EFI_UNSUPPORTED;
742 efi_thunk_query_variable_info(u32 attr, u64 *storage_space,
743 u64 *remaining_space,
744 u64 *max_variable_size)
747 u32 phys_storage, phys_remaining, phys_max;
750 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
751 return EFI_UNSUPPORTED;
753 spin_lock_irqsave(&efi_runtime_lock, flags);
755 phys_storage = virt_to_phys_or_null(storage_space);
756 phys_remaining = virt_to_phys_or_null(remaining_space);
757 phys_max = virt_to_phys_or_null(max_variable_size);
759 status = efi_thunk(query_variable_info, attr, phys_storage,
760 phys_remaining, phys_max);
762 spin_unlock_irqrestore(&efi_runtime_lock, flags);
768 efi_thunk_query_variable_info_nonblocking(u32 attr, u64 *storage_space,
769 u64 *remaining_space,
770 u64 *max_variable_size)
773 u32 phys_storage, phys_remaining, phys_max;
776 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
777 return EFI_UNSUPPORTED;
779 if (!spin_trylock_irqsave(&efi_runtime_lock, flags))
780 return EFI_NOT_READY;
782 phys_storage = virt_to_phys_or_null(storage_space);
783 phys_remaining = virt_to_phys_or_null(remaining_space);
784 phys_max = virt_to_phys_or_null(max_variable_size);
786 status = efi_thunk(query_variable_info, attr, phys_storage,
787 phys_remaining, phys_max);
789 spin_unlock_irqrestore(&efi_runtime_lock, flags);
795 efi_thunk_query_capsule_caps(efi_capsule_header_t **capsules,
796 unsigned long count, u64 *max_size,
800 * To properly support this function we would need to repackage
801 * 'capsules' because the firmware doesn't understand 64-bit
804 return EFI_UNSUPPORTED;
807 void __init efi_thunk_runtime_setup(void)
809 if (!IS_ENABLED(CONFIG_EFI_MIXED))
812 efi.get_time = efi_thunk_get_time;
813 efi.set_time = efi_thunk_set_time;
814 efi.get_wakeup_time = efi_thunk_get_wakeup_time;
815 efi.set_wakeup_time = efi_thunk_set_wakeup_time;
816 efi.get_variable = efi_thunk_get_variable;
817 efi.get_next_variable = efi_thunk_get_next_variable;
818 efi.set_variable = efi_thunk_set_variable;
819 efi.set_variable_nonblocking = efi_thunk_set_variable_nonblocking;
820 efi.get_next_high_mono_count = efi_thunk_get_next_high_mono_count;
821 efi.reset_system = efi_thunk_reset_system;
822 efi.query_variable_info = efi_thunk_query_variable_info;
823 efi.query_variable_info_nonblocking = efi_thunk_query_variable_info_nonblocking;
824 efi.update_capsule = efi_thunk_update_capsule;
825 efi.query_capsule_caps = efi_thunk_query_capsule_caps;
828 efi_status_t __init __no_sanitize_address
829 efi_set_virtual_address_map(unsigned long memory_map_size,
830 unsigned long descriptor_size,
831 u32 descriptor_version,
832 efi_memory_desc_t *virtual_map,
833 unsigned long systab_phys)
835 const efi_system_table_t *systab = (efi_system_table_t *)systab_phys;
840 return efi_thunk_set_virtual_address_map(memory_map_size,
848 /* Disable interrupts around EFI calls: */
849 local_irq_save(flags);
850 status = arch_efi_call_virt(efi.runtime, set_virtual_address_map,
851 memory_map_size, descriptor_size,
852 descriptor_version, virtual_map);
853 local_irq_restore(flags);
857 /* grab the virtually remapped EFI runtime services table pointer */
858 efi.runtime = READ_ONCE(systab->runtime);