Skip to content

Commit 93917ad

Browse files
VincentZWCpalmer-dabbelt
authored andcommitted
RISC-V: Add support for restartable sequence
Add calls to rseq_signal_deliver() and rseq_syscall() to introduce RSEQ support. 1. Call the rseq_signal_deliver() function to fixup on the pre-signal frame when a signal is delivered on top of a restartable sequence critical section. 2. Check that system calls are not invoked from within rseq critical sections by invoking rseq_signal() from ret_from_syscall(). With CONFIG_DEBUG_RSEQ, such behavior results in termination of the process with SIGSEGV. Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent e783362 commit 93917ad

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ config RISCV
101101
select HAVE_FUNCTION_ARG_ACCESS_API
102102
select HAVE_STACKPROTECTOR
103103
select HAVE_SYSCALL_TRACEPOINTS
104+
select HAVE_RSEQ
104105
select IRQ_DOMAIN
105106
select IRQ_FORCED_THREADING
106107
select MODULES_USE_ELF_RELA if MODULES

arch/riscv/kernel/entry.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ ret_from_syscall:
225225
* (If it was configured with SECCOMP_RET_ERRNO/TRACE)
226226
*/
227227
ret_from_syscall_rejected:
228+
#ifdef CONFIG_DEBUG_RSEQ
229+
move a0, sp
230+
call rseq_syscall
231+
#endif
228232
/* Trace syscalls, but only if requested by the user. */
229233
REG_L t0, TASK_TI_FLAGS(tp)
230234
andi t0, t0, _TIF_SYSCALL_WORK

arch/riscv/kernel/signal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
258258
}
259259
}
260260

261+
rseq_signal_deliver(ksig, regs);
262+
261263
/* Set up the stack frame */
262264
ret = setup_rt_frame(ksig, oldset, regs);
263265

0 commit comments

Comments
 (0)