~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/platform/efi/efi_thunk_64.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright (C) 2014 Intel Corporation; author Matt Fleming
  4  *
  5  * Support for invoking 32-bit EFI runtime services from a 64-bit
  6  * kernel.
  7  *
  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.
 14  *
 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()).
 20  */
 21 
 22 #include <linux/linkage.h>
 23 #include <linux/objtool.h>
 24 #include <asm/page_types.h>
 25 #include <asm/segment.h>
 26 
 27         .text
 28         .code64
 29 SYM_FUNC_START(__efi64_thunk)
 30 STACK_FRAME_NON_STANDARD __efi64_thunk
 31         push    %rbp
 32         push    %rbx
 33 
 34         /*
 35          * Switch to 1:1 mapped 32-bit stack pointer.
 36          */
 37         movq    %rsp, %rax
 38         movq    efi_mixed_mode_stack_pa(%rip), %rsp
 39         push    %rax
 40 
 41         /*
 42          * Copy args passed via the stack
 43          */
 44         subq    $0x24, %rsp
 45         movq    0x18(%rax), %rbp
 46         movq    0x20(%rax), %rbx
 47         movq    0x28(%rax), %rax
 48         movl    %ebp, 0x18(%rsp)
 49         movl    %ebx, 0x1c(%rsp)
 50         movl    %eax, 0x20(%rsp)
 51 
 52         /*
 53          * Calculate the physical address of the kernel text.
 54          */
 55         movq    $__START_KERNEL_map, %rax
 56         subq    phys_base(%rip), %rax
 57 
 58         leaq    1f(%rip), %rbp
 59         leaq    2f(%rip), %rbx
 60         subq    %rax, %rbp
 61         subq    %rax, %rbx
 62 
 63         movl    %ebx, 0x0(%rsp)         /* return address */
 64         movl    %esi, 0x4(%rsp)
 65         movl    %edx, 0x8(%rsp)
 66         movl    %ecx, 0xc(%rsp)
 67         movl    %r8d, 0x10(%rsp)
 68         movl    %r9d, 0x14(%rsp)
 69 
 70         /* Switch to 32-bit descriptor */
 71         pushq   $__KERNEL32_CS
 72         pushq   %rdi                    /* EFI runtime service address */
 73         lretq
 74 
 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.
 78         RET
 79 SYM_FUNC_END(__efi64_thunk)
 80 
 81         .section ".rodata", "a", @progbits
 82         .balign 16
 83 SYM_DATA_START(__efi64_thunk_ret_tramp)
 84 1:      movq    0x20(%rsp), %rsp
 85         pop     %rbx
 86         pop     %rbp
 87         ret
 88         int3
 89 
 90         .code32
 91 2:      pushl   $__KERNEL_CS
 92         pushl   %ebp
 93         lret
 94 SYM_DATA_END(__efi64_thunk_ret_tramp)
 95 
 96         .bss
 97         .balign 8
 98 SYM_DATA(efi_mixed_mode_stack_pa, .quad 0)

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php