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

TOMOYO Linux Cross Reference
Linux/arch/arm64/kernel/efi-rt-wrapper.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-only */
  2 /*
  3  * Copyright (C) 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
  4  */
  5 
  6 #include <linux/linkage.h>
  7 #include <asm/assembler.h>
  8 
  9 SYM_FUNC_START(__efi_rt_asm_wrapper)
 10         stp     x29, x30, [sp, #-112]!
 11         mov     x29, sp
 12 
 13         /*
 14          * Register x18 is designated as the 'platform' register by the AAPCS,
 15          * which means firmware running at the same exception level as the OS
 16          * (such as UEFI) should never touch it.
 17          */
 18         stp     x1, x18, [sp, #16]
 19 
 20         /*
 21          * Preserve all callee saved registers and preserve the stack pointer
 22          * value at the base of the EFI runtime stack so we can recover from
 23          * synchronous exceptions occurring while executing the firmware
 24          * routines.
 25          */
 26         stp     x19, x20, [sp, #32]
 27         stp     x21, x22, [sp, #48]
 28         stp     x23, x24, [sp, #64]
 29         stp     x25, x26, [sp, #80]
 30         stp     x27, x28, [sp, #96]
 31 
 32         ldr_l   x16, efi_rt_stack_top
 33         mov     sp, x16
 34         stp     x18, x29, [sp, #-16]!
 35 
 36         /*
 37          * We are lucky enough that no EFI runtime services take more than
 38          * 5 arguments, so all are passed in registers rather than via the
 39          * stack.
 40          */
 41         mov     x8, x0
 42         mov     x0, x2
 43         mov     x1, x3
 44         mov     x2, x4
 45         mov     x3, x5
 46         mov     x4, x6
 47         blr     x8
 48 
 49         mov     x16, sp
 50         mov     sp, x29
 51         str     xzr, [x16, #8]                  // clear recorded task SP value
 52 
 53         ldp     x1, x2, [sp, #16]
 54         cmp     x2, x18
 55         ldp     x29, x30, [sp], #112
 56         b.ne    0f
 57         ret
 58 0:
 59         /*
 60          * With CONFIG_SHADOW_CALL_STACK, the kernel uses x18 to store a
 61          * shadow stack pointer, which we need to restore before returning to
 62          * potentially instrumented code. This is safe because the wrapper is
 63          * called with preemption disabled and a separate shadow stack is used
 64          * for interrupts.
 65          */
 66 #ifdef CONFIG_SHADOW_CALL_STACK
 67         ldr_l   x18, efi_rt_stack_top
 68         ldr     x18, [x18, #-16]
 69 #endif
 70 
 71         b       efi_handle_corrupted_x18        // tail call
 72 SYM_FUNC_END(__efi_rt_asm_wrapper)
 73 
 74 SYM_CODE_START(__efi_rt_asm_recover)
 75         mov     sp, x30
 76 
 77         ldr_l   x16, efi_rt_stack_top           // clear recorded task SP value
 78         str     xzr, [x16, #-8]
 79 
 80         ldp     x19, x20, [sp, #32]
 81         ldp     x21, x22, [sp, #48]
 82         ldp     x23, x24, [sp, #64]
 83         ldp     x25, x26, [sp, #80]
 84         ldp     x27, x28, [sp, #96]
 85         ldp     x29, x30, [sp], #112
 86         ret
 87 SYM_CODE_END(__efi_rt_asm_recover)

~ [ 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