File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
components/lwp/arch/risc-v/rv64 Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,29 @@ ret_to_user_exit:
9898 // `RESTORE_ALL` also reset sp to user sp, and setup sscratch
9999 sret
100100
101+ /**
102+ * Signal cleanup exit path - returns to user mode without checking pending signals.
103+ *
104+ * This is called after signal handler completion (via arch_signal_quit) to restore
105+ * user context. We intentionally skip pending signal checks here to prevent:
106+ * 1. Signal handler recursion (e.g. if handler uses sys_tkill to send itself signals)
107+ *
108+ * The primary purpose is to break potential infinite loops where a signal handler
109+ * keeps triggering new signals. Normal signal delivery will resume on the next
110+ * kernel-to-userspace transition.
111+ */
112+ .global arch_signal_quit_to_user
113+ arch_signal_quit_to_user:
114+ call lwp_check_exit_request
115+ beqz a0, 1f
116+ mv a0, x0
117+ call sys_exit
118+
119+ 1:
120+ mv a0, sp
121+ RESTORE_ALL
122+ sret
123+
101124/**
102125 * Restore user context from exception frame stroraged in ustack
103126 * And handle pending signals;
@@ -119,7 +142,7 @@ arch_signal_quit:
119142
120143 RESTORE_ALL
121144 SAVE_ALL
122- j arch_ret_to_user
145+ j arch_signal_quit_to_user
123146
124147/**
125148 * rt_noreturn
You can’t perform that action at this time.
0 commit comments