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 04/15] arm64/entry: Use generic syscall entry function
Date: Thu, 19 Sep 2019 17:03:18 +0200 [thread overview]
Message-ID: <20190919150808.830764150@linutronix.de> (raw)
In-Reply-To: 20190919150314.054351477@linutronix.de
Replace the syscall entry work handling with the generic version, Provide
the necessary helper inlines to handle the real architecture specific
parts, e.g. audit and seccomp invocations.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/arm64/Kconfig | 1
arch/arm64/include/asm/entry-common.h | 39 ++++++++++++++++++++++++++++++++++
arch/arm64/kernel/ptrace.c | 29 -------------------------
arch/arm64/kernel/syscall.c | 15 +++++--------
4 files changed, 47 insertions(+), 37 deletions(-)
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -99,6 +99,7 @@ config ARM64
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
+ select GENERIC_ENTRY
select GENERIC_IDLE_POLL_SETUP
select GENERIC_IRQ_MULTI_HANDLER
select GENERIC_IRQ_PROBE
--- /dev/null
+++ b/arch/arm64/include/asm/entry-common.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2017 ARM Ltd.
+ */
+#ifndef __ASM_ENTRY_COMMON_H
+#define __ASM_ENTRY_COMMON_H
+
+enum ptrace_syscall_dir {
+ PTRACE_SYSCALL_ENTER = 0,
+ PTRACE_SYSCALL_EXIT,
+};
+
+/*
+ * A scratch register (ip(r12) on AArch32, x7 on AArch64) is
+ * used to denote syscall entry/exit for the tracehooks
+ */
+static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs)
+{
+ int regno = (is_compat_task() ? 12 : 7);
+ unsigned long reg = regs->regs[regno];
+ long ret;
+
+ regs->regs[regno] = PTRACE_SYSCALL_ENTER;
+ ret = tracehook_report_syscall_entry(regs);
+ if (ret)
+ forget_syscall(regs);
+ regs->regs[regno] = reg;
+ return ret;
+}
+#define arch_syscall_enter_tracehook arch_syscall_enter_tracehook
+
+static inline void arch_syscall_enter_audit(struct pt_regs *regs)
+{
+ audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1],
+ regs->regs[2], regs->regs[3]);
+}
+#define arch_syscall_enter_audit arch_syscall_enter_audit
+
+#endif
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -13,6 +13,7 @@
#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>
@@ -41,7 +42,6 @@
#include <asm/traps.h>
#include <asm/system_misc.h>
-#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>
struct pt_regs_offset {
@@ -1779,11 +1779,6 @@ long arch_ptrace(struct task_struct *chi
return ptrace_request(child, request, addr, data);
}
-enum ptrace_syscall_dir {
- PTRACE_SYSCALL_ENTER = 0,
- PTRACE_SYSCALL_EXIT,
-};
-
static void tracehook_report_syscall(struct pt_regs *regs,
enum ptrace_syscall_dir dir)
{
@@ -1806,28 +1801,6 @@ static void tracehook_report_syscall(str
regs->regs[regno] = saved_reg;
}
-int syscall_trace_enter(struct pt_regs *regs)
-{
- if (test_thread_flag(TIF_SYSCALL_TRACE) ||
- test_thread_flag(TIF_SYSCALL_EMU)) {
- tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
- if (!in_syscall(regs) || test_thread_flag(TIF_SYSCALL_EMU))
- return -1;
- }
-
- /* Do the secure computing after ptrace; failures should be fast. */
- if (secure_computing(NULL) == -1)
- return -1;
-
- if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
- trace_sys_enter(regs, regs->syscallno);
-
- audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1],
- regs->regs[2], regs->regs[3]);
-
- return regs->syscallno;
-}
-
void syscall_trace_exit(struct pt_regs *regs)
{
audit_syscall_exit(regs);
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>
+#include <linux/entry-common.h>
#include <linux/context_tracking.h>
#include <linux/errno.h>
#include <linux/nospec.h>
@@ -58,7 +59,6 @@ static inline bool has_syscall_work(unsi
return unlikely(flags & _TIF_SYSCALL_WORK);
}
-int syscall_trace_enter(struct pt_regs *regs);
void syscall_trace_exit(struct pt_regs *regs);
#ifdef CONFIG_ARM64_ERRATUM_1463225
@@ -97,19 +97,16 @@ static void el0_svc_common(struct pt_reg
regs->orig_x0 = regs->regs[0];
regs->syscallno = scno;
+ /* Set default error number */
+ regs->regs[0] = -ENOSYS;
cortex_a76_erratum_1463225_svc_handler();
local_daif_restore(DAIF_PROCCTX);
user_exit();
- if (has_syscall_work(flags)) {
- /* set default errno for user-issued syscall(-1) */
- if (scno == NO_SYSCALL)
- regs->regs[0] = -ENOSYS;
- scno = syscall_trace_enter(regs);
- if (scno == NO_SYSCALL)
- goto trace_exit;
- }
+ scno = syscall_enter_from_usermode(regs, scno);
+ if (scno == NO_SYSCALL)
+ goto trace_exit;
invoke_syscall(regs, scno, sc_nr, syscall_table);
next prev parent reply other threads:[~2019-09-19 15:09 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 ` Thomas Gleixner [this message]
2019-09-20 12:21 ` [RFC patch 04/15] arm64/entry: " 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 ` [RFC patch 08/15] arm64/syscall: Use generic syscall exit functionality Thomas Gleixner
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=20190919150808.830764150@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).