[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250107-arm-generic-entry-v3-22-4e5f3c15db2d@linaro.org>
Date: Tue, 07 Jan 2025 10:41:38 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Dmitry Vyukov <dvyukov@...gle.com>, Oleg Nesterov <oleg@...hat.com>,
Russell King <linux@...linux.org.uk>, Kees Cook <kees@...nel.org>,
Andy Lutomirski <luto@...capital.net>, Will Drewry <wad@...omium.org>,
Frederic Weisbecker <frederic@...nel.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Jinjie Ruan <ruanjinjie@...wei.com>, Arnd Bergmann <arnd@...db.de>,
Ard Biesheuvel <ardb@...nel.org>, Al Viro <viro@...iv.linux.org.uk>
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH RFC v3 22/30] ARM: entry: Move work processing to C
At the end of a syscall software interrupt and every time we exit
an interrupt handler we check if there is work to do, i.e. if the
current thread (userspace or kernel daemon) has set the
_TIF_SYSCALL_WORK flag.
Move this processing over to the C entry code.
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
arch/arm/kernel/entry-common.S | 14 +-------------
arch/arm/kernel/entry.c | 10 ++++++++++
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 33bc9e7c5b32f62474724f1d47f97af24dba53bf..5385574c4339714f3d8b5ab6894f27466b89f932 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -42,19 +42,7 @@ ret_fast_syscall:
/* do_rseq_syscall needs interrupts enabled. */
mov r0, sp @ 'regs'
bl syscall_exit_to_user_mode
- ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
- movs r1, r1, lsl #16
- beq 2f
-
- tst r1, #_TIF_SYSCALL_WORK
- beq 1f
-
- b 2f
-
-1: mov r0, sp @ 'regs'
- bl do_work_pending
-
-2: asm_irqentry_exit_to_user_mode
+ asm_irqentry_exit_to_user_mode
#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
bl stackleak_erase_on_task_stack
diff --git a/arch/arm/kernel/entry.c b/arch/arm/kernel/entry.c
index 47233804733752aef0f2fec6f54badeab18e98d0..0e3960844b94b14325eb00ce7dd791b36c43ac3c 100644
--- a/arch/arm/kernel/entry.c
+++ b/arch/arm/kernel/entry.c
@@ -1,10 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
#include <asm/entry.h>
+#include <asm/ptrace.h>
#include <asm/signal.h>
#include <linux/context_tracking.h>
#include <linux/irqflags.h>
#include <linux/rseq.h>
+static inline bool has_syscall_work(unsigned long flags)
+{
+ return unlikely(flags & _TIF_SYSCALL_WORK);
+}
+
long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
{
trace_hardirqs_on();
@@ -18,8 +24,12 @@ long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
void syscall_exit_to_user_mode(struct pt_regs *regs)
{
+ unsigned long flags = read_thread_flags();
+
rseq_syscall(regs);
local_irq_disable();
+ if (has_syscall_work(flags))
+ do_work_pending(regs, flags);
}
noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)
--
2.47.1
Powered by blists - more mailing lists