[lwp][rv64] riscv: fix potential signal handler infinite loop

This commit is contained in:
Yulong Wang 2025-07-13 04:04:20 +00:00 committed by Rbb666
parent e7a40ae6ec
commit ee1fe2024e
1 changed files with 12 additions and 2 deletions

View File

@ -75,12 +75,20 @@ arch_crt_start_umode:
* we handle following things here:
* 1. restoring user mode debug state (not support yet)
* 2. handling thread's exit request
* 3. handling POSIX signal
* 3. handling POSIX signal (skipped for signal quit path)
* 4. restoring user context
* 5. jump to user mode
*/
.global arch_ret_to_user
arch_ret_to_user:
li s0, 1 // flag=1 (normal path)
j arch_ret_to_user_impl
.global arch_signal_quit_ret_to_user
arch_signal_quit_ret_to_user:
li s0, 0 // flag=0 (signal quit path)
arch_ret_to_user_impl:
// TODO: we don't support kernel gdb server in risc-v yet
// so we don't check debug state here and handle debugging bussiness
@ -90,6 +98,8 @@ arch_ret_to_user:
call sys_exit
1:
// Skip signal handling if coming from arch_signal_quit
beqz s0, ret_to_user_exit
mv a0, sp
call lwp_thread_signal_catch
@ -119,7 +129,7 @@ arch_signal_quit:
RESTORE_ALL
SAVE_ALL
j arch_ret_to_user
j arch_signal_quit_ret_to_user
/**
* rt_noreturn