[PATCH v21 11/15] arm64: syscall: Simplify el0_svc_common() syscall exit path
From: Jinjie Ruan
Date: Wed Nov 11 2026 - 06:44:24 EST
The fast exit path of el0_svc_common() is only taken when no syscall
work was pending on entry and CONFIG_DEBUG_RSEQ is disabled:
if (!(flags & _TIF_SYSCALL_WORK) && !IS_ENABLED(CONFIG_DEBUG_RSEQ)) {
flags = read_thread_flags();
if (unlikely(flags & _TIF_SYSCALL_EXIT_WORK) || flags & _TIF_SINGLESTEP)
arm64_syscall_exit_to_user_mode_work(regs);
return;
}
trace_exit:
arm64_syscall_exit_to_user_mode_work(regs);
arm64_syscall_exit_to_user_mode_work() already re-reads the thread
flags and checks the same flags itself. The only other thing it does is
rseq_syscall(), which is an empty stub when CONFIG_DEBUG_RSEQ is
disabled, i.e. whenever the fast path is taken. So both paths end up
doing exactly the same thing, and the fast path can be dropped:
trace_exit:
arm64_syscall_exit_to_user_mode_work(regs);
With CONFIG_DEBUG_RSEQ enabled the fast path was never taken, so
nothing changes there either.
has_syscall_work() then has a single user left, so open-code it.
No functional changes intended.
Cc: Mark Rutland <mark.rutland@xxxxxxx>
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Ada Couprie Diaz <ada.coupriediaz@xxxxxxx>
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
arch/arm64/kernel/syscall.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
index f1f0b6f3e32b..3488afd45d20 100644
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -54,11 +54,6 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno,
syscall_set_return_value(current, regs, 0, ret);
}
-static inline bool has_syscall_work(unsigned long flags)
-{
- return unlikely(flags & _TIF_SYSCALL_WORK);
-}
-
static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr,
const syscall_fn_t syscall_table[])
{
@@ -95,7 +90,7 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr,
return;
}
- if (has_syscall_work(flags)) {
+ if (unlikely(flags & _TIF_SYSCALL_WORK)) {
/*
* The de-facto standard way to skip a system call using ptrace
* is to set the system call to -1 (NO_SYSCALL) and set x0 to a
@@ -119,19 +114,6 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr,
}
invoke_syscall(regs, scno, sc_nr, syscall_table);
-
- /*
- * The tracing status may have changed under our feet, so we have to
- * check again. However, if we were tracing entry, then we always trace
- * exit regardless, as the old entry assembly did.
- */
- if (!has_syscall_work(flags) && !IS_ENABLED(CONFIG_DEBUG_RSEQ)) {
- flags = read_thread_flags();
- if (unlikely(flags & _TIF_SYSCALL_EXIT_WORK) || flags & _TIF_SINGLESTEP)
- arm64_syscall_exit_to_user_mode_work(regs);
- return;
- }
-
trace_exit:
arm64_syscall_exit_to_user_mode_work(regs);
}
--
2.34.1