Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/lwp/arch/risc-v/rv64/lwp_gcc.S
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ arch_signal_quit:
call arch_signal_ucontext_restore

/* reset kernel sp to the stack */
addi sp, sp, CTX_REG_NR * REGBYTES
STORE sp, FRAME_OFF_SP(a0)
/* return value is user sp */
mv sp, a0
Expand Down Expand Up @@ -280,7 +281,7 @@ arch_syscall_exit:
CLOSE_INTERRUPT

#if defined(ARCH_MM_MMU)
LOAD s0, 2 * REGBYTES(sp)
LOAD s0, FRAME_OFF_SSTATUS(sp)
andi s0, s0, 0x100
bnez s0, dont_ret_to_user
j arch_ret_to_user
Expand Down
2 changes: 2 additions & 0 deletions libcpu/risc-v/virt64/context_gcc.S
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
li s10, (SSTATUS_SPP)
or s11, s11, s10
PUSH_8 s11
addi sp, sp, -8
.endm

.macro RESTORE_CONTEXT
addi sp, sp, 8
POP_8 s11
csrw sstatus, s11
POP_8 s11
Expand Down
1 change: 1 addition & 0 deletions libcpu/risc-v/virt64/cpuport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; /* s11 */
(*--sp) = sstatus; /* sstatus */
--sp; /* align to 16bytes */

return (void *)sp;
}
Expand Down
4 changes: 2 additions & 2 deletions libcpu/risc-v/virt64/cpuport.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#error "Not supported XLEN"
#endif

/* 33 general register */
#define CTX_GENERAL_REG_NR 33
/* 33 general register + 1 padding */
#define CTX_GENERAL_REG_NR 34

#ifdef ENABLE_FPU
/* 32 fpu register */
Expand Down
1 change: 1 addition & 0 deletions libcpu/risc-v/virt64/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct rt_hw_stack_frame
rt_ubase_t t5; /* x30 - t5 - temporary register 5 */
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 __padding; /* align to 16bytes */
#ifdef ENABLE_FPU
rt_ubase_t f[CTX_FPU_REG_NR]; /* f0~f31 */
#endif
Expand Down
Loading