Skip to content

Commit d3943ea

Browse files
hongquan-progteburd
authored andcommitted
arch: arm64: fix a4 result corruption
The SMCCC macro in arch/arm64/core/smccc-call.S used x4 to load the result pointer from the stack after the smc/hvc instruction. However, per the SMCCC calling convention x4 holds the returned a4 value at that point, so loading the pointer overwrote the real return value and res->a4 ended up containing the result pointer itself. Use x9 as the temporary register for the result pointer so that x4 is preserved until it is stored into res->a4. Fixes zephyrproject-rtos#113379 Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
1 parent 9f8f966 commit d3943ea

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

arch/arm64/core/smccc-call.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
.macro SMCCC instr
2020
\instr #0
21-
ldr x4, [sp]
22-
stp x0, x1, [x4, __arm_smccc_res_t_a0_a1_OFFSET]
23-
stp x2, x3, [x4, __arm_smccc_res_t_a2_a3_OFFSET]
24-
stp x4, x5, [x4, __arm_smccc_res_t_a4_a5_OFFSET]
25-
stp x6, x7, [x4, __arm_smccc_res_t_a6_a7_OFFSET]
21+
ldr x9, [sp]
22+
stp x0, x1, [x9, __arm_smccc_res_t_a0_a1_OFFSET]
23+
stp x2, x3, [x9, __arm_smccc_res_t_a2_a3_OFFSET]
24+
stp x4, x5, [x9, __arm_smccc_res_t_a4_a5_OFFSET]
25+
stp x6, x7, [x9, __arm_smccc_res_t_a6_a7_OFFSET]
2626
ret
2727
.endm
2828

0 commit comments

Comments
 (0)