Commit 7a64f3f1 authored by Guo Ren's avatar Guo Ren Committed by Palmer Dabbelt

riscv/signal: Fixup additional syscall restarting

The function of do_notify_resume called by entry.S could be entered
in loop when SIGPENDING was setted again before sret. So we must add
prevent code to make syscall restart (regs->sepc -= 0x4) or it may
re-execute unexpected instructions.

Just like in_syscall & forget_syscall used by arm.
Signed-off-by: default avatarGuo Ren <ren_guo@c-sky.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarPalmer Dabbelt <palmer@sifive.com>
parent 085b7755
...@@ -234,6 +234,9 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) ...@@ -234,6 +234,9 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
/* Are we from a system call? */ /* Are we from a system call? */
if (regs->scause == EXC_SYSCALL) { if (regs->scause == EXC_SYSCALL) {
/* Avoid additional syscall restarting via ret_from_exception */
regs->scause = -1UL;
/* If so, check system call restarting.. */ /* If so, check system call restarting.. */
switch (regs->a0) { switch (regs->a0) {
case -ERESTART_RESTARTBLOCK: case -ERESTART_RESTARTBLOCK:
...@@ -272,6 +275,9 @@ static void do_signal(struct pt_regs *regs) ...@@ -272,6 +275,9 @@ static void do_signal(struct pt_regs *regs)
/* Did we come from a system call? */ /* Did we come from a system call? */
if (regs->scause == EXC_SYSCALL) { if (regs->scause == EXC_SYSCALL) {
/* Avoid additional syscall restarting via ret_from_exception */
regs->scause = -1UL;
/* Restart the system call - no handlers present */ /* Restart the system call - no handlers present */
switch (regs->a0) { switch (regs->a0) {
case -ERESTARTNOHAND: case -ERESTARTNOHAND:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment