1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2014 Intel Corporation; author Matt Fleming
5 * Support for invoking 32-bit EFI runtime services from a 64-bit
8 * The below thunking functions are only used after ExitBootServices()
9 * has been called. This simplifies things considerably as compared with
10 * the early EFI thunking because we can leave all the kernel state
11 * intact (GDT, IDT, etc) and simply invoke the 32-bit EFI runtime
12 * services from __KERNEL32_CS. This means we can continue to service
13 * interrupts across an EFI mixed mode call.
15 * We do however, need to handle the fact that we're running in a full
16 * 64-bit virtual address space. Things like the stack and instruction
17 * addresses need to be accessible by the 32-bit firmware, so we rely on
18 * using the identity mappings in the EFI page table to access the stack
19 * and kernel text (see efi_setup_page_tables()).
22 #include <linux/linkage.h>
23 #include <linux/objtool.h>
24 #include <asm/page_types.h>
25 #include <asm/segment.h>
29 SYM_FUNC_START(__efi64_thunk)
30 STACK_FRAME_NON_STANDARD __efi64_thunk
35 * Switch to 1:1 mapped 32-bit stack pointer.
38 movq efi_mixed_mode_stack_pa(%rip), %rsp
42 * Copy args passed via the stack
53 * Calculate the physical address of the kernel text.
55 movq $__START_KERNEL_map, %rax
56 subq phys_base(%rip), %rax
63 movl %ebx, 0x0(%rsp) /* return address */
70 /* Switch to 32-bit descriptor */
72 pushq %rdi /* EFI runtime service address */
75 // This return instruction is not needed for correctness, as it will
76 // never be reached. It only exists to make objtool happy, which will
77 // otherwise complain about unreachable instructions in the callers.
79 SYM_FUNC_END(__efi64_thunk)
81 .section ".rodata", "a", @progbits
83 SYM_DATA_START(__efi64_thunk_ret_tramp)
84 1: movq 0x20(%rsp), %rsp
94 SYM_DATA_END(__efi64_thunk_ret_tramp)
98 SYM_DATA(efi_mixed_mode_stack_pa, .quad 0)