mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: stefan.kristiansson@saunalahti.fi, shorne@gmail.com, jonas@southpole.se
Cc: linux@roeck-us.net, blue@cmd.nu, robh@kernel.org,
	linux-kernel@vger.kernel.org, openrisc@lists.librecores.org
Subject: [PATCH v2 2/9] openrisc: restore all regs on rt_sigreturn
Date: Mon, 14 Nov 2016 22:30:32 +0900	[thread overview]
Message-ID: <5c3fa1c5a426801ddf8a31730c24b749b285fab4.1479128947.git.shorne@gmail.com> (raw)
In-Reply-To: <1479130239-30707-1-git-send-email-shorne@gmail.com>
In-Reply-To: <cover.1479128947.git.shorne@gmail.com>

From: Jonas Bonn <jonas@southpole.se>

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 <sebastian@macke.de>
Signed-off-by: Jonas Bonn <jonas@southpole.se>
Tested-by: Guenter Roeck <linux@roeck-us.net>
[shorne@gmail.com: Updated comment better reflect change and issue]

Signed-off-by: Stafford Horne <shorne@gmail.com>
---
 arch/openrisc/kernel/entry.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
index fec8bf9..572d223 100644
--- a/arch/openrisc/kernel/entry.S
+++ b/arch/openrisc/kernel/entry.S
@@ -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
-- 
2.7.4

  parent reply	other threads:[~2016-11-14 13:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 13:30 [PATCH v2 0/9] openrisc: Misc fixes from backlog Stafford Horne
     [not found] ` <cover.1479128947.git.shorne@gmail.com>
2016-11-14 13:30   ` [PATCH v2 1/9] openrisc: fix PTRS_PER_PGD define Stafford Horne
2016-11-14 13:30   ` Stafford Horne [this message]
2016-11-14 13:30   ` [PATCH v2 3/9] openrisc: Add thread-local storage (TLS) support Stafford Horne
2016-11-14 13:30   ` [PATCH v2 4/9] openrisc: Support both old (or32) and new (or1k) toolchain Stafford Horne
2016-11-14 13:30   ` [PATCH v2 5/9] openrisc: add NR_CPUS Kconfig default value Stafford Horne
2016-11-14 13:30   ` [PATCH v2 6/9] openrisc: remove the redundant of_platform_populate Stafford Horne
2016-11-14 13:30   ` [PATCH v2 7/9] openrisc: Consolidate setup to use memblock instead of bootmem Stafford Horne
2016-11-14 13:30   ` [PATCH v2 8/9] openrisc: Updates after openrisc.net has been lost Stafford Horne
2016-11-16  7:13     ` [OpenRISC] " Olof Kindgren
2016-12-14  8:57     ` Geert Uytterhoeven
2016-12-14 11:44       ` Stafford Horne
2016-11-14 13:30   ` [PATCH v2 9/9] openrisc: include l.swa in check for write data pagefault Stafford Horne
2016-11-30  1:23 ` [PATCH v2 0/9] openrisc: Misc fixes from backlog Guenter Roeck
2016-11-30 12:40   ` Stafford Horne
2016-11-30 14:21     ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c3fa1c5a426801ddf8a31730c24b749b285fab4.1479128947.git.shorne@gmail.com \
    --to=shorne@gmail.com \
    --cc=blue@cmd.nu \
    --cc=jonas@southpole.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=openrisc@lists.librecores.org \
    --cc=robh@kernel.org \
    --cc=stefan.kristiansson@saunalahti.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®