]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmSvcLib/Arm/ArmSvc.S
ArmPkg/ArmSvcLib: prevent speculative execution beyond svc
[mirror_edk2.git] / ArmPkg / Library / ArmSvcLib / Arm / ArmSvc.S
1 //
2 // Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause-Patent
5 //
6 //
7
8 .text
9 .align 3
10
11 GCC_ASM_EXPORT(ArmCallSvc)
12
13 ASM_PFX(ArmCallSvc):
14 // r0 will be popped just after the SVC call
15 push {r0, r4-r8}
16
17 // Load the SVC arguments values into the appropriate registers
18 ldm r0, {r0-r7}
19
20 svc #0
21 // Prevent speculative execution beyond svc instruction
22 dsb nsh
23 isb
24
25 // Load the ARM_SVC_ARGS structure address from the stack into r8
26 ldr r8, [sp]
27
28 // Load the SVC returned values into the appropriate registers
29 // A SVC call can return up to 4 values - we do not need to store back r4-r7.
30 stm r8, {r0-r3}
31
32 mov r0, r8
33
34 // Restore the registers r4-r8
35 pop {r1, r4-r8}
36 bx lr