summaryrefslogtreecommitdiff
path: root/components/lwp/arch
diff options
context:
space:
mode:
authorShell <[email protected]>2023-02-24 14:52:16 +0800
committerGitHub <[email protected]>2023-02-24 14:52:16 +0800
commit382e9bcac746b408b5b01ea2f59338428ab203dd (patch)
tree448e8692183ad031b57afda6681aaa93caa56df9 /components/lwp/arch
parent08c2a651360899ca59e90433dfb78579a642fd75 (diff)
[rt-smart] handling kernel from accessing unmapped user stack (#6957)
[rt-smart] handling kernel from accessing unmapped user stack
Diffstat (limited to 'components/lwp/arch')
-rw-r--r--components/lwp/arch/risc-v/rv64/lwp_gcc.S10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/lwp/arch/risc-v/rv64/lwp_gcc.S b/components/lwp/arch/risc-v/rv64/lwp_gcc.S
index c54726bc45..3977553dbf 100644
--- a/components/lwp/arch/risc-v/rv64/lwp_gcc.S
+++ b/components/lwp/arch/risc-v/rv64/lwp_gcc.S
@@ -121,6 +121,16 @@ arch_signal_quit:
* routine in user stack
*/
user_do_signal:
+ /* prefetch ustack to avoid corrupted status in RESTORE/STORE pair below */
+ LOAD t0, FRAME_OFF_SP(sp)
+ addi t1, t0, -CTX_REG_NR * REGBYTES
+ LOAD t2, (t0)
+ li t3, -0x1000
+1:
+ add t0, t0, t3
+ LOAD t2, (t0)
+ bgt t0, t1, 1b
+
/** restore and backup kernel sp carefully to avoid leaking */
addi t0, sp, CTX_REG_NR * REGBYTES
csrw sscratch, t0