OSDN Git Service

powerpc: Add syscall detection for restartable sequences
authorBoqun Feng <boqun.feng@gmail.com>
Sat, 2 Jun 2018 12:44:01 +0000 (08:44 -0400)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 6 Jun 2018 09:58:33 +0000 (11:58 +0200)
Syscalls are not allowed inside restartable sequences, so add a call to
rseq_syscall() at the very beginning of system call exiting path for
CONFIG_DEBUG_RSEQ=y kernel. This could help us to detect whether there
is a syscall issued inside restartable sequences.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Watson <davejwatson@fb.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Chris Lameter <cl@linux.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Andrew Hunter <ahh@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ben Maurer <bmaurer@fb.com>
Cc: linux-api@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lkml.kernel.org/r/20180602124408.8430-10-mathieu.desnoyers@efficios.com
arch/powerpc/kernel/entry_32.S
arch/powerpc/kernel/entry_64.S

index eb8d01b..973577f 100644 (file)
@@ -365,6 +365,13 @@ syscall_dotrace_cont:
        blrl                    /* Call handler */
        .globl  ret_from_syscall
 ret_from_syscall:
+#ifdef CONFIG_DEBUG_RSEQ
+       /* Check whether the syscall is issued inside a restartable sequence */
+       stw     r3,GPR3(r1)
+       addi    r3,r1,STACK_FRAME_OVERHEAD
+       bl      rseq_syscall
+       lwz     r3,GPR3(r1)
+#endif
        mr      r6,r3
        CURRENT_THREAD_INFO(r12, r1)
        /* disable interrupts so current_thread_info()->flags can't change */
index 5169560..1c37438 100644 (file)
@@ -184,6 +184,14 @@ system_call:                       /* label this so stack traces look sane */
 
 .Lsyscall_exit:
        std     r3,RESULT(r1)
+
+#ifdef CONFIG_DEBUG_RSEQ
+       /* Check whether the syscall is issued inside a restartable sequence */
+       addi    r3,r1,STACK_FRAME_OVERHEAD
+       bl      rseq_syscall
+       ld      r3,RESULT(r1)
+#endif
+
        CURRENT_THREAD_INFO(r12, r1)
 
        ld      r8,_MSR(r1)