1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
6 #include <linux/linkage.h>
7 #include <asm/assembler.h>
9 SYM_FUNC_START(__efi_rt_asm_wrapper)
10 stp x29, x30, [sp, #-32]!
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.
18 stp x1, x18, [sp, #16]
20 ldr_l x16, efi_rt_stack_top
22 #ifdef CONFIG_SHADOW_CALL_STACK
27 * We are lucky enough that no EFI runtime services take more than
28 * 5 arguments, so all are passed in registers rather than via the
42 ldp x29, x30, [sp], #32
47 * With CONFIG_SHADOW_CALL_STACK, the kernel uses x18 to store a
48 * shadow stack pointer, which we need to restore before returning to
49 * potentially instrumented code. This is safe because the wrapper is
50 * called with preemption disabled and a separate shadow stack is used
53 #ifdef CONFIG_SHADOW_CALL_STACK
54 ldr_l x18, efi_rt_stack_top
58 b efi_handle_corrupted_x18 // tail call
59 SYM_FUNC_END(__efi_rt_asm_wrapper)