^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) SYM_FUNC_START(__efi_rt_asm_wrapper)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) stp x29, x30, [sp, #-32]!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) mov x29, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Register x18 is designated as the 'platform' register by the AAPCS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * which means firmware running at the same exception level as the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * (such as UEFI) should never touch it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) stp x1, x18, [sp, #16]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * We are lucky enough that no EFI runtime services take more than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * 5 arguments, so all are passed in registers rather than via the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) mov x8, x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) mov x0, x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) mov x1, x3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) mov x2, x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) mov x3, x5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) mov x4, x6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) blr x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ldp x1, x2, [sp, #16]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) cmp x2, x18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ldp x29, x30, [sp], #32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) b.ne 0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * With CONFIG_SHADOW_CALL_STACK, the kernel uses x18 to store a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * shadow stack pointer, which we need to restore before returning to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * potentially instrumented code. This is safe because the wrapper is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * called with preemption disabled and a separate shadow stack is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * for interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) mov x18, x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) b efi_handle_corrupted_x18 // tail call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) SYM_FUNC_END(__efi_rt_asm_wrapper)