linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-arch@vger.kernel.org
Subject: [RFC patch 08/15] arm64/syscall: Use generic syscall exit functionality
Date: Thu, 19 Sep 2019 17:03:22 +0200	[thread overview]
Message-ID: <20190919150809.235562522@linutronix.de> (raw)
In-Reply-To: 20190919150314.054351477@linutronix.de

Replace the syscall exit handling code with the generic version. That gets
rid of the interrupts disabled check for work flags. That's a non-issue
because the flags are checked with READ_ONCE() in the core and not
reevaluated. That's perfectly fine because the interrupts disabled check is
also just a snapshot.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arm64/include/asm/entry-common.h |   11 +++++++++
 arch/arm64/kernel/ptrace.c            |   38 ----------------------------------
 arch/arm64/kernel/syscall.c           |   14 ------------
 3 files changed, 12 insertions(+), 51 deletions(-)

--- a/arch/arm64/include/asm/entry-common.h
+++ b/arch/arm64/include/asm/entry-common.h
@@ -29,6 +29,17 @@ static inline __must_check int arch_sysc
 }
 #define arch_syscall_enter_tracehook arch_syscall_enter_tracehook
 
+static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step)
+{
+	int regno = (is_compat_task() ? 12 : 7);
+	unsigned long reg = regs->regs[regno];
+
+	regs->regs[regno] = PTRACE_SYSCALL_EXIT;
+	tracehook_report_syscall_exit(regs, step);
+	regs->regs[regno] = reg;
+}
+#define arch_syscall_exit_tracehook arch_syscall_exit_tracehook
+
 static inline void arch_syscall_enter_audit(struct pt_regs *regs)
 {
 	audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1],
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -13,13 +13,11 @@
 #include <linux/kernel.h>
 #include <linux/sched/signal.h>
 #include <linux/sched/task_stack.h>
-#include <linux/entry-common.h>
 #include <linux/mm.h>
 #include <linux/nospec.h>
 #include <linux/smp.h>
 #include <linux/ptrace.h>
 #include <linux/user.h>
-#include <linux/seccomp.h>
 #include <linux/security.h>
 #include <linux/init.h>
 #include <linux/signal.h>
@@ -28,7 +26,6 @@
 #include <linux/perf_event.h>
 #include <linux/hw_breakpoint.h>
 #include <linux/regset.h>
-#include <linux/tracehook.h>
 #include <linux/elf.h>
 
 #include <asm/compat.h>
@@ -1779,41 +1776,6 @@ long arch_ptrace(struct task_struct *chi
 	return ptrace_request(child, request, addr, data);
 }
 
-static void tracehook_report_syscall(struct pt_regs *regs,
-				     enum ptrace_syscall_dir dir)
-{
-	int regno;
-	unsigned long saved_reg;
-
-	/*
-	 * A scratch register (ip(r12) on AArch32, x7 on AArch64) is
-	 * used to denote syscall entry/exit:
-	 */
-	regno = (is_compat_task() ? 12 : 7);
-	saved_reg = regs->regs[regno];
-	regs->regs[regno] = dir;
-
-	if (dir == PTRACE_SYSCALL_EXIT)
-		tracehook_report_syscall_exit(regs, 0);
-	else if (tracehook_report_syscall_entry(regs))
-		forget_syscall(regs);
-
-	regs->regs[regno] = saved_reg;
-}
-
-void syscall_trace_exit(struct pt_regs *regs)
-{
-	audit_syscall_exit(regs);
-
-	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
-		trace_sys_exit(regs, regs_return_value(regs));
-
-	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT);
-
-	rseq_syscall(regs);
-}
-
 /*
  * SPSR_ELx bits which are always architecturally RES0 per ARM DDI 0487D.a.
  * We permit userspace to set SSBS (AArch64 bit 12, AArch32 bit 23) which is
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -54,13 +54,6 @@ static void invoke_syscall(struct pt_reg
 	regs->regs[0] = ret;
 }
 
-static inline bool has_syscall_work(unsigned long flags)
-{
-	return unlikely(flags & _TIF_SYSCALL_WORK);
-}
-
-void syscall_trace_exit(struct pt_regs *regs);
-
 #ifdef CONFIG_ARM64_ERRATUM_1463225
 DECLARE_PER_CPU(int, __in_cortex_a76_erratum_1463225_wa);
 
@@ -106,12 +99,7 @@ static void el0_svc_common(struct pt_reg
 	if (scno != NO_SYSCALL)
 		invoke_syscall(regs, scno, sc_nr, syscall_table);
 
-	local_daif_mask();
-	if (has_syscall_work(current_thread_info()->flags) ||
-	    IS_ENABLED(CONFIG_DEBUG_RSEQ)) {
-		local_daif_restore(DAIF_PROCCTX);
-		syscall_trace_exit(regs);
-	}
+	syscall_exit_to_usermode(regs, scno, regs_return_value(regs));
 }
 
 static inline void sve_user_discard(void)



  parent reply	other threads:[~2019-09-19 15:10 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 15:03 [RFC patch 00/15] entry: Provide generic implementation for host and guest entry/exit work Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 01/15] entry: Provide generic syscall entry functionality Thomas Gleixner
2019-09-20 23:38   ` Andy Lutomirski
2019-10-20 11:49     ` Thomas Gleixner
2019-09-23  9:05   ` Mike Rapoport
2019-09-19 15:03 ` [RFC patch 02/15] x86/entry: Remove _TIF_NOHZ from _TIF_WORK_SYSCALL_ENTRY Thomas Gleixner
2019-09-20 23:39   ` Andy Lutomirski
2019-09-23 20:43     ` Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 03/15] x86/entry: Use generic syscall entry function Thomas Gleixner
2019-09-20 23:41   ` Andy Lutomirski
2019-09-23  8:31     ` Peter Zijlstra
2019-09-23  8:40       ` Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 04/15] arm64/entry: " Thomas Gleixner
2019-09-20 12:21   ` Catalin Marinas
2019-09-19 15:03 ` [RFC patch 05/15] entry: Provide generic syscall exit function Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 06/15] x86/entry: Use generic syscall exit functionality Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 07/15] arm64/syscall: Remove obscure flag check Thomas Gleixner
2019-09-20 14:29   ` Catalin Marinas
2019-09-19 15:03 ` Thomas Gleixner [this message]
2019-09-19 15:03 ` [RFC patch 09/15] entry: Provide generic exit to usermode functionality Thomas Gleixner
2019-09-23  8:30   ` Peter Zijlstra
2019-09-19 15:03 ` [RFC patch 10/15] x86/entry: Move irq tracing to C code Thomas Gleixner
2019-09-23  8:47   ` Peter Zijlstra
2019-09-23 10:27     ` Thomas Gleixner
2019-09-23 11:49       ` Peter Zijlstra
2019-09-23 11:55         ` Peter Zijlstra
2019-09-23 12:10           ` Peter Zijlstra
2019-09-23 17:24             ` Andy Lutomirski
2019-09-26  2:59   ` Josh Poimboeuf
2019-09-19 15:03 ` [RFC patch 11/15] x86/entry: Use generic exit to usermode Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 12/15] arm64/entry: " Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 13/15] arm64/entry: Move FPU restore out of exit_to_usermode() loop Thomas Gleixner
2019-09-19 15:03 ` [RFC patch 14/15] workpending: Provide infrastructure for work before entering a guest Thomas Gleixner
2019-09-19 15:40   ` Paolo Bonzini
2019-09-20 11:48     ` Thomas Gleixner
2019-09-23 18:17   ` Andy Lutomirski
2019-09-26 11:35   ` Miroslav Benes
2019-09-19 15:03 ` [RFC patch 15/15] x86/kvm: Use GENERIC_EXIT_WORKPENDING Thomas Gleixner
2019-09-19 15:40   ` Paolo Bonzini
2019-09-20 15:12 ` [RFC patch 00/15] entry: Provide generic implementation for host and guest entry/exit work Mark Rutland
2019-09-23 20:50   ` Thomas Gleixner
2019-09-23 18:18 ` Andy Lutomirski
2019-09-24  6:50 ` Christian Borntraeger

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=20190919150809.235562522@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=catalin.marinas@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).