This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 79b6d270182 arm64: fix SP_EL0 register handling in syscall return path
79b6d270182 is described below
commit 79b6d270182b5fbb787b2be3fab044dc53e4b815
Author: hujun5 <[email protected]>
AuthorDate: Sun Apr 27 12:08:42 2025 +0800
arm64: fix SP_EL0 register handling in syscall return path
Use regs[REG_SP_EL0] from register context instead of direct sp_el0 system
register read/write operations in arm64_syscall(). Replace
read_sysreg(sp_el0)
with regs[REG_SP_EL0] and write_sysreg(usp, sp_el0) with direct assignment
to
regs[REG_SP_EL0]. Ensures userspace stack pointer is correctly maintained
from
register context during signal delivery, preventing userspace SP corruption
on
syscall return.
Signed-off-by: hujun5 <[email protected]>
---
arch/arm64/src/common/arm64_syscall.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/src/common/arm64_syscall.c
b/arch/arm64/src/common/arm64_syscall.c
index 6e837df1c23..ab1a67f4660 100644
--- a/arch/arm64/src/common/arm64_syscall.c
+++ b/arch/arm64/src/common/arm64_syscall.c
@@ -269,13 +269,13 @@ uint64_t *arm64_syscall(uint64_t *regs)
/* Create a frame for info and copy the kernel info */
- rtcb->xcp.ustkptr = (uintptr_t *)read_sysreg(sp_el0);
+ rtcb->xcp.ustkptr = (uintptr_t *)regs[REG_SP_EL0];
usp = (uintptr_t)rtcb->xcp.ustkptr - sizeof(siginfo_t);
memcpy((void *)usp, (void *)regs[REG_X2], sizeof(siginfo_t));
/* Now set the updated SP and user copy of "info" to R2 */
- write_sysreg(usp, sp_el0);
+ regs[REG_SP_EL0] = usp;
regs[REG_X2] = usp;
}
#endif