[rv]修正signal退出后用户态sp少8的问题 (#9080)

This commit is contained in:
heyuanjie87 2024-06-24 21:36:32 +08:00 committed by GitHub
parent 5e04d8b3c1
commit a5a89c439f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 3 deletions

View File

@ -107,6 +107,7 @@ arch_signal_quit:
call arch_signal_ucontext_restore call arch_signal_ucontext_restore
/* reset kernel sp to the stack */ /* reset kernel sp to the stack */
addi sp, sp, CTX_REG_NR * REGBYTES
STORE sp, FRAME_OFF_SP(a0) STORE sp, FRAME_OFF_SP(a0)
/* return value is user sp */ /* return value is user sp */
mv sp, a0 mv sp, a0
@ -280,7 +281,7 @@ arch_syscall_exit:
CLOSE_INTERRUPT CLOSE_INTERRUPT
#if defined(ARCH_MM_MMU) #if defined(ARCH_MM_MMU)
LOAD s0, 2 * REGBYTES(sp) LOAD s0, FRAME_OFF_SSTATUS(sp)
andi s0, s0, 0x100 andi s0, s0, 0x100
bnez s0, dont_ret_to_user bnez s0, dont_ret_to_user
j arch_ret_to_user j arch_ret_to_user

View File

@ -44,9 +44,11 @@
li s10, (SSTATUS_SPP) li s10, (SSTATUS_SPP)
or s11, s11, s10 or s11, s11, s10
PUSH_8 s11 PUSH_8 s11
addi sp, sp, -8
.endm .endm
.macro RESTORE_CONTEXT .macro RESTORE_CONTEXT
addi sp, sp, 8
POP_8 s11 POP_8 s11
csrw sstatus, s11 csrw sstatus, s11
POP_8 s11 POP_8 s11

View File

@ -52,6 +52,7 @@ void *_rt_hw_stack_init(rt_ubase_t *sp, rt_ubase_t ra, rt_ubase_t sstatus)
(*--sp) = 0; /* s10 */ (*--sp) = 0; /* s10 */
(*--sp) = 0; /* s11 */ (*--sp) = 0; /* s11 */
(*--sp) = sstatus; /* sstatus */ (*--sp) = sstatus; /* sstatus */
--sp; /* align to 16bytes */
return (void *)sp; return (void *)sp;
} }

View File

@ -23,8 +23,8 @@
#error "Not supported XLEN" #error "Not supported XLEN"
#endif #endif
/* 33 general register */ /* 33 general register + 1 padding */
#define CTX_GENERAL_REG_NR 33 #define CTX_GENERAL_REG_NR 34
#ifdef ENABLE_FPU #ifdef ENABLE_FPU
/* 32 fpu register */ /* 32 fpu register */

View File

@ -47,6 +47,7 @@ struct rt_hw_stack_frame
rt_ubase_t t5; /* x30 - t5 - temporary register 5 */ rt_ubase_t t5; /* x30 - t5 - temporary register 5 */
rt_ubase_t t6; /* x31 - t6 - temporary register 6 */ rt_ubase_t t6; /* x31 - t6 - temporary register 6 */
rt_ubase_t user_sp_exc_stack; /* sscratch - user mode sp/exception stack */ rt_ubase_t user_sp_exc_stack; /* sscratch - user mode sp/exception stack */
rt_ubase_t __padding; /* align to 16bytes */
#ifdef ENABLE_FPU #ifdef ENABLE_FPU
rt_ubase_t f[CTX_FPU_REG_NR]; /* f0~f31 */ rt_ubase_t f[CTX_FPU_REG_NR]; /* f0~f31 */
#endif #endif