[PATCH RFC 20/28] ARM: entry: Untangle ret_fast_syscall/to_user

From: Linus Walleij
Date: Thu Oct 10 2024 - 07:37:09 EST


The return to userspace is a bit hard to follow. To prepare
the ground for further refactorings we rewrite the functions
to ret_fast_syscall and ret_to_user are mostly stand-alone
symbols.

Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
arch/arm/kernel/entry-common.S | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index d27e34d7e97a..ece921571714 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -44,20 +44,23 @@ ret_fast_syscall:
bl syscall_exit_to_user_mode
ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
movs r1, r1, lsl #16
- beq no_work_pending
- UNWIND(.fnend )
-ENDPROC(ret_fast_syscall)
-
- /* Slower path - fall through to work_pending */
+ beq 2f

tst r1, #_TIF_SYSCALL_WORK
- beq slow_work_pending
+ beq 1f
+
b ret_to_user

-slow_work_pending:
- mov r0, sp @ 'regs'
+1: mov r0, sp @ 'regs'
bl do_work_pending
- b no_work_pending
+
+2: asm_irqentry_exit_to_user_mode
+
+#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
+ bl stackleak_erase_on_task_stack
+#endif
+ restore_user_regs
+ UNWIND(.fnend )
ENDPROC(ret_fast_syscall)

/*
@@ -74,7 +77,9 @@ ENTRY(ret_to_user)
ENTRY(ret_to_user_from_irq)
ldr r1, [tsk, #TI_FLAGS]
movs r1, r1, lsl #16
- bne slow_work_pending
+ beq no_work_pending
+ mov r0, sp @ 'regs'
+ bl do_work_pending
no_work_pending:
asm_irqentry_exit_to_user_mode


--
2.46.2