blob: 62f0260f5c174ef987daf822ce69348c54034bf6 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/* 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
8ENTRY(__efi_rt_asm_wrapper)
9 stp x29, x30, [sp, #-32]!
10 mov x29, sp
11
12 /*
13 * Register x18 is designated as the 'platform' register by the AAPCS,
14 * which means firmware running at the same exception level as the OS
15 * (such as UEFI) should never touch it.
16 */
17 stp x1, x18, [sp, #16]
18
19 /*
20 * We are lucky enough that no EFI runtime services take more than
21 * 5 arguments, so all are passed in registers rather than via the
22 * stack.
23 */
24 mov x8, x0
25 mov x0, x2
26 mov x1, x3
27 mov x2, x4
28 mov x3, x5
29 mov x4, x6
30 blr x8
31
32 ldp x1, x2, [sp, #16]
33 cmp x2, x18
34 ldp x29, x30, [sp], #32
35 b.ne 0f
36 ret
370:
38#ifdef CONFIG_SHADOW_CALL_STACK
39 /*
40 * Restore x18 before returning to instrumented code. This is
41 * safe because the wrapper is called with preemption disabled and
42 * a separate shadow stack is used for interrupts.
43 */
44 mov x18, x2
45#endif
46 b efi_handle_corrupted_x18 // tail call
47ENDPROC(__efi_rt_asm_wrapper)