[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241029-arm-generic-entry-v2-22-573519abef38@linaro.org>
Date: Tue, 29 Oct 2024 11:53:02 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: 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 v2 22/28] 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 33bc9e7c5b32..5385574c4339 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 472338047337..0e3960844b94 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.46.2
Powered by blists - more mailing lists