Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
0004  */
0005 
0006 #include <linux/linkage.h>
0007 
0008 SYM_FUNC_START(__efi_rt_asm_wrapper)
0009     stp x29, x30, [sp, #-32]!
0010     mov x29, sp
0011 
0012     /*
0013      * Register x18 is designated as the 'platform' register by the AAPCS,
0014      * which means firmware running at the same exception level as the OS
0015      * (such as UEFI) should never touch it.
0016      */
0017     stp x1, x18, [sp, #16]
0018 
0019     /*
0020      * We are lucky enough that no EFI runtime services take more than
0021      * 5 arguments, so all are passed in registers rather than via the
0022      * stack.
0023      */
0024     mov x8, x0
0025     mov x0, x2
0026     mov x1, x3
0027     mov x2, x4
0028     mov x3, x5
0029     mov x4, x6
0030     blr x8
0031 
0032     ldp x1, x2, [sp, #16]
0033     cmp x2, x18
0034     ldp x29, x30, [sp], #32
0035     b.ne    0f
0036     ret
0037 0:
0038     /*
0039      * With CONFIG_SHADOW_CALL_STACK, the kernel uses x18 to store a
0040      * shadow stack pointer, which we need to restore before returning to
0041      * potentially instrumented code. This is safe because the wrapper is
0042      * called with preemption disabled and a separate shadow stack is used
0043      * for interrupts.
0044      */
0045     mov x18, x2
0046     b   efi_handle_corrupted_x18    // tail call
0047 SYM_FUNC_END(__efi_rt_asm_wrapper)