[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241206101744.4161990-21-ruanjinjie@huawei.com>
Date: Fri, 6 Dec 2024 18:17:42 +0800
From: Jinjie Ruan <ruanjinjie@...wei.com>
To: <catalin.marinas@....com>, <will@...nel.org>, <oleg@...hat.com>,
<sstabellini@...nel.org>, <tglx@...utronix.de>, <peterz@...radead.org>,
<luto@...nel.org>, <mingo@...hat.com>, <juri.lelli@...hat.com>,
<vincent.guittot@...aro.org>, <dietmar.eggemann@....com>,
<rostedt@...dmis.org>, <bsegall@...gle.com>, <mgorman@...e.de>,
<vschneid@...hat.com>, <kees@...nel.org>, <wad@...omium.org>,
<akpm@...ux-foundation.org>, <samitolvanen@...gle.com>,
<masahiroy@...nel.org>, <hca@...ux.ibm.com>, <aliceryhl@...gle.com>,
<rppt@...nel.org>, <xur@...gle.com>, <paulmck@...nel.org>, <arnd@...db.de>,
<mbenes@...e.cz>, <puranjay@...nel.org>, <mark.rutland@....com>,
<ruanjinjie@...wei.com>, <pcc@...gle.com>, <ardb@...nel.org>,
<sudeep.holla@....com>, <guohanjun@...wei.com>, <rafael@...nel.org>,
<liuwei09@...tc.cn>, <dwmw@...zon.co.uk>, <Jonathan.Cameron@...wei.com>,
<liaochang1@...wei.com>, <kristina.martsenko@....com>, <ptosi@...gle.com>,
<broonie@...nel.org>, <thiago.bauermann@...aro.org>, <kevin.brodsky@....com>,
<joey.gouly@....com>, <liuyuntao12@...wei.com>, <leobras@...hat.com>,
<linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
<xen-devel@...ts.xenproject.org>
Subject: [PATCH -next v5 20/22] entry: Add arch_ptrace_report_syscall_entry/exit()
Due to historical reasons, ARM64 need to save/restore during syscall
entry/exit because ARM64 use a scratch register (ip(r12) on AArch32,
x7 on AArch64) to denote syscall entry/exit, which differs from
the implementation of the generic entry.
Add arch_ptrace_report_syscall_entry/exit() as the default
ptrace_report_syscall_entry/exit() implementation. This allows arm64
to implement the architecture specific version for switching over to
the generic entry code.
Suggested-by: Mark Rutland <mark.rutland@....com>
Suggested-by: Kevin Brodsky <kevin.brodsky@....com>
Suggested-by: Thomas Gleixner <tglx@...utronix.de>
Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
---
kernel/entry/syscall-common.c | 43 +++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/kernel/entry/syscall-common.c b/kernel/entry/syscall-common.c
index f78285097111..9ffa6349e769 100644
--- a/kernel/entry/syscall-common.c
+++ b/kernel/entry/syscall-common.c
@@ -17,6 +17,25 @@ static inline void syscall_enter_audit(struct pt_regs *regs, long syscall)
}
}
+/**
+ * arch_ptrace_report_syscall_entry - Architecture specific
+ * ptrace_report_syscall_entry().
+ *
+ * Invoked from syscall_trace_enter() to wrap ptrace_report_syscall_entry().
+ * Defaults to ptrace_report_syscall_entry.
+ *
+ * The main purpose is to support arch-specific ptrace_report_syscall_entry()
+ * implementation.
+ */
+static inline int arch_ptrace_report_syscall_entry(struct pt_regs *regs);
+
+#ifndef arch_ptrace_report_syscall_entry
+static inline int arch_ptrace_report_syscall_entry(struct pt_regs *regs)
+{
+ return ptrace_report_syscall_entry(regs);
+}
+#endif
+
long syscall_trace_enter(struct pt_regs *regs, long syscall,
unsigned long work)
{
@@ -34,7 +53,7 @@ long syscall_trace_enter(struct pt_regs *regs, long syscall,
/* Handle ptrace */
if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) {
- ret = ptrace_report_syscall_entry(regs);
+ ret = arch_ptrace_report_syscall_entry(regs);
if (ret || (work & SYSCALL_WORK_SYSCALL_EMU))
return -1L;
}
@@ -84,6 +103,26 @@ static inline bool report_single_step(unsigned long work)
return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP;
}
+/**
+ * arch_ptrace_report_syscall_exit - Architecture specific
+ * ptrace_report_syscall_exit.
+ *
+ * Invoked from syscall_exit_work() to wrap ptrace_report_syscall_exit().
+ *
+ * The main purpose is to support arch-specific ptrace_report_syscall_exit
+ * implementation.
+ */
+static inline void arch_ptrace_report_syscall_exit(struct pt_regs *regs,
+ int step);
+
+#ifndef arch_ptrace_report_syscall_exit
+static inline void arch_ptrace_report_syscall_exit(struct pt_regs *regs,
+ int step)
+{
+ ptrace_report_syscall_exit(regs, step);
+}
+#endif
+
static void syscall_exit_work(struct pt_regs *regs, unsigned long work)
{
bool step;
@@ -108,7 +147,7 @@ static void syscall_exit_work(struct pt_regs *regs, unsigned long work)
step = report_single_step(work);
if (step || work & SYSCALL_WORK_SYSCALL_TRACE)
- ptrace_report_syscall_exit(regs, step);
+ arch_ptrace_report_syscall_exit(regs, step);
}
/*
--
2.34.1
Powered by blists - more mailing lists