Skip to content

Commit

Permalink
openrisc: restore all regs on rt_sigreturn
Browse files Browse the repository at this point in the history
Fix signal handling for when signals are handled as the result of timers
or exceptions, previous code assumed syscalls. This was noticeable with X
crashing where it uses SIGALRM.

This patch restores all regs before returning to userspace via
_resume_userspace instead of via syscall return path.

The rt_sigreturn syscall is more like a context switch than a function
call; it entails a return from one context (the signal handler) to another
(the process in question).  For a context switch like this there are
effectively no call-saved regs that remain constant across the transition.

Reported-by: Sebastian Macke <[email protected]>
Signed-off-by: Jonas Bonn <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
[[email protected]: Updated comment better reflect change and issue]
Signed-off-by: Stafford Horne <[email protected]>
  • Loading branch information
Jonas Bonn authored and stffrdhrn committed Dec 12, 2016
1 parent f477060 commit c799021
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion arch/openrisc/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,16 @@ ENTRY(__sys_fork)
l.addi r3,r1,0

ENTRY(sys_rt_sigreturn)
l.j _sys_rt_sigreturn
l.jal _sys_rt_sigreturn
l.addi r3,r1,0
l.sfne r30,r0
l.bnf _no_syscall_trace
l.nop
l.jal do_syscall_trace_leave
l.addi r3,r1,0
_no_syscall_trace:
l.j _resume_userspace
l.nop

/* This is a catch-all syscall for atomic instructions for the OpenRISC 1000.
* The functions takes a variable number of parameters depending on which
Expand Down

0 comments on commit c799021

Please sign in to comment.