[PATCH RFC 25/28] ARM: entry: Create irqentry calls from kernel mode

From: Linus Walleij
Date: Thu Oct 10 2024 - 07:38:21 EST


This adds a few calls to C when exceptions enter/exit from
the kernel itself, so these can be used for generic entry.

Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
arch/arm/include/asm/entry.h | 2 ++
arch/arm/kernel/entry-armv.S | 3 +++
arch/arm/kernel/entry-header.S | 5 +++++
arch/arm/kernel/entry.c | 8 ++++++++
4 files changed, 18 insertions(+)

diff --git a/arch/arm/include/asm/entry.h b/arch/arm/include/asm/entry.h
index 8b8cc9a1eefb..a78bc5054b09 100644
--- a/arch/arm/include/asm/entry.h
+++ b/arch/arm/include/asm/entry.h
@@ -12,5 +12,7 @@ long syscall_enter_from_user_mode(struct pt_regs *regs, long);
void syscall_exit_to_user_mode(struct pt_regs *regs);
void irqentry_enter_from_user_mode(struct pt_regs *regs);
void irqentry_exit_to_user_mode(struct pt_regs *regs);
+void irqentry_enter_from_kernel_mode(struct pt_regs *regs);
+void irqentry_exit_to_kernel_mode(struct pt_regs *regs);

#endif /* __ASM_ENTRY_H__ */
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index bd468d58dc02..21b11fe199cb 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -204,6 +204,9 @@ ENDPROC(__und_invalid)
get_thread_info tsk
uaccess_entry tsk, r0, r1, r2, \uaccess

+ mov r0, sp @ 'regs'
+ bl irqentry_enter_from_kernel_mode
+
.if \trace
#ifdef CONFIG_TRACE_IRQFLAGS
bl trace_hardirqs_off
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index 51c7f93c1ded..49a9c5cf6fd5 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -210,6 +210,7 @@
.else
@ IRQs off again before pulling preserved data off the stack
disable_irq_notrace
+
#ifdef CONFIG_TRACE_IRQFLAGS
tst \rpsr, #PSR_I_BIT
bleq trace_hardirqs_on
@@ -217,6 +218,10 @@
blne trace_hardirqs_off
#endif
.endif
+
+ mov r0, sp @ 'regs'
+ bl irqentry_exit_to_kernel_mode
+
uaccess_exit tsk, r0, r1

#ifndef CONFIG_THUMB2_KERNEL
diff --git a/arch/arm/kernel/entry.c b/arch/arm/kernel/entry.c
index d7fdb9df3331..674b5adcec00 100644
--- a/arch/arm/kernel/entry.c
+++ b/arch/arm/kernel/entry.c
@@ -56,3 +56,11 @@ noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)
/* This context tracking call has inverse naming */
user_enter_callable();
}
+
+noinstr void irqentry_enter_from_kernel_mode(struct pt_regs *regs)
+{
+}
+
+noinstr void irqentry_exit_to_kernel_mode(struct pt_regs *regs)
+{
+}

--
2.46.2