mirror of
https://github.com/apache/nuttx.git
synced 2026-08-15 01:13:29 +00:00
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 <hujun5@xiaomi.com>
This commit is contained in:
parent
3d45550da9
commit
79b6d27018
1 changed files with 2 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue