Skip to contentSkip to conversation

Generic IRQ entry/exit support for powerpc

PATCH Superseded Mukesh Kumar Chaurasiya 5 participants 16 messages Nov 2, 2025 – Nov 21, 2025

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#5 lore raw

PATCH 5/8 powerpc: add exit_flags field in pt_regs

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Add a new field exit_flags in the pt_regs structure. This field will hold the flags set during interrupt or syscall execution that are required during exit to user mode.

Specifically, the TIF_RESTOREALL flag, stored in this field, helps the exit routine determine if any NVGPRs were modified and need to be restored before returning to userspace.

This addition ensures a clean and architecture-specific mechanism to track per-syscall or per-interrupt state transitions related to register restore.

Changes:
- Add exit_flags and __pt_regs_pad to maintain 16-byte stack alignment
- Update asm-offsets.c and ptrace.c for offset and validation
- Update PT_* constants in uapi header to reflect the new layout

---
 arch/powerpc/include/asm/ptrace.h      |  3 +++
 arch/powerpc/include/uapi/asm/ptrace.h | 14 +++++++++-----
 arch/powerpc/kernel/asm-offsets.c      |  1 +
 arch/powerpc/kernel/ptrace/ptrace.c    |  1 +
 4 files changed, 14 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/ptrace.h +3 -0
index 94aa1de2b06e..3af8a5898fe3 100644
@@ -53,6 +53,9 @@ struct pt_regs
 				unsigned long esr;
 			};
 			unsigned long result;
+			unsigned long exit_flags;
+			/* Maintain 16 byte interrupt stack alignment */
+			unsigned long __pt_regs_pad[1];
 		};
 	};
 #if defined(CONFIG_PPC64) || defined(CONFIG_PPC_KUAP)
arch/powerpc/include/uapi/asm/ptrace.h +9 -5
index 01e630149d48..de56b216c9c5 100644
@@ -55,6 +55,8 @@ struct pt_regs
 	unsigned long dar;		/* Fault registers */
 	unsigned long dsisr;		/* on 4xx/Book-E used for ESR */
 	unsigned long result;		/* Result of a system call */
+	unsigned long exit_flags;	/* System call exit flags */
+	unsigned long __pt_regs_pad[1];	/* Maintain 16 byte interrupt stack alignment */
 };
 
 #endif /* __ASSEMBLER__ */
@@ -114,10 +116,12 @@ struct pt_regs
 #define PT_DAR	41
 #define PT_DSISR 42
 #define PT_RESULT 43
-#define PT_DSCR 44
-#define PT_REGS_COUNT 44
+#define PT_EXIT_FLAGS 44
+#define PT_PAD 45
+#define PT_DSCR 46
+#define PT_REGS_COUNT 46
 
-#define PT_FPR0	48	/* each FP reg occupies 2 slots in this space */
+#define PT_FPR0	(PT_REGS_COUNT + 4)	/* each FP reg occupies 2 slots in this space */
 
 #ifndef __powerpc64__
 
@@ -129,7 +133,7 @@ struct pt_regs
 #define PT_FPSCR (PT_FPR0 + 32)	/* each FP reg occupies 1 slot in 64-bit space */
 
 
-#define PT_VR0 82	/* each Vector reg occupies 2 slots in 64-bit */
+#define PT_VR0	(PT_FPSCR + 2)	/* <82> each Vector reg occupies 2 slots in 64-bit */
 #define PT_VSCR (PT_VR0 + 32*2 + 1)
 #define PT_VRSAVE (PT_VR0 + 33*2)
 
@@ -137,7 +141,7 @@ struct pt_regs
 /*
  * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
  */
-#define PT_VSR0 150	/* each VSR reg occupies 2 slots in 64-bit */
+#define PT_VSR0	(PT_VRSAVE + 2)	/* each VSR reg occupies 2 slots in 64-bit */
 #define PT_VSR31 (PT_VSR0 + 2*31)
 #endif /* __powerpc64__ */
 
arch/powerpc/kernel/asm-offsets.c +1 -0
index a4bc80b30410..c0bb09f1db78 100644
@@ -292,6 +292,7 @@ int main(void)
 	STACK_PT_REGS_OFFSET(_ESR, esr);
 	STACK_PT_REGS_OFFSET(ORIG_GPR3, orig_gpr3);
 	STACK_PT_REGS_OFFSET(RESULT, result);
+	STACK_PT_REGS_OFFSET(EXIT_FLAGS, exit_flags);
 	STACK_PT_REGS_OFFSET(_TRAP, trap);
 #ifdef CONFIG_PPC64
 	STACK_PT_REGS_OFFSET(SOFTE, softe);
arch/powerpc/kernel/ptrace/ptrace.c +1 -0
index c6997df63287..2134b6d155ff 100644
@@ -432,6 +432,7 @@ void __init pt_regs_check(void)
 	CHECK_REG(PT_DAR, dar);
 	CHECK_REG(PT_DSISR, dsisr);
 	CHECK_REG(PT_RESULT, result);
+	CHECK_REG(PT_EXIT_FLAGS, exit_flags);
 	#undef CHECK_REG
 
 	BUILD_BUG_ON(PT_REGS_COUNT != sizeof(struct user_pt_regs) / sizeof(unsigned long));
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/8 powerpc: rename arch_irq_disabled_regs

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Rename arch_irq_disabled_regs() to regs_irqs_disabled() to align with the naming used in the generic irqentry framework. This makes the function available for use both in the PowerPC architecture code and in the common entry/exit paths shared with other architectures.

This is a preparatory change for enabling the generic irqentry framework on PowerPC.

---
 arch/powerpc/include/asm/hw_irq.h    |  4 ++--
 arch/powerpc/include/asm/interrupt.h | 16 ++++++++--------
 arch/powerpc/kernel/interrupt.c      |  4 ++--
 arch/powerpc/kernel/syscall.c        |  2 +-
 arch/powerpc/kernel/traps.c          |  2 +-
 arch/powerpc/kernel/watchdog.c       |  2 +-
 arch/powerpc/perf/core-book3s.c      |  2 +-
 7 files changed, 16 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/hw_irq.h +2 -2
index 1078ba88efaf..8dfe36b442a5 100644
@@ -393,7 +393,7 @@ static inline void do_hard_irq_enable(void)
 	__hard_irq_enable();
 }
 
-static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
+static inline bool regs_irqs_disabled(struct pt_regs *regs)
 {
 	return (regs->softe & IRQS_DISABLED);
 }
@@ -466,7 +466,7 @@ static inline bool arch_irqs_disabled(void)
 
 #define hard_irq_disable()		arch_local_irq_disable()
 
-static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
+static inline bool regs_irqs_disabled(struct pt_regs *regs)
 {
 	return !(regs->msr & MSR_EE);
 }
arch/powerpc/include/asm/interrupt.h +8 -8
index eb0e4a20b818..0e2cddf8bd21 100644
@@ -172,7 +172,7 @@ static inline void interrupt_enter_prepare(struct pt_regs *regs)
 	/* Enable MSR[RI] early, to support kernel SLB and hash faults */
 #endif
 
-	if (!arch_irq_disabled_regs(regs))
+	if (!regs_irqs_disabled(regs))
 		trace_hardirqs_off();
 
 	if (user_mode(regs)) {
@@ -192,11 +192,11 @@ static inline void interrupt_enter_prepare(struct pt_regs *regs)
 			CT_WARN_ON(ct_state() != CT_STATE_KERNEL &&
 				   ct_state() != CT_STATE_IDLE);
 		INT_SOFT_MASK_BUG_ON(regs, is_implicit_soft_masked(regs));
-		INT_SOFT_MASK_BUG_ON(regs, arch_irq_disabled_regs(regs) &&
-					   search_kernel_restart_table(regs->nip));
+		INT_SOFT_MASK_BUG_ON(regs, regs_irqs_disabled(regs) &&
+				     search_kernel_restart_table(regs->nip));
 	}
-	INT_SOFT_MASK_BUG_ON(regs, !arch_irq_disabled_regs(regs) &&
-				   !(regs->msr & MSR_EE));
+	INT_SOFT_MASK_BUG_ON(regs, !regs_irqs_disabled(regs) &&
+			     !(regs->msr & MSR_EE));
 
 	booke_restore_dbcr0();
 }
@@ -298,7 +298,7 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte
 		 * Adjust regs->softe to be soft-masked if it had not been
 		 * reconcied (e.g., interrupt entry with MSR[EE]=0 but softe
 		 * not yet set disabled), or if it was in an implicit soft
-		 * masked state. This makes arch_irq_disabled_regs(regs)
+		 * masked state. This makes regs_irqs_disabled(regs)
 		 * behave as expected.
 		 */
 		regs->softe = IRQS_ALL_DISABLED;
@@ -372,7 +372,7 @@ static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct inter
 
 #ifdef CONFIG_PPC64
 #ifdef CONFIG_PPC_BOOK3S
-	if (arch_irq_disabled_regs(regs)) {
+	if (regs_irqs_disabled(regs)) {
 		unsigned long rst = search_kernel_restart_table(regs->nip);
 		if (rst)
 			regs_set_return_ip(regs, rst);
@@ -661,7 +661,7 @@ void replay_soft_interrupts(void);
 
 static inline void interrupt_cond_local_irq_enable(struct pt_regs *regs)
 {
-	if (!arch_irq_disabled_regs(regs))
+	if (!regs_irqs_disabled(regs))
 		local_irq_enable();
 }
 
arch/powerpc/kernel/interrupt.c +2 -2
index e0c681d0b076..0d8fd47049a1 100644
@@ -347,7 +347,7 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)
 	unsigned long ret;
 
 	BUG_ON(regs_is_unrecoverable(regs));
-	BUG_ON(arch_irq_disabled_regs(regs));
+	BUG_ON(regs_irqs_disabled(regs));
 	CT_WARN_ON(ct_state() == CT_STATE_USER);
 
 	/*
@@ -396,7 +396,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
 
 	local_irq_disable();
 
-	if (!arch_irq_disabled_regs(regs)) {
+	if (!regs_irqs_disabled(regs)) {
 		/* Returning to a kernel context with local irqs enabled. */
 		WARN_ON_ONCE(!(regs->msr & MSR_EE));
 again:
arch/powerpc/kernel/syscall.c +1 -1
index be159ad4b77b..9f03a6263fb4 100644
@@ -32,7 +32,7 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
 
 	BUG_ON(regs_is_unrecoverable(regs));
 	BUG_ON(!user_mode(regs));
-	BUG_ON(arch_irq_disabled_regs(regs));
+	BUG_ON(regs_irqs_disabled(regs));
 
 #ifdef CONFIG_PPC_PKEY
 	if (mmu_has_feature(MMU_FTR_PKEY)) {
arch/powerpc/kernel/traps.c +1 -1
index cb8e9357383e..629f2a2d4780 100644
@@ -1956,7 +1956,7 @@ DEFINE_INTERRUPT_HANDLER_RAW(performance_monitor_exception)
 	 * prevent hash faults on user addresses when reading callchains (and
 	 * looks better from an irq tracing perspective).
 	 */
-	if (IS_ENABLED(CONFIG_PPC64) && unlikely(arch_irq_disabled_regs(regs)))
+	if (IS_ENABLED(CONFIG_PPC64) && unlikely(regs_irqs_disabled(regs)))
 		performance_monitor_exception_nmi(regs);
 	else
 		performance_monitor_exception_async(regs);
arch/powerpc/kernel/watchdog.c +1 -1
index 2429cb1c7baa..6111cbbde069 100644
@@ -373,7 +373,7 @@ DEFINE_INTERRUPT_HANDLER_NMI(soft_nmi_interrupt)
 	u64 tb;
 
 	/* should only arrive from kernel, with irqs disabled */
-	WARN_ON_ONCE(!arch_irq_disabled_regs(regs));
+	WARN_ON_ONCE(!regs_irqs_disabled(regs));
 
 	if (!cpumask_test_cpu(cpu, &wd_cpus_enabled))
 		return 0;
arch/powerpc/perf/core-book3s.c +1 -1
index 8b0081441f85..f7518b7e3055 100644
@@ -2482,7 +2482,7 @@ static void __perf_event_interrupt(struct pt_regs *regs)
 	 * will trigger a PMI after waking up from idle. Since counter values are _not_
 	 * saved/restored in idle path, can lead to below "Can't find PMC" message.
 	 */
-	if (unlikely(!found) && !arch_irq_disabled_regs(regs))
+	if (unlikely(!found) && !regs_irqs_disabled(regs))
 		printk_ratelimited(KERN_WARNING "Can't find PMC that caused IRQ\n");
 
 	/*
Signature · 1 line
2.51.0
#0 lore raw

cover Generic IRQ entry/exit support for powerpc

Adding support for the generic irq entry/exit handling for PowerPC. The goal is to bring PowerPC in line with other architectures that already use the common irq entry infrastructure, reducing duplicated code and making it easier to share future changes in entry/exit paths.

This is slightly tested of ppc64le and ppc32.

The performance benchmarks from perf bench basic syscall are below:

| Metric     | W/O Generic Framework | With Generic Framework | Change |
| ---------- | --------------------- | ---------------------- | ------ |
| Total time | 0.939 [sec]           | 0.938 [sec]            | ~0%    |
| usecs/op   | 0.093900              | 0.093882               | ~0%    |
| ops/sec    | 1,06,49,615           | 1,06,51,725            | ~0%    |

Thats very close to performance earlier with arch specific handling.

Tests done:
- Build and boot on ppc64le pseries.
- Build and boot on ppc64le powernv8 powernv9 powernv10.
- Build and boot on ppc32.
- Performance benchmark done with perf syscall basic on pseries.

Changelog:

RFC -> PATCH
- Fix for ppc32 spitting out kuap lock warnings.
- ppc64le powernv8 crash fix.
- Review comments incorporated from previous RFC.
RFC https://lore.kernel.org/all/[email protected]/

Mukesh Kumar Chaurasiya (8):
powerpc: rename arch_irq_disabled_regs
powerpc: Prepare to build with generic entry/exit framework
powerpc: introduce arch_enter_from_user_mode
powerpc: Introduce syscall exit arch functions
powerpc: add exit_flags field in pt_regs
powerpc: Prepare for IRQ entry exit
powerpc: Enable IRQ generic entry/exit path.
powerpc: Enable Generic Entry/Exit for syscalls.

 arch/powerpc/Kconfig                    |   2 +
 arch/powerpc/include/asm/entry-common.h | 539 ++++++++++++++++++++++++
 arch/powerpc/include/asm/hw_irq.h       |   4 +-
 arch/powerpc/include/asm/interrupt.h    | 401 +++---------------
 arch/powerpc/include/asm/ptrace.h       |   3 +
 arch/powerpc/include/asm/stacktrace.h   |   6 +
 arch/powerpc/include/asm/syscall.h      |   5 +
 arch/powerpc/include/asm/thread_info.h  |   1 +
 arch/powerpc/include/uapi/asm/ptrace.h  |  14 +-
 arch/powerpc/kernel/asm-offsets.c       |   1 +
 arch/powerpc/kernel/interrupt.c         | 258 +++---------
 arch/powerpc/kernel/ptrace/ptrace.c     | 142 +------
 arch/powerpc/kernel/signal.c            |   8 +
 arch/powerpc/kernel/syscall.c           | 119 +-----
 arch/powerpc/kernel/traps.c             |   2 +-
 arch/powerpc/kernel/watchdog.c          |   2 +-
 arch/powerpc/perf/core-book3s.c         |   2 +-
 17 files changed, 693 insertions(+), 816 deletions(-)
 create mode 100644 arch/powerpc/include/asm/entry-common.h
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/8 powerpc: Prepare to build with generic entry/exit framework

From: Mukesh Kumar Chaurasiya <[email protected]>

This patch introduces preparatory changes needed to support building PowerPC with the generic entry/exit (irqentry) framework.

The following infrastructure updates are added:
- Add a syscall_work field to struct thread_info to hold SYSCALL_WORK_* flags.
- Provide a stub implementation of arch_syscall_is_vdso_sigreturn(), returning false for now.
- Introduce on_thread_stack() helper to detect if the current stack pointer lies within the task’s kernel stack.

These additions enable later integration with the generic entry/exit infrastructure while keeping existing PowerPC behavior unchanged.

No functional change is intended in this patch.

---
 arch/powerpc/include/asm/entry-common.h | 11 +++++++++++
 arch/powerpc/include/asm/stacktrace.h   |  6 ++++++
 arch/powerpc/include/asm/syscall.h      |  5 +++++
 arch/powerpc/include/asm/thread_info.h  |  1 +
 4 files changed, 23 insertions(+)
 create mode 100644 arch/powerpc/include/asm/entry-common.h
arch/powerpc/include/asm/entry-common.h new file +11 -0
new file mode 100644
index 000000000000..3af16d821d07
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _ASM_PPC_ENTRY_COMMON_H
+#define _ASM_PPC_ENTRY_COMMON_H
+
+#ifdef CONFIG_GENERIC_IRQ_ENTRY
+
+#include <asm/stacktrace.h>
+
+#endif /* CONFIG_GENERIC_IRQ_ENTRY */
+#endif /* _ASM_PPC_ENTRY_COMMON_H */
arch/powerpc/include/asm/stacktrace.h +6 -0
index 6149b53b3bc8..a81a9373d723 100644
@@ -10,4 +10,10 @@
 
 void show_user_instructions(struct pt_regs *regs);
 
+static inline bool on_thread_stack(void)
+{
+	return !(((unsigned long)(current->stack) ^ current_stack_pointer)
+			& ~(THREAD_SIZE - 1));
+}
+
 #endif /* _ASM_POWERPC_STACKTRACE_H */
arch/powerpc/include/asm/syscall.h +5 -0
index 4b3c52ed6e9d..834fcc4f7b54 100644
@@ -139,4 +139,9 @@ static inline int syscall_get_arch(struct task_struct *task)
 	else
 		return AUDIT_ARCH_PPC64;
 }
+
+static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
+{
+	return false;
+}
 #endif	/* _ASM_SYSCALL_H */
arch/powerpc/include/asm/thread_info.h +1 -0
index b0f200aba2b3..9c8270354f0b 100644
@@ -57,6 +57,7 @@ struct thread_info {
 #ifdef CONFIG_SMP
 	unsigned int	cpu;
 #endif
+	unsigned long	syscall_work;		/* SYSCALL_WORK_ flags */
 	unsigned long	local_flags;		/* private flags for thread */
 #ifdef CONFIG_LIVEPATCH_64
 	unsigned long *livepatch_sp;
Signature · 1 line
2.51.0
#3 lore raw

PATCH 3/8 powerpc: introduce arch_enter_from_user_mode

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Implement the arch_enter_from_user_mode() hook required by the generic entry/exit framework. This helper prepares the CPU state when entering the kernel from userspace, ensuring correct handling of KUAP/KUEP, transactional memory, and debug register state.

As part of this change, move booke_load_dbcr0() from interrupt.c to interrupt.h so it can be used by the new helper without introducing cross-file dependencies.

This patch contains no functional changes, it is purely preparatory for enabling the generic syscall and interrupt entry path on PowerPC.

---
 arch/powerpc/include/asm/entry-common.h | 97 +++++++++++++++++++++++++
 arch/powerpc/include/asm/interrupt.h    | 22 ++++++
 arch/powerpc/kernel/interrupt.c         | 22 ------
 3 files changed, 119 insertions(+), 22 deletions(-)
arch/powerpc/include/asm/entry-common.h +97 -0
index 3af16d821d07..093ece06ef79 100644
@@ -5,7 +5,104 @@
 
 #ifdef CONFIG_GENERIC_IRQ_ENTRY
 
+#include <asm/cputime.h>
+#include <asm/interrupt.h>
 #include <asm/stacktrace.h>
+#include <asm/tm.h>
+
+static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
+{
+	if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
+		BUG_ON(irq_soft_mask_return() != IRQS_ALL_DISABLED);
+
+	BUG_ON(regs_is_unrecoverable(regs));
+	BUG_ON(!user_mode(regs));
+	BUG_ON(regs_irqs_disabled(regs));
+
+#ifdef CONFIG_PPC_PKEY
+	if (mmu_has_feature(MMU_FTR_PKEY) && trap_is_syscall(regs)) {
+		unsigned long amr, iamr;
+		bool flush_needed = false;
+		/*
+		 * When entering from userspace we mostly have the AMR/IAMR
+		 * different from kernel default values. Hence don't compare.
+		 */
+		amr = mfspr(SPRN_AMR);
+		iamr = mfspr(SPRN_IAMR);
+		regs->amr  = amr;
+		regs->iamr = iamr;
+		if (mmu_has_feature(MMU_FTR_KUAP)) {
+			mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
+			flush_needed = true;
+		}
+		if (mmu_has_feature(MMU_FTR_BOOK3S_KUEP)) {
+			mtspr(SPRN_IAMR, AMR_KUEP_BLOCKED);
+			flush_needed = true;
+		}
+		if (flush_needed)
+			isync();
+	} else
+#endif
+		kuap_assert_locked();
+
+	booke_restore_dbcr0();
+
+	account_cpu_user_entry();
+
+	account_stolen_time();
+
+	/*
+	 * This is not required for the syscall exit path, but makes the
+	 * stack frame look nicer. If this was initialised in the first stack
+	 * frame, or if the unwinder was taught the first stack frame always
+	 * returns to user with IRQS_ENABLED, this store could be avoided!
+	 */
+	irq_soft_mask_regs_set_state(regs, IRQS_ENABLED);
+
+	/*
+	 * If system call is called with TM active, set _TIF_RESTOREALL to
+	 * prevent RFSCV being used to return to userspace, because POWER9
+	 * TM implementation has problems with this instruction returning to
+	 * transactional state. Final register values are not relevant because
+	 * the transaction will be aborted upon return anyway. Or in the case
+	 * of unsupported_scv SIGILL fault, the return state does not much
+	 * matter because it's an edge case.
+	 */
+	if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&
+	    unlikely(MSR_TM_TRANSACTIONAL(regs->msr)))
+		set_bits(_TIF_RESTOREALL, &current_thread_info()->flags);
+
+	/*
+	 * If the system call was made with a transaction active, doom it and
+	 * return without performing the system call. Unless it was an
+	 * unsupported scv vector, in which case it's treated like an illegal
+	 * instruction.
+	 */
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+	if (unlikely(MSR_TM_TRANSACTIONAL(regs->msr)) &&
+	    !trap_is_unsupported_scv(regs)) {
+		/* Enable TM in the kernel, and disable EE (for scv) */
+		hard_irq_disable();
+		mtmsr(mfmsr() | MSR_TM);
+
+		/* tabort, this dooms the transaction, nothing else */
+		asm volatile(".long 0x7c00071d | ((%0) << 16)"
+			     :: "r"(TM_CAUSE_SYSCALL | TM_CAUSE_PERSISTENT));
+
+		/*
+		 * Userspace will never see the return value. Execution will
+		 * resume after the tbegin. of the aborted transaction with the
+		 * checkpointed register state. A context switch could occur
+		 * or signal delivered to the process before resuming the
+		 * doomed transaction context, but that should all be handled
+		 * as expected.
+		 */
+		return;
+	}
+#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
+}
+
+#define arch_enter_from_user_mode arch_enter_from_user_mode
 
 #endif /* CONFIG_GENERIC_IRQ_ENTRY */
 #endif /* _ASM_PPC_ENTRY_COMMON_H */
arch/powerpc/include/asm/interrupt.h +22 -0
index 0e2cddf8bd21..ca8a2cda9400 100644
@@ -138,6 +138,28 @@ static inline void nap_adjust_return(struct pt_regs *regs)
 #endif
 }
 
+static inline void booke_load_dbcr0(void)
+{
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
+	unsigned long dbcr0 = current->thread.debug.dbcr0;
+
+	if (likely(!(dbcr0 & DBCR0_IDM)))
+		return;
+
+	/*
+	 * Check to see if the dbcr0 register is set up to debug.
+	 * Use the internal debug mode bit to do this.
+	 */
+	mtmsr(mfmsr() & ~MSR_DE);
+	if (IS_ENABLED(CONFIG_PPC32)) {
+		isync();
+		global_dbcr0[smp_processor_id()] = mfspr(SPRN_DBCR0);
+	}
+	mtspr(SPRN_DBCR0, dbcr0);
+	mtspr(SPRN_DBSR, -1);
+#endif
+}
+
 static inline void booke_restore_dbcr0(void)
 {
 #ifdef CONFIG_PPC_ADV_DEBUG_REGS
arch/powerpc/kernel/interrupt.c +0 -22
index 0d8fd47049a1..2a09ac5dabd6 100644
@@ -78,28 +78,6 @@ static notrace __always_inline bool prep_irq_for_enabled_exit(bool restartable)
 	return true;
 }
 
-static notrace void booke_load_dbcr0(void)
-{
-#ifdef CONFIG_PPC_ADV_DEBUG_REGS
-	unsigned long dbcr0 = current->thread.debug.dbcr0;
-
-	if (likely(!(dbcr0 & DBCR0_IDM)))
-		return;
-
-	/*
-	 * Check to see if the dbcr0 register is set up to debug.
-	 * Use the internal debug mode bit to do this.
-	 */
-	mtmsr(mfmsr() & ~MSR_DE);
-	if (IS_ENABLED(CONFIG_PPC32)) {
-		isync();
-		global_dbcr0[smp_processor_id()] = mfspr(SPRN_DBCR0);
-	}
-	mtspr(SPRN_DBCR0, dbcr0);
-	mtspr(SPRN_DBSR, -1);
-#endif
-}
-
 static notrace void check_return_regs_valid(struct pt_regs *regs)
 {
 #ifdef CONFIG_PPC_BOOK3S_64
Signature · 1 line
2.51.0
#7 lore raw

PATCH 7/8 powerpc: Enable IRQ generic entry/exit path.

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Enable the generic IRQ entry/exit infrastructure on PowerPC by selecting GENERIC_IRQ_ENTRY and integrating the architecture-specific interrupt handlers with the generic entry/exit APIs.

This change replaces PowerPC’s local interrupt entry/exit handling with calls to the generic irqentry_* helpers, aligning the architecture with the common kernel entry model. The macros that define interrupt, async, and NMI handlers are updated to use irqentry_enter()/irqentry_exit() and irqentry_nmi_enter()/irqentry_nmi_exit() where applicable.

Key updates include:
- Select GENERIC_IRQ_ENTRY in Kconfig.
- Replace interrupt_enter/exit_prepare() with arch_interrupt_* helpers.
- Integrate irqentry_enter()/exit() in standard and async interrupt paths.
- Integrate irqentry_nmi_enter()/exit() in NMI handlers.
- Remove redundant irq_enter()/irq_exit() calls now handled generically.
- Use irqentry_exit_cond_resched() for preemption checks.

This change establishes the necessary wiring for PowerPC to use the generic IRQ entry/exit framework while maintaining existing semantics.

---
 arch/powerpc/Kconfig                    |   1 +
 arch/powerpc/include/asm/entry-common.h |  66 +---
 arch/powerpc/include/asm/interrupt.h    | 499 +++---------------------
 arch/powerpc/kernel/interrupt.c         |  13 +-
 4 files changed, 74 insertions(+), 505 deletions(-)
arch/powerpc/Kconfig +1 -0
index e24f4d88885a..b0c602c3bbe1 100644
@@ -206,6 +206,7 @@ config PPC
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IOREMAP
+	select GENERIC_IRQ_ENTRY
 	select GENERIC_IRQ_SHOW
 	select GENERIC_IRQ_SHOW_LEVEL
 	select GENERIC_PCI_IOMAP		if PCI
arch/powerpc/include/asm/entry-common.h +13 -53

109 lines not on this page · raw message

arch/powerpc/include/asm/interrupt.h +58 -441

539 lines not on this page · raw message

arch/powerpc/kernel/interrupt.c +2 -11
index f53d432f6087..7f67f0b9d627 100644
@@ -24,10 +24,6 @@
 unsigned long global_dbcr0[NR_CPUS];
 #endif
 
-#if defined(CONFIG_PREEMPT_DYNAMIC)
-DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
-#endif
-
 #ifdef CONFIG_PPC_BOOK3S_64
 DEFINE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
 static inline bool exit_must_hard_disable(void)
@@ -297,13 +293,8 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
 		/* Returning to a kernel context with local irqs enabled. */
 		WARN_ON_ONCE(!(regs->msr & MSR_EE));
 again:
-		if (need_irq_preemption()) {
-			/* Return to preemptible kernel context */
-			if (unlikely(read_thread_flags() & _TIF_NEED_RESCHED)) {
-				if (preempt_count() == 0)
-					preempt_schedule_irq();
-			}
-		}
+		if (need_irq_preemption())
+			irqentry_exit_cond_resched();
 
 		check_return_regs_valid(regs);
 
Signature · 1 line
2.51.0
#4 lore raw

PATCH 4/8 powerpc: Introduce syscall exit arch functions

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Add PowerPC-specific implementations of the generic syscall exit hooks used by the generic entry/exit framework:

- arch_exit_to_user_mode_work_prepare()
- arch_exit_to_user_mode_work()

These helpers handle user state restoration when returning from the kernel to userspace, including FPU/VMX/VSX state, transactional memory, KUAP restore, and per-CPU accounting.

Additionally, move check_return_regs_valid() from interrupt.c to interrupt.h so it can be shared by the new entry/exit logic, and add arch_do_signal_or_restart() for use with the generic entry flow.

No functional change is intended with this patch.

---
 arch/powerpc/include/asm/entry-common.h | 49 +++++++++++++++
 arch/powerpc/include/asm/interrupt.h    | 82 +++++++++++++++++++++++++
 arch/powerpc/kernel/interrupt.c         | 81 ------------------------
 arch/powerpc/kernel/signal.c            | 14 +++++
 4 files changed, 145 insertions(+), 81 deletions(-)
arch/powerpc/include/asm/entry-common.h +49 -0
index 093ece06ef79..e8ebd42a4e6d 100644
@@ -8,6 +8,7 @@
 #include <asm/cputime.h>
 #include <asm/interrupt.h>
 #include <asm/stacktrace.h>
+#include <asm/switch_to.h>
 #include <asm/tm.h>
 
 static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
@@ -104,5 +105,53 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
 
 #define arch_enter_from_user_mode arch_enter_from_user_mode
 
+static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
+						  unsigned long ti_work)
+{
+	unsigned long mathflags;
+
+	if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && IS_ENABLED(CONFIG_PPC_FPU)) {
+		if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&
+		    unlikely((ti_work & _TIF_RESTORE_TM))) {
+			restore_tm_state(regs);
+		} else {
+			mathflags = MSR_FP;
+
+			if (cpu_has_feature(CPU_FTR_VSX))
+				mathflags |= MSR_VEC | MSR_VSX;
+			else if (cpu_has_feature(CPU_FTR_ALTIVEC))
+				mathflags |= MSR_VEC;
+
+			/*
+			 * If userspace MSR has all available FP bits set,
+			 * then they are live and no need to restore. If not,
+			 * it means the regs were given up and restore_math
+			 * may decide to restore them (to avoid taking an FP
+			 * fault).
+			 */
+			if ((regs->msr & mathflags) != mathflags)
+				restore_math(regs);
+		}
+	}
+
+	check_return_regs_valid(regs);
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+	local_paca->tm_scratch = regs->msr;
+#endif
+	/* Restore user access locks last */
+	kuap_user_restore(regs);
+}
+
+#define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare
+
+static __always_inline void arch_exit_to_user_mode(void)
+{
+	booke_load_dbcr0();
+
+	account_cpu_user_exit();
+}
+
+#define arch_exit_to_user_mode arch_exit_to_user_mode
+
 #endif /* CONFIG_GENERIC_IRQ_ENTRY */
 #endif /* _ASM_PPC_ENTRY_COMMON_H */
arch/powerpc/include/asm/interrupt.h +82 -0

94 lines not on this page · raw message

arch/powerpc/kernel/interrupt.c +0 -81

93 lines not on this page · raw message

arch/powerpc/kernel/signal.c +14 -0
index aa17e62f3754..719930cf4ae1 100644
@@ -22,6 +22,11 @@
 
 #include "signal.h"
 
+/* This will be removed */
+#ifdef CONFIG_GENERIC_ENTRY
+#include <linux/entry-common.h>
+#endif /* CONFIG_GENERIC_ENTRY */
+
 #ifdef CONFIG_VSX
 unsigned long copy_fpr_to_user(void __user *to,
 			       struct task_struct *task)
@@ -368,3 +373,12 @@ void signal_fault(struct task_struct *tsk, struct pt_regs *regs,
 		printk_ratelimited(regs->msr & MSR_64BIT ? fm64 : fm32, tsk->comm,
 				   task_pid_nr(tsk), where, ptr, regs->nip, regs->link);
 }
+
+#ifdef CONFIG_GENERIC_ENTRY
+void arch_do_signal_or_restart(struct pt_regs *regs)
+{
+	BUG_ON(regs != current->thread.regs);
+	local_paca->generic_fw_flags |= GFW_RESTORE_ALL;
+	do_signal(current);
+}
+#endif /* CONFIG_GENERIC_ENTRY */
Signature · 1 line
2.51.0
#6 lore raw

PATCH 6/8 powerpc: Prepare for IRQ entry exit

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Move interrupt entry and exit helper routines from interrupt.h into the PowerPC-specific entry-common.h header as a preparatory step for enabling the generic entry/exit framework.

This consolidation places all PowerPC interrupt entry/exit handling in a single common header, aligning with the generic entry infrastructure. The helpers provide architecture-specific handling for interrupt and NMI entry/exit sequences, including:

- arch_interrupt_enter/exit_prepare()
- arch_interrupt_async_enter/exit_prepare()
- arch_interrupt_nmi_enter/exit_prepare()
- Supporting helpers such as nap_adjust_return(), check_return_regs_valid(), debug register maintenance, and soft mask handling.

The functions are copied verbatim from interrupt.h to avoid functional changes at this stage. Subsequent patches will integrate these routines into the generic entry/exit flow.

No functional change intended.

---
 arch/powerpc/include/asm/entry-common.h | 422 ++++++++++++++++++++++++
 1 file changed, 422 insertions(+)
arch/powerpc/include/asm/entry-common.h +422 -0
index e8ebd42a4e6d..e8bde4c67eaf 100644
@@ -7,10 +7,432 @@
 
 #include <asm/cputime.h>
 #include <asm/interrupt.h>
+#include <asm/runlatch.h>
 #include <asm/stacktrace.h>
 #include <asm/switch_to.h>
 #include <asm/tm.h>
 
+#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
+/*
+ * WARN/BUG is handled with a program interrupt so minimise checks here to
+ * avoid recursion and maximise the chance of getting the first oops handled.
+ */
+#define INT_SOFT_MASK_BUG_ON(regs, cond)				\
+do {									\
+	if ((user_mode(regs) || (TRAP(regs) != INTERRUPT_PROGRAM)))	\
+		BUG_ON(cond);						\
+} while (0)
+#else
+#define INT_SOFT_MASK_BUG_ON(regs, cond)
+#endif
+
+#ifdef CONFIG_PPC_BOOK3S_64
+extern char __end_soft_masked[];
+bool search_kernel_soft_mask_table(unsigned long addr);
+unsigned long search_kernel_restart_table(unsigned long addr);
+
+DECLARE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
+
+static inline bool is_implicit_soft_masked(struct pt_regs *regs)
+{
+	if (user_mode(regs))
+		return false;
+
+	if (regs->nip >= (unsigned long)__end_soft_masked)
+		return false;
+
+	return search_kernel_soft_mask_table(regs->nip);
+}
+
+static inline void srr_regs_clobbered(void)
+{
+	local_paca->srr_valid = 0;
+	local_paca->hsrr_valid = 0;
+}
+#else
+static inline unsigned long search_kernel_restart_table(unsigned long addr)
+{
+	return 0;
+}
+
+static inline bool is_implicit_soft_masked(struct pt_regs *regs)
+{
+	return false;
+}
+
+static inline void srr_regs_clobbered(void)
+{
+}
+#endif
+
+static inline void nap_adjust_return(struct pt_regs *regs)
+{
+#ifdef CONFIG_PPC_970_NAP
+	if (unlikely(test_thread_local_flags(_TLF_NAPPING))) {
+		/* Can avoid a test-and-clear because NMIs do not call this */
+		clear_thread_local_flags(_TLF_NAPPING);
+		regs_set_return_ip(regs, (unsigned long)power4_idle_nap_return);
+	}
+#endif
+}
+
+static inline void booke_load_dbcr0(void)
+{
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
+	unsigned long dbcr0 = current->thread.debug.dbcr0;
+
+	if (likely(!(dbcr0 & DBCR0_IDM)))
+		return;
+
+	/*
+	 * Check to see if the dbcr0 register is set up to debug.
+	 * Use the internal debug mode bit to do this.
+	 */
+	mtmsr(mfmsr() & ~MSR_DE);
+	if (IS_ENABLED(CONFIG_PPC32)) {
+		isync();
+		global_dbcr0[smp_processor_id()] = mfspr(SPRN_DBCR0);
+	}
+	mtspr(SPRN_DBCR0, dbcr0);
+	mtspr(SPRN_DBSR, -1);
+#endif
+}
+
+static inline void booke_restore_dbcr0(void)
+{
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
+	unsigned long dbcr0 = current->thread.debug.dbcr0;
+
+	if (IS_ENABLED(CONFIG_PPC32) && unlikely(dbcr0 & DBCR0_IDM)) {
+		mtspr(SPRN_DBSR, -1);
+		mtspr(SPRN_DBCR0, global_dbcr0[smp_processor_id()]);
+	}
+#endif
+}
+
+static inline void check_return_regs_valid(struct pt_regs *regs)
+{
+#ifdef CONFIG_PPC_BOOK3S_64
+	unsigned long trap, srr0, srr1;
+	static bool warned;
+	u8 *validp;
+	char *h;
+
+	if (trap_is_scv(regs))
+		return;
+
+	trap = TRAP(regs);
+	// EE in HV mode sets HSRRs like 0xea0
+	if (cpu_has_feature(CPU_FTR_HVMODE) && trap == INTERRUPT_EXTERNAL)
+		trap = 0xea0;
+
+	switch (trap) {
+	case 0x980:
+	case INTERRUPT_H_DATA_STORAGE:
+	case 0xe20:
+	case 0xe40:
+	case INTERRUPT_HMI:
+	case 0xe80:
+	case 0xea0:
+	case INTERRUPT_H_FAC_UNAVAIL:
+	case 0x1200:
+	case 0x1500:
+	case 0x1600:
+	case 0x1800:
+		validp = &local_paca->hsrr_valid;
+		if (!READ_ONCE(*validp))
+			return;
+
+		srr0 = mfspr(SPRN_HSRR0);
+		srr1 = mfspr(SPRN_HSRR1);
+		h = "H";
+
+		break;
+	default:
+		validp = &local_paca->srr_valid;
+		if (!READ_ONCE(*validp))
+			return;
+
+		srr0 = mfspr(SPRN_SRR0);
+		srr1 = mfspr(SPRN_SRR1);
+		h = "";
+		break;
+	}
+
+	if (srr0 == regs->nip && srr1 == regs->msr)
+		return;
+
+	/*
+	 * A NMI / soft-NMI interrupt may have come in after we found
+	 * srr_valid and before the SRRs are loaded. The interrupt then
+	 * comes in and clobbers SRRs and clears srr_valid. Then we load
+	 * the SRRs here and test them above and find they don't match.
+	 *
+	 * Test validity again after that, to catch such false positives.
+	 *
+	 * This test in general will have some window for false negatives
+	 * and may not catch and fix all such cases if an NMI comes in
+	 * later and clobbers SRRs without clearing srr_valid, but hopefully
+	 * such things will get caught most of the time, statistically
+	 * enough to be able to get a warning out.
+	 */
+	if (!READ_ONCE(*validp))
+		return;
+
+	if (!data_race(warned)) {
+		data_race(warned = true);
+		pr_warn("%sSRR0 was: %lx should be: %lx\n", h, srr0, regs->nip);
+		pr_warn("%sSRR1 was: %lx should be: %lx\n", h, srr1, regs->msr);
+		show_regs(regs);
+	}
+
+	WRITE_ONCE(*validp, 0); /* fixup */
+#endif
+}
+
+static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
+{
+#ifdef CONFIG_PPC64
+	irq_soft_mask_set(IRQS_ALL_DISABLED);
+
+	/*
+	 * If the interrupt was taken with HARD_DIS clear, then enable MSR[EE].
+	 * Asynchronous interrupts get here with HARD_DIS set (see below), so
+	 * this enables MSR[EE] for synchronous interrupts. IRQs remain
+	 * soft-masked. The interrupt handler may later call
+	 * interrupt_cond_local_irq_enable() to achieve a regular process
+	 * context.
+	 */
+	if (!(local_paca->irq_happened & PACA_IRQ_HARD_DIS)) {
+		INT_SOFT_MASK_BUG_ON(regs, !(regs->msr & MSR_EE));
+		__hard_irq_enable();
+	} else {
+		__hard_RI_enable();
+	}
+	/* Enable MSR[RI] early, to support kernel SLB and hash faults */
+#endif
+
+	if (!regs_irqs_disabled(regs))
+		trace_hardirqs_off();
+
+	if (user_mode(regs)) {
+		kuap_lock();
+		CT_WARN_ON(ct_state() != CT_STATE_USER);
+		user_exit_irqoff();
+
+		account_cpu_user_entry();
+		account_stolen_time();
+	} else {
+		kuap_save_and_lock(regs);
+		/*
+		 * CT_WARN_ON comes here via program_check_exception,
+		 * so avoid recursion.
+		 */
+		if (TRAP(regs) != INTERRUPT_PROGRAM)
+			CT_WARN_ON(ct_state() != CT_STATE_KERNEL &&
+				   ct_state() != CT_STATE_IDLE);
+		INT_SOFT_MASK_BUG_ON(regs, is_implicit_soft_masked(regs));
+		INT_SOFT_MASK_BUG_ON(regs, regs_irqs_disabled(regs) &&
+				     search_kernel_restart_table(regs->nip));
+	}
+	INT_SOFT_MASK_BUG_ON(regs, !regs_irqs_disabled(regs) &&
+			     !(regs->msr & MSR_EE));
+
+	booke_restore_dbcr0();
+}
+
+/*
+ * Care should be taken to note that arch_interrupt_exit_prepare and
+ * arch_interrupt_async_exit_prepare do not necessarily return immediately to
+ * regs context (e.g., if regs is usermode, we don't necessarily return to
+ * user mode). Other interrupts might be taken between here and return,
+ * context switch / preemption may occur in the exit path after this, or a
+ * signal may be delivered, etc.
+ *
+ * The real interrupt exit code is platform specific, e.g.,
+ * interrupt_exit_user_prepare / interrupt_exit_kernel_prepare for 64s.
+ *
+ * However arch_interrupt_nmi_exit_prepare does return directly to regs, because
+ * NMIs do not do "exit work" or replay soft-masked interrupts.
+ */
+static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
+{
+}
+
+static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
+{
+#ifdef CONFIG_PPC64
+	/* Ensure arch_interrupt_enter_prepare does not enable MSR[EE] */
+	local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
+#endif
+	arch_interrupt_enter_prepare(regs);
+#ifdef CONFIG_PPC_BOOK3S_64
+	/*
+	 * RI=1 is set by arch_interrupt_enter_prepare, so this thread flags access
+	 * has to come afterward (it can cause SLB faults).
+	 */
+	if (cpu_has_feature(CPU_FTR_CTRL) &&
+	    !test_thread_local_flags(_TLF_RUNLATCH))
+		__ppc64_runlatch_on();
+#endif
+	irq_enter();
+}
+
+static inline void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
+{
+	/*
+	 * Adjust at exit so the main handler sees the true NIA. This must
+	 * come before irq_exit() because irq_exit can enable interrupts, and
+	 * if another interrupt is taken before nap_adjust_return has run
+	 * here, then that interrupt would return directly to idle nap return.
+	 */
+	nap_adjust_return(regs);
+
+	irq_exit();
+	arch_interrupt_exit_prepare(regs);
+}
+
+struct interrupt_nmi_state {
+#ifdef CONFIG_PPC64
+	u8 irq_soft_mask;
+	u8 irq_happened;
+	u8 ftrace_enabled;
+	u64 softe;
+#endif
+};
+
+static inline bool nmi_disables_ftrace(struct pt_regs *regs)
+{
+	/* Allow DEC and PMI to be traced when they are soft-NMI */
+	if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) {
+		if (TRAP(regs) == INTERRUPT_DECREMENTER)
+			return false;
+		if (TRAP(regs) == INTERRUPT_PERFMON)
+			return false;
+	}
+	if (IS_ENABLED(CONFIG_PPC_BOOK3E_64)) {
+		if (TRAP(regs) == INTERRUPT_PERFMON)
+			return false;
+	}
+
+	return true;
+}
+
+static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
+					       struct interrupt_nmi_state *state)
+{
+#ifdef CONFIG_PPC64
+	state->irq_soft_mask = local_paca->irq_soft_mask;
+	state->irq_happened = local_paca->irq_happened;
+	state->softe = regs->softe;
+
+	/*
+	 * Set IRQS_ALL_DISABLED unconditionally so irqs_disabled() does
+	 * the right thing, and set IRQ_HARD_DIS. We do not want to reconcile
+	 * because that goes through irq tracing which we don't want in NMI.
+	 */
+	local_paca->irq_soft_mask = IRQS_ALL_DISABLED;
+	local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
+
+	if (!(regs->msr & MSR_EE) || is_implicit_soft_masked(regs)) {
+		/*
+		 * Adjust regs->softe to be soft-masked if it had not been
+		 * reconcied (e.g., interrupt entry with MSR[EE]=0 but softe
+		 * not yet set disabled), or if it was in an implicit soft
+		 * masked state. This makes regs_irqs_disabled(regs)
+		 * behave as expected.
+		 */
+		regs->softe = IRQS_ALL_DISABLED;
+	}
+
+	__hard_RI_enable();
+
+	/* Don't do any per-CPU operations until interrupt state is fixed */
+
+	if (nmi_disables_ftrace(regs)) {
+		state->ftrace_enabled = this_cpu_get_ftrace_enabled();
+		this_cpu_set_ftrace_enabled(0);
+	}
+#endif
+
+	/* If data relocations are enabled, it's safe to use nmi_enter() */
+	if (mfmsr() & MSR_DR) {
+		nmi_enter();
+		return;
+	}
+
+	/*
+	 * But do not use nmi_enter() for pseries hash guest taking a real-mode
+	 * NMI because not everything it touches is within the RMA limit.
+	 */
+	if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) &&
+	    firmware_has_feature(FW_FEATURE_LPAR) &&
+	    !radix_enabled())
+		return;
+
+	/*
+	 * Likewise, don't use it if we have some form of instrumentation (like
+	 * KASAN shadow) that is not safe to access in real mode (even on radix)
+	 */
+	if (IS_ENABLED(CONFIG_KASAN))
+		return;
+
+	/*
+	 * Likewise, do not use it in real mode if percpu first chunk is not
+	 * embedded. With CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK enabled there
+	 * are chances where percpu allocation can come from vmalloc area.
+	 */
+	if (percpu_first_chunk_is_paged)
+		return;
+
+	/* Otherwise, it should be safe to call it */
+	nmi_enter();
+}
+
+static inline void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
+					      struct interrupt_nmi_state *state)
+{
+	if (mfmsr() & MSR_DR) {
+		// nmi_exit if relocations are on
+		nmi_exit();
+	} else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) &&
+		   firmware_has_feature(FW_FEATURE_LPAR) &&
+		   !radix_enabled()) {
+		// no nmi_exit for a pseries hash guest taking a real mode exception
+	} else if (IS_ENABLED(CONFIG_KASAN)) {
+		// no nmi_exit for KASAN in real mode
+	} else if (percpu_first_chunk_is_paged) {
+		// no nmi_exit if percpu first chunk is not embedded
+	} else {
+		nmi_exit();
+	}
+
+	/*
+	 * nmi does not call nap_adjust_return because nmi should not create
+	 * new work to do (must use irq_work for that).
+	 */
+
+#ifdef CONFIG_PPC64
+#ifdef CONFIG_PPC_BOOK3S
+	if (regs_irqs_disabled(regs)) {
+		unsigned long rst = search_kernel_restart_table(regs->nip);
+
+		if (rst)
+			regs_set_return_ip(regs, rst);
+	}
+#endif
+
+	if (nmi_disables_ftrace(regs))
+		this_cpu_set_ftrace_enabled(state->ftrace_enabled);
+
+	/* Check we didn't change the pending interrupt mask. */
+	WARN_ON_ONCE((state->irq_happened | PACA_IRQ_HARD_DIS) != local_paca->irq_happened);
+	regs->softe = state->softe;
+	local_paca->irq_happened = state->irq_happened;
+	local_paca->irq_soft_mask = state->irq_soft_mask;
+#endif
+}
+
 static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
 {
 	if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
Signature · 1 line
2.51.0
#8 lore raw

PATCH 8/8 powerpc: Enable Generic Entry/Exit for syscalls.

In reply to Mukesh Kumar Chaurasiya

From: Mukesh Kumar Chaurasiya <[email protected]>

Convert the PowerPC syscall entry and exit paths to use the generic entry/exit framework by selecting GENERIC_ENTRY and integrating with the common syscall handling routines.

This change transitions PowerPC away from its custom syscall entry and exit code to use the generic helpers such as:
- syscall_enter_from_user_mode()
- syscall_exit_to_user_mode()

As part of this migration:
- The architecture now selects GENERIC_ENTRY in Kconfig.
- Old tracing, seccomp, and audit handling in ptrace.c is removed in favor of generic entry infrastructure.
- interrupt.c and syscall.c are simplified to delegate context management and user exit handling to the generic entry path.
- The new pt_regs field exit_flags introduced earlier is now used to carry per-syscall exit state flags (e.g. _TIF_RESTOREALL).

This aligns PowerPC with the common entry code used by other architectures and reduces duplicated logic around syscall tracing, context tracking, and signal handling.

The performance benchmarks from perf bench basic syscall are below:

| Metric     | W/O Generic Framework | With Generic Framework | Change |
| ---------- | --------------------- | ---------------------- | ------ |
| Total time | 0.939 [sec]           | 0.938 [sec]            | ~0%    |
| usecs/op   | 0.093900              | 0.093882               | ~0%    |
| ops/sec    | 1,06,49,615           | 1,06,51,725            | ~0%    |

Thats very close to performance earlier with arch specific handling.

---
 arch/powerpc/Kconfig                    |   1 +
 arch/powerpc/include/asm/entry-common.h |   2 +-
 arch/powerpc/kernel/interrupt.c         | 138 ++++++++---------------
 arch/powerpc/kernel/ptrace/ptrace.c     | 141 ------------------------
 arch/powerpc/kernel/signal.c            |  10 +-
 arch/powerpc/kernel/syscall.c           | 119 +-------------------
 6 files changed, 52 insertions(+), 359 deletions(-)
arch/powerpc/Kconfig +1 -0
index b0c602c3bbe1..a4330775b254 100644
@@ -203,6 +203,7 @@ config PPC
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES	if PPC_BARRIER_NOSPEC
 	select GENERIC_EARLY_IOREMAP
+	select GENERIC_ENTRY
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IOREMAP
arch/powerpc/include/asm/entry-common.h +1 -1
index e2ae7416dee1..466cfafc10ad 100644
@@ -3,7 +3,7 @@
 #ifndef _ASM_PPC_ENTRY_COMMON_H
 #define _ASM_PPC_ENTRY_COMMON_H
 
-#ifdef CONFIG_GENERIC_IRQ_ENTRY
+#ifdef CONFIG_GENERIC_ENTRY
 
 #include <asm/cputime.h>
 #include <asm/interrupt.h>
arch/powerpc/kernel/interrupt.c +45 -93

194 lines not on this page · raw message

arch/powerpc/kernel/ptrace/ptrace.c +0 -141

153 lines not on this page · raw message

arch/powerpc/kernel/signal.c +2 -8
index 719930cf4ae1..9f1847b4742e 100644
@@ -6,6 +6,7 @@
  *    Extracted from signal_32.c and signal_64.c
  */
 
+#include <linux/entry-common.h>
 #include <linux/resume_user_mode.h>
 #include <linux/signal.h>
 #include <linux/uprobes.h>
@@ -22,11 +23,6 @@
 
 #include "signal.h"
 
-/* This will be removed */
-#ifdef CONFIG_GENERIC_ENTRY
-#include <linux/entry-common.h>
-#endif /* CONFIG_GENERIC_ENTRY */
-
 #ifdef CONFIG_VSX
 unsigned long copy_fpr_to_user(void __user *to,
 			       struct task_struct *task)
@@ -374,11 +370,9 @@ void signal_fault(struct task_struct *tsk, struct pt_regs *regs,
 				   task_pid_nr(tsk), where, ptr, regs->nip, regs->link);
 }
 
-#ifdef CONFIG_GENERIC_ENTRY
 void arch_do_signal_or_restart(struct pt_regs *regs)
 {
 	BUG_ON(regs != current->thread.regs);
-	local_paca->generic_fw_flags |= GFW_RESTORE_ALL;
+	regs->exit_flags |= _TIF_RESTOREALL;
 	do_signal(current);
 }
-#endif /* CONFIG_GENERIC_ENTRY */
arch/powerpc/kernel/syscall.c +3 -116

133 lines not on this page · raw message

Signature · 1 line
2.51.0
#10 lore raw
In reply to Mukesh Kumar Chaurasiya
Quoted 15 lines · Mukesh Kumar Chaurasiya

Adding support for the generic irq entry/exit handling for PowerPC. The goal is to bring PowerPC in line with other architectures that already use the common irq entry infrastructure, reducing duplicated code and making it easier to share future changes in entry/exit paths.

This is slightly tested of ppc64le and ppc32.

The performance benchmarks from perf bench basic syscall are below:

| Metric     | W/O Generic Framework | With Generic Framework | Change |
| ---------- | --------------------- | ---------------------- | ------ |
| Total time | 0.939 [sec]           | 0.938 [sec]            | ~0%    |
| usecs/op   | 0.093900              | 0.093882               | ~0%    |
| ops/sec    | 1,06,49,615           | 1,06,51,725            | ~0%    |
Quoted 8 lines

Thats very close to performance earlier with arch specific handling.

Tests done:
- Build and boot on ppc64le pseries.
- Build and boot on ppc64le powernv8 powernv9 powernv10.
- Build and boot on ppc32.
- Performance benchmark done with perf syscall basic on pseries.

Hi Mukesh.

The context tracking is not correct.
too many warning when booted with nohz_full=<>

Did some fiddling, but no luck still in avoiding the warnings. Below helps to boot into atleast (less warning in comparison)

arch/powerpc/include/asm/entry-common.h +0 -9
index 466cfafc10ad..a66cafc94b5e 100644
@@ -217,20 +217,11 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
 
        if (user_mode(regs)) {
                kuap_lock();
-               CT_WARN_ON(ct_state() != CT_STATE_USER);
-               user_exit_irqoff();
 
                account_cpu_user_entry();
                account_stolen_time();
        } else {
                kuap_save_and_lock(regs);
-               /*
-                * CT_WARN_ON comes here via program_check_exception,
-                * so avoid recursion.
-                */
-               if (TRAP(regs) != INTERRUPT_PROGRAM)
-                       CT_WARN_ON(ct_state() != CT_STATE_KERNEL &&
-                                  ct_state() != CT_STATE_IDLE);
                INT_SOFT_MASK_BUG_ON(regs, is_implicit_soft_masked(regs));
                INT_SOFT_MASK_BUG_ON(regs, regs_irqs_disabled(regs) &&
                                     search_kernel_restart_table(regs->nip));
arch/powerpc/kernel/interrupt.c +25 -40

108 lines not on this page · raw message

arch/powerpc/kernel/syscall.c +3 -0
index df1c9a8d62bc..e041b187b1b7 100644
@@ -20,6 +20,9 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
        syscall_fn f;
 
        add_random_kstack_offset();
+
+       local_irq_disable();
+       user_enter_irqoff();
        r0 = syscall_enter_from_user_mode(regs, r0);
 
        if (unlikely(r0 >= NR_syscalls)) {
#9 lore raw

Re: [PATCH 8/8] powerpc: Enable Generic Entry/Exit for syscalls.

In reply to Mukesh Kumar Chaurasiya
kernel test robot noticed the following build errors:

Hi Mukesh,

kernel test robot noticed the following build errors:

[auto build test ERROR on powerpc/next]
[also build test ERROR on powerpc/fixes linus/master v6.18-rc4 next-20251107] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mukesh-Kumar-Chaurasiya/powerpc-rename-arch_irq_disabled_regs/20251102-195716
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link:    https://lore.kernel.org/r/20251102115358.1744304-9-mkchauras%40linux.ibm.com
patch subject: [PATCH 8/8] powerpc: Enable Generic Entry/Exit for syscalls.
config: powerpc-randconfig-002-20251108 (https://download.01.org/0day-ci/archive/20251108/[email protected]/config)
compiler: powerpc-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251108/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

powerpc-linux-ld: init/main.o: in function `do_one_initcall':

>> main.c:(.text+0x2418): undefined reference to `memcpy'
   powerpc-linux-ld: init/initramfs_test.o: in function `initramfs_test_many':
>> initramfs_test.c:(.init.text+0x130): undefined reference to `memset'
   powerpc-linux-ld: init/initramfs_test.o: in function `initramfs_test_hardlink':
   initramfs_test.c:(.init.text+0x5a0): undefined reference to `memset'
   powerpc-linux-ld: init/initramfs_test.o: in function `initramfs_test_csum':
   initramfs_test.c:(.init.text+0x1054): undefined reference to `memset'
   powerpc-linux-ld: init/initramfs_test.o: in function `initramfs_test_fname_overrun':
   initramfs_test.c:(.init.text+0x21dc): undefined reference to `memset'
   powerpc-linux-ld: init/initramfs_test.o: in function `initramfs_test_extract':
   initramfs_test.c:(.init.text+0x2798): undefined reference to `memset'
   powerpc-linux-ld: init/initramfs_test.o:initramfs_test.c:(.init.text+0x27a8): more undefined references to `memset' follow
   powerpc-linux-ld: arch/powerpc/kernel/process.o: in function `arch_dup_task_struct':
>> process.c:(.text+0x238c): undefined reference to `memcpy'
   powerpc-linux-ld: arch/powerpc/kernel/process.o: in function `copy_thread':
   process.c:(.text+0x2630): undefined reference to `memcpy'
   powerpc-linux-ld: arch/powerpc/kernel/signal.o: in function `do_signal':
>> signal.c:(.text+0xc0): undefined reference to `memset'
>> powerpc-linux-ld: signal.c:(.text+0x62c): undefined reference to `memset'
   powerpc-linux-ld: arch/powerpc/kernel/time.o: in function `register_decrementer_clockevent.constprop.0':
>> time.c:(.text+0xc00): undefined reference to `memcpy'
   powerpc-linux-ld: arch/powerpc/kernel/time.o: in function `rtc_init':
>> time.c:(.init.text+0x218): undefined reference to `memset'
   powerpc-linux-ld: arch/powerpc/mm/mem.o: in function `execmem_arch_setup':
>> mem.c:(.init.text+0x9ec): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o: in function `copy_clone_args_from_user':
>> fork.c:(.text+0x2f34): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o: in function `arch_dup_task_struct':
>> fork.c:(.text+0x4abc): undefined reference to `memcpy'
   powerpc-linux-ld: kernel/fork.o: in function `replace_mm_exe_file':
   fork.c:(.text+0x5664): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o: in function `create_io_thread':
   fork.c:(.text+0xbdc8): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o: in function `kernel_thread':
   fork.c:(.text+0xc894): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o: in function `user_mode_thread':
   fork.c:(.text+0xc998): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o: in function `sys_fork':
   fork.c:(.text+0xca6c): undefined reference to `memset'
   powerpc-linux-ld: kernel/fork.o:fork.c:(.text+0xcb14): more undefined references to `memset' follow
   powerpc-linux-ld: kernel/kallsyms.o: in function `__sprint_symbol.isra.0':
>> kallsyms.c:(.text+0x1c38): undefined reference to `memcpy'
   powerpc-linux-ld: kernel/acct.o: in function `acct_collect':
>> acct.c:(.text+0x29fc): undefined reference to `memset'
   powerpc-linux-ld: kernel/cgroup/cgroup.o: in function `features_show':
>> cgroup.c:(.text+0x5ca8): undefined reference to `memcpy'
   powerpc-linux-ld: kernel/trace/trace_events_synth.o: in function `print_synth_event':
>> trace_events_synth.c:(.text+0x347c): undefined reference to `memcpy'
   powerpc-linux-ld: kernel/trace/trace_events_hist.o: in function `hist_trigger_print_val':
>> trace_events_hist.c:(.text+0x1e02c): undefined reference to `memcpy'
   powerpc-linux-ld: kernel/events/core.o: in function `perf_event_namespaces.part.0':
>> core.c:(.text+0xd0d0): undefined reference to `memset'
   powerpc-linux-ld: kernel/events/core.o: in function `perf_event_addr_filters_apply':
   core.c:(.text+0xdc10): undefined reference to `memset'
   powerpc-linux-ld: kernel/events/core.o: in function `perf_event_alloc.part.0':
>> core.c:(.text+0x20450): undefined reference to `memcpy'
   powerpc-linux-ld: kernel/events/core.o: in function `perf_event_mmap':
   core.c:(.text+0x3d584): undefined reference to `memset'
   powerpc-linux-ld: mm/filemap.o: in function `filemap_invalidate_inode':
>> filemap.c:(.text+0x6c60): undefined reference to `memset'
   powerpc-linux-ld: mm/filemap.o: in function `__filemap_fdatawrite_range':
   filemap.c:(.text+0x1022c): undefined reference to `memset'
   powerpc-linux-ld: mm/filemap.o: in function `filemap_splice_read':
   filemap.c:(.text+0x1c0b8): undefined reference to `memset'
   powerpc-linux-ld: mm/oom_kill.o: in function `__oom_reap_task_mm':
>> oom_kill.c:(.text+0x47e8): undefined reference to `memset'
   powerpc-linux-ld: mm/page-writeback.o:page-writeback.c:(.text+0x6640): more undefined references to `memset' follow
   powerpc-linux-ld: fs/exec.o: in function `exec_test_bprm_stack_limits':
>> exec.c:(.text+0x1644): undefined reference to `memcpy'

powerpc-linux-ld: fs/ioctl.o: in function `ioctl_get_fs_sysfs_path':
ioctl.c:(.text+0x5b0): undefined reference to `memset'
powerpc-linux-ld: fs/readdir.o: in function `sys_getdents':
readdir.c:(.text+0x1d84): undefined reference to `memset'
powerpc-linux-ld: fs/readdir.o: in function `sys_getdents64':
readdir.c:(.text+0x20ec): undefined reference to `memset'
powerpc-linux-ld: fs/inode.o: in function `dump_mapping':
inode.c:(.text+0xe484): undefined reference to `memset'
powerpc-linux-ld: fs/seq_file.o: in function `seq_read':
seq_file.c:(.text+0x54f4): undefined reference to `memset'
powerpc-linux-ld: fs/fs-writeback.o:fs-writeback.c:(.text+0x1de74): more undefined references to `memset' follow
powerpc-linux-ld: fs/verity/hash_algs.o: in function `fsverity_hash_block':
hash_algs.c:(.text+0x808): undefined reference to `memcpy'
powerpc-linux-ld: fs/binfmt_misc.o: in function `bm_entry_read':
binfmt_misc.c:(.text+0x9f0): undefined reference to `memcpy'
powerpc-linux-ld: binfmt_misc.c:(.text+0xdbc): undefined reference to `memcpy'
powerpc-linux-ld: fs/binfmt_elf.o: in function `elf_core_dump':
binfmt_elf.c:(.text+0x88e8): undefined reference to `memset'
powerpc-linux-ld: fs/coredump.o: in function `dump_vma_snapshot':
coredump.c:(.text+0x1ff4): undefined reference to `memset'
powerpc-linux-ld: fs/coredump.o: in function `vfs_coredump':
coredump.c:(.text+0x5614): undefined reference to `memset'
powerpc-linux-ld: fs/iomap/buffered-io.o: in function `iomap_page_mkwrite':
buffered-io.c:(.text+0xbec): undefined reference to `memset'
powerpc-linux-ld: fs/iomap/buffered-io.o: in function `iomap_read_folio':
buffered-io.c:(.text+0x6608): undefined reference to `memset'
powerpc-linux-ld: fs/iomap/buffered-io.o:buffered-io.c:(.text+0x6ae0): more undefined references to `memset' follow
powerpc-linux-ld: crypto/sha512.o: in function `__crypto_sha512_export':
sha512.c:(.text+0x620): undefined reference to `memcpy'
powerpc-linux-ld: crypto/sha3_generic.o: in function `crypto_sha3_finup':
sha3_generic.c:(.text+0x1654): undefined reference to `memset'
powerpc-linux-ld: sha3_generic.c:(.text+0x17b8): undefined reference to `memset'
powerpc-linux-ld: crypto/drbg.o: in function `drbg_seed':
drbg.c:(.text+0x19ec): undefined reference to `memset'
powerpc-linux-ld: crypto/drbg.o: in function `drbg_kcapi_random':
drbg.c:(.text+0x2634): undefined reference to `memset'
powerpc-linux-ld: crypto/jitterentropy-kcapi.o: in function `jent_kcapi_cleanup':
jitterentropy-kcapi.c:(.text+0x118): undefined reference to `memset'
powerpc-linux-ld: crypto/jitterentropy-kcapi.o:jitterentropy-kcapi.c:(.text+0xc5c): more undefined references to `memset' follow
powerpc-linux-ld: block/elevator.o: in function `elv_iosched_show':
elevator.c:(.text+0x50fc): undefined reference to `memcpy'
powerpc-linux-ld: elevator.c:(.text+0x5274): undefined reference to `memcpy'
powerpc-linux-ld: elevator.c:(.text+0x52cc): undefined reference to `memcpy'
powerpc-linux-ld: block/blk-core.o: in function `blk_alloc_queue':
blk-core.c:(.text+0xe6d4): undefined reference to `memcpy'
powerpc-linux-ld: block/blk-sysfs.o: in function `queue_attr_store':
blk-sysfs.c:(.text+0x3d90): undefined reference to `memcpy'
powerpc-linux-ld: block/blk-settings.o:blk-settings.c:(.text+0x216c): more undefined references to `memcpy' follow
powerpc-linux-ld: block/blk-mq.o: in function `blk_mq_alloc_queue':
blk-mq.c:(.text+0x27528): undefined reference to `memset'
powerpc-linux-ld: block/genhd.o: in function `__blk_alloc_disk':
genhd.c:(.text+0x6ea4): undefined reference to `memset'
powerpc-linux-ld: block/partitions/core.o: in function `check_partition':
core.c:(.text+0x1b20): undefined reference to `memcpy'
powerpc-linux-ld: block/blk-rq-qos.o: in function `rq_qos_wait':
blk-rq-qos.c:(.text+0x1598): undefined reference to `memset'
powerpc-linux-ld: block/disk-events.o: in function `disk_events_show':
disk-events.c:(.text+0x17c): undefined reference to `memcpy'
powerpc-linux-ld: block/disk-events.o: in function `disk_events_poll_msecs_show':
disk-events.c:(.text+0xd8c): undefined reference to `memcpy'
powerpc-linux-ld: block/blk-cgroup.o: in function `__blkg_clear_stat':
blk-cgroup.c:(.text+0x52b0): undefined reference to `memset'
powerpc-linux-ld: block/blk-cgroup-rwstat.o: in function `blkg_prfill_rwstat':
blk-cgroup-rwstat.c:(.text+0x430): undefined reference to `memset'
powerpc-linux-ld: block/blk-integrity.o: in function `flag_store':
blk-integrity.c:(.text+0x1050): undefined reference to `memcpy'
powerpc-linux-ld: blk-integrity.c:(.text+0x1060): undefined reference to `memcpy'
powerpc-linux-ld: block/sed-opal.o: in function `sed_ioctl':
sed-opal.c:(.text+0x10340): undefined reference to `memcpy'
powerpc-linux-ld: sed-opal.c:(.text+0x11810): undefined reference to `memset'
powerpc-linux-ld: io_uring/io_uring.o: in function `sys_io_uring_enter':
io_uring.c:(.text+0x25670): undefined reference to `memset'
powerpc-linux-ld: io_uring/msg_ring.o: in function `io_uring_sync_msg_ring':
msg_ring.c:(.text+0x2068): undefined reference to `memset'
powerpc-linux-ld: io_uring/register.o: in function `io_register_resize_rings':
register.c:(.text+0xc4): undefined reference to `memset'
powerpc-linux-ld: register.c:(.text+0xd4): undefined reference to `memset'
powerpc-linux-ld: lib/kunit/test.o:test.c:(.text+0x1f04): more undefined references to `memset' follow
powerpc-linux-ld: lib/lz4/lz4_decompress.o: in function `LZ4_decompress_safe_partial':
lz4_decompress.c:(.text+0xa60): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0xb00): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0xb10): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0xc1c): undefined reference to `memmove'
powerpc-linux-ld: lz4_decompress.c:(.text+0xc94): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0x1288): undefined reference to `memmove'
powerpc-linux-ld: lib/lz4/lz4_decompress.o: in function `LZ4_decompress_safe':
lz4_decompress.c:(.text+0x15c4): undefined reference to `memmove'
powerpc-linux-ld: lz4_decompress.c:(.text+0x1664): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0x1700): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0x1710): undefined reference to `memcpy'
powerpc-linux-ld: lib/lz4/lz4_decompress.o: in function `LZ4_decompress_fast':
lz4_decompress.c:(.text+0x2a40): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0x2ae4): undefined reference to `memcpy'
powerpc-linux-ld: lib/lz4/lz4_decompress.o:lz4_decompress.c:(.text+0x2af4): more undefined references to `memcpy' follow
powerpc-linux-ld: lib/lz4/lz4_decompress.o: in function `LZ4_decompress_fast':
lz4_decompress.c:(.text+0x2c48): undefined reference to `memmove'
powerpc-linux-ld: lib/lz4/lz4_decompress.o: in function `LZ4_decompress_safe_withPrefix64k':
lz4_decompress.c:(.text+0x4744): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0x47d4): undefined reference to `memcpy'
powerpc-linux-ld: lz4_decompress.c:(.text+0x47e4): undefined reference to `memcpy'

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Tested-by on the v1 series
#13 lore raw
In reply to Mukesh Kumar Chaurasiya
Quoted 59 lines · Mukesh Kumar Chaurasiya

Adding support for the generic irq entry/exit handling for PowerPC. The goal is to bring PowerPC in line with other architectures that already use the common irq entry infrastructure, reducing duplicated code and making it easier to share future changes in entry/exit paths.

This is slightly tested of ppc64le and ppc32.

The performance benchmarks from perf bench basic syscall are below:

| Metric     | W/O Generic Framework | With Generic Framework | Change |
| ---------- | --------------------- | ---------------------- | ------ |
| Total time | 0.939 [sec]           | 0.938 [sec]            | ~0%    |
| usecs/op   | 0.093900              | 0.093882               | ~0%    |
| ops/sec    | 1,06,49,615           | 1,06,51,725            | ~0%    |

Thats very close to performance earlier with arch specific handling.

Tests done:
- Build and boot on ppc64le pseries.
- Build and boot on ppc64le powernv8 powernv9 powernv10.
- Build and boot on ppc32.
- Performance benchmark done with perf syscall basic on pseries.

Changelog:

RFC -> PATCH
- Fix for ppc32 spitting out kuap lock warnings.
- ppc64le powernv8 crash fix.
- Review comments incorporated from previous RFC.
RFChttps://lore.kernel.org/all/[email protected]/

Mukesh Kumar Chaurasiya (8):
powerpc: rename arch_irq_disabled_regs
powerpc: Prepare to build with generic entry/exit framework
powerpc: introduce arch_enter_from_user_mode
powerpc: Introduce syscall exit arch functions
powerpc: add exit_flags field in pt_regs
powerpc: Prepare for IRQ entry exit
powerpc: Enable IRQ generic entry/exit path.
powerpc: Enable Generic Entry/Exit for syscalls.

  arch/powerpc/Kconfig                    |   2 +
  arch/powerpc/include/asm/entry-common.h | 539 ++++++++++++++++++++++++
  arch/powerpc/include/asm/hw_irq.h       |   4 +-
  arch/powerpc/include/asm/interrupt.h    | 401 +++---------------
  arch/powerpc/include/asm/ptrace.h       |   3 +
  arch/powerpc/include/asm/stacktrace.h   |   6 +
  arch/powerpc/include/asm/syscall.h      |   5 +
  arch/powerpc/include/asm/thread_info.h  |   1 +
  arch/powerpc/include/uapi/asm/ptrace.h  |  14 +-
  arch/powerpc/kernel/asm-offsets.c       |   1 +
  arch/powerpc/kernel/interrupt.c         | 258 +++---------
  arch/powerpc/kernel/ptrace/ptrace.c     | 142 +------
  arch/powerpc/kernel/signal.c            |   8 +
  arch/powerpc/kernel/syscall.c           | 119 +-----
  arch/powerpc/kernel/traps.c             |   2 +-
  arch/powerpc/kernel/watchdog.c          |   2 +-
  arch/powerpc/perf/core-book3s.c         |   2 +-
  17 files changed, 693 insertions(+), 816 deletions(-)
Quoted 2 lines

create mode 100644 arch/powerpc/include/asm/entry-common.h

Hi,

I have reviewed and tested the generic IRQ entry/exist patch series. Below are my observations:


Test Coverage

• Successfully ran LTP (specially syscall) and entire LTP test suite, without observing any regressions or issues related to the implementation.


System Configuration

• CPUs: 160

• Kernel: v6.18.0-rc1+

• Processor mode: Shared (uncapped)


Performance Evaluation

• Conducted benchmarking using perf bench syscall basic -l and hackbench.

• No functional regressions observed, and results were consistent with expectations.

* Results for perf bench syscall**Loops = 100,000**

**Loops = 100,000**

| Metric       | W/O Generic Framework      | With Generic Framework    | Improvement |
|----------|-----------------------:|-----------------------:|------------:|
| usecs/op   |              0.125328              | 0.128839              |     ~-2.80% |
| ops/sec     |             7,979,645              |  7,762,047              |     ~-2.73% |

**Loops = 1,000,000**

| Metric        | W/O Generic Framework         | With Generic Framework             | Improvement |
|----------|-----------------------:|-----------------------:|------------:|
| usecs/op   |              0.125015              | 0.127885              |     ~-2.30% |
| ops/sec     |             7,999,051              |  7,819,546              |     ~-2.24% |

**Loops = 10,000,000**

| Metric        | W/O Generic Framework    | With Generic Framework    | Improvement |
|----------|-----------------------:|-----------------------:|------------:|
| usecs/op   |              0.124613              | 0.127426              |     ~-2.26% |
| ops/sec     |             8,024,827              |  7,847,735              |     ~-2.21% |

**Overall (aggregated across all runs)**

| Metric         | W/O Generic Framework   | With Generic Framework    | Improvement |
| ---------- | ---------------------:|-----------------------:|------------:|
| Total time    |           1.384 [sec]            |           1.415 [sec]               |     ~-2.27% |
| usecs/op     |              0.124656            | 0.127480              |     ~-2.27% |
| ops/sec       |             8,022,098            |  7,844,423              |     ~-2.21% |

A 2% performance degradation was observed with the perf bench syscall.

* Results for hackbench

| Metric        | W/O Generic Framework    | With Generic Framework   | Improvement |
|----------|---------------------- :|-----------------------:|------------:|
| Min Time   | 142.055 (sec).                   | 141.699 (sec)                | 0.25%
| Max Time  | 143.791 (sec).                   | 143.206 (sec)                | 0.41%
| Avg Time   | 142.925 (sec)                    | 142.472 (sec)                | 0.32%

So overall 0.3 % improvement is observed across 10 runs.

Please add below tag for the patch set.

Thank You !!

Regards,
Samir.

Tested-by on the v1 series
#14 lore raw
In reply to Mukesh Kumar Chaurasiya
Quoted 59 lines · Mukesh Kumar Chaurasiya

Adding support for the generic irq entry/exit handling for PowerPC. The goal is to bring PowerPC in line with other architectures that already use the common irq entry infrastructure, reducing duplicated code and making it easier to share future changes in entry/exit paths.

This is slightly tested of ppc64le and ppc32.

The performance benchmarks from perf bench basic syscall are below:

| Metric     | W/O Generic Framework | With Generic Framework | Change |
| ---------- | --------------------- | ---------------------- | ------ |
| Total time | 0.939 [sec]           | 0.938 [sec]            | ~0%    |
| usecs/op   | 0.093900              | 0.093882               | ~0%    |
| ops/sec    | 1,06,49,615           | 1,06,51,725            | ~0%    |

Thats very close to performance earlier with arch specific handling.

Tests done:
- Build and boot on ppc64le pseries.
- Build and boot on ppc64le powernv8 powernv9 powernv10.
- Build and boot on ppc32.
- Performance benchmark done with perf syscall basic on pseries.

Changelog:

RFC -> PATCH
- Fix for ppc32 spitting out kuap lock warnings.
- ppc64le powernv8 crash fix.
- Review comments incorporated from previous RFC.
RFC https://lore.kernel.org/all/[email protected]/

Mukesh Kumar Chaurasiya (8):
powerpc: rename arch_irq_disabled_regs
powerpc: Prepare to build with generic entry/exit framework
powerpc: introduce arch_enter_from_user_mode
powerpc: Introduce syscall exit arch functions
powerpc: add exit_flags field in pt_regs
powerpc: Prepare for IRQ entry exit
powerpc: Enable IRQ generic entry/exit path.
powerpc: Enable Generic Entry/Exit for syscalls.

  arch/powerpc/Kconfig                    |   2 +
  arch/powerpc/include/asm/entry-common.h | 539 ++++++++++++++++++++++++
  arch/powerpc/include/asm/hw_irq.h       |   4 +-
  arch/powerpc/include/asm/interrupt.h    | 401 +++---------------
  arch/powerpc/include/asm/ptrace.h       |   3 +
  arch/powerpc/include/asm/stacktrace.h   |   6 +
  arch/powerpc/include/asm/syscall.h      |   5 +
  arch/powerpc/include/asm/thread_info.h  |   1 +
  arch/powerpc/include/uapi/asm/ptrace.h  |  14 +-
  arch/powerpc/kernel/asm-offsets.c       |   1 +
  arch/powerpc/kernel/interrupt.c         | 258 +++---------
  arch/powerpc/kernel/ptrace/ptrace.c     | 142 +------
  arch/powerpc/kernel/signal.c            |   8 +
  arch/powerpc/kernel/syscall.c           | 119 +-----
  arch/powerpc/kernel/traps.c             |   2 +-
  arch/powerpc/kernel/watchdog.c          |   2 +-
  arch/powerpc/perf/core-book3s.c         |   2 +-
  17 files changed, 693 insertions(+), 816 deletions(-)
Quoted 2 lines

create mode 100644 arch/powerpc/include/asm/entry-common.h

Hi,

I have reviewed and tested the generic IRQ entry/exist patch series. Below are my observations:


Test Coverage
• Successfully ran LTP (specially syscall) and entire LTP test suite, without observing any regressions or issues related to the implementation.


System Configuration
• CPUs: 160
• Kernel: v6.18.0-rc1+
• Processor mode: Shared (uncapped)


Performance Evaluation
• Conducted benchmarking using perf bench syscall basic -l and hackbench.
• No functional regressions observed, and results were consistent with expectations.

    •    Results for perf bench syscall**Loops = 100,000** **Loops = 100,000**

| Metric       | W/O Generic Framework      | With Generic Framework    | Improvement |
|----------|-----------------------:|-----------------------:|------------:|
| usecs/op   |              0.125328              | 0.128839              |     ~-2.80% |
| ops/sec     |             7,979,645              |  7,762,047              |     ~-2.73% |

**Loops = 1,000,000**

| Metric        | W/O Generic Framework         | With Generic Framework             | Improvement |
|----------|-----------------------:|-----------------------:|------------:|
| usecs/op   |              0.125015              | 0.127885              |     ~-2.30% |
| ops/sec     |             7,999,051              |  7,819,546              |     ~-2.24% |

**Loops = 10,000,000**

| Metric        | W/O Generic Framework    | With Generic Framework    | Improvement |
|----------|-----------------------:|-----------------------:|------------:|
| usecs/op   |              0.124613              | 0.127426              |     ~-2.26% |
| ops/sec     |             8,024,827              |  7,847,735              |     ~-2.21% |

**Overall (aggregated across all runs)**

| Metric         | W/O Generic Framework   | With Generic Framework    | Improvement |
| ---------- | ---------------------:|-----------------------:|------------:|
| Total time    |           1.384 [sec]            |           1.415 [sec]               |     ~-2.27% |
| usecs/op     |              0.124656            | 0.127480              |     ~-2.27% |
| ops/sec       |             8,022,098            |  7,844,423              |     ~-2.21% |

A 2% performance degradation was observed with the perf bench syscall.

    •    Results for hackbench

| Metric        | W/O Generic Framework    | With Generic Framework   | Improvement |
|----------|---------------------- :|-----------------------:|------------:|
| Min Time   | 142.055 (sec).                   | 141.699 (sec)                | 0.25%
| Max Time  | 143.791 (sec).                   | 143.206 (sec)                | 0.41%
| Avg Time   | 142.925 (sec)                    | 142.472 (sec)                | 0.32%

So overall 0.3 % improvement is observed across 10 runs.

Please add below tag for the patch set.

Thank You !!

Regards,
Samir.

Tested-by
#15 lore raw
Quoted 120 lines · Samir M
Quoted 58 lines · Mukesh Kumar Chaurasiya

Adding support for the generic irq entry/exit handling for PowerPC. The goal is to bring PowerPC in line with other architectures that already use the common irq entry infrastructure, reducing duplicated code and making it easier to share future changes in entry/exit paths.

This is slightly tested of ppc64le and ppc32.

The performance benchmarks from perf bench basic syscall are below:

| Metric     | W/O Generic Framework | With Generic Framework | Change |
| ---------- | --------------------- | ---------------------- | ------ |
| Total time | 0.939 [sec]           | 0.938 [sec]            | ~0%    |
| usecs/op   | 0.093900              | 0.093882               | ~0%    |
| ops/sec    | 1,06,49,615           | 1,06,51,725            | ~0%    |

Thats very close to performance earlier with arch specific handling.

Tests done:
  - Build and boot on ppc64le pseries.
  - Build and boot on ppc64le powernv8 powernv9 powernv10.
  - Build and boot on ppc32.
  - Performance benchmark done with perf syscall basic on pseries.

Changelog:

RFC -> PATCH
  - Fix for ppc32 spitting out kuap lock warnings.
  - ppc64le powernv8 crash fix.
  - Review comments incorporated from previous RFC.
RFC https://lore.kernel.org/all/[email protected]/

Mukesh Kumar Chaurasiya (8):
   powerpc: rename arch_irq_disabled_regs
   powerpc: Prepare to build with generic entry/exit framework
   powerpc: introduce arch_enter_from_user_mode
   powerpc: Introduce syscall exit arch functions
   powerpc: add exit_flags field in pt_regs
   powerpc: Prepare for IRQ entry exit
   powerpc: Enable IRQ generic entry/exit path.
   powerpc: Enable Generic Entry/Exit for syscalls.

  arch/powerpc/Kconfig                    |   2 + arch/powerpc/include/asm/entry-common.h | 539 ++++++++++++++++++++++++ arch/powerpc/include/asm/hw_irq.h       |   4 +- arch/powerpc/include/asm/interrupt.h    | 401 +++--------------- arch/powerpc/include/asm/ptrace.h       |   3 + arch/powerpc/include/asm/stacktrace.h   |   6 + arch/powerpc/include/asm/syscall.h      |   5 + arch/powerpc/include/asm/thread_info.h  |   1 + arch/powerpc/include/uapi/asm/ptrace.h  |  14 +- arch/powerpc/kernel/asm-offsets.c       |   1 + arch/powerpc/kernel/interrupt.c         | 258 +++--------- arch/powerpc/kernel/ptrace/ptrace.c     | 142 +------ arch/powerpc/kernel/signal.c            |   8 + arch/powerpc/kernel/syscall.c           | 119 +----- arch/powerpc/kernel/traps.c             |   2 +- arch/powerpc/kernel/watchdog.c          |   2 +- arch/powerpc/perf/core-book3s.c         |   2 +-

Quoted 3 lines
  17 files changed, 693 insertions(+), 816 deletions(-)

  create mode 100644 arch/powerpc/include/asm/entry-common.h

Hi,

I have reviewed and tested the generic IRQ entry/exist patch series. Below are my observations:


Test Coverage
• Successfully ran LTP (specially syscall) and entire LTP test suite, without observing any regressions or issues related to the implementation.


System Configuration
• CPUs: 160
• Kernel: v6.18.0-rc1+
• Processor mode: Shared (uncapped)


Performance Evaluation
• Conducted benchmarking using perf bench syscall basic -l and hackbench.
• No functional regressions observed, and results were consistent with expectations.

    •    Results for perf bench syscall**Loops = 100,000** **Loops = 100,000**

| Metric       | W/O Generic Framework      | With Generic Framework    | Improvement |
|----------|-----------------------:|-----------------------:|------------:| 
| usecs/op   |              0.125328              | 0.128839         |     ~-2.80% |
| ops/sec     |             7,979,645              |  7,762,047           |     ~-2.73% |

**Loops = 1,000,000**

| Metric        | W/O Generic Framework         | With Generic Framework             | Improvement |
|----------|-----------------------:|-----------------------:|------------:| 
| usecs/op   |              0.125015              | 0.127885         |     ~-2.30% |
| ops/sec     |             7,999,051              |  7,819,546           |     ~-2.24% |

**Loops = 10,000,000**

| Metric        | W/O Generic Framework    | With Generic Framework    | Improvement |
|----------|-----------------------:|-----------------------:|------------:| 
| usecs/op   |              0.124613              | 0.127426         |     ~-2.26% |
| ops/sec     |             8,024,827              |  7,847,735           |     ~-2.21% |

**Overall (aggregated across all runs)**

| Metric         | W/O Generic Framework   | With Generic Framework    | Improvement |
| ---------- | 
---------------------:|-----------------------:|------------:|
| Total time    |           1.384 [sec]            |  1.415 [sec]               |     ~-2.27% |
| usecs/op     |              0.124656            | 0.127480         |     ~-2.27% |
| ops/sec       |             8,022,098            |  7,844,423           |     ~-2.21% |

A 2% performance degradation was observed with the perf bench syscall.

    •    Results for hackbench

| Metric        | W/O Generic Framework    | With Generic Framework   | Improvement |
|----------|---------------------- :|-----------------------:|------------:|
| Min Time   | 142.055 (sec).                   | 141.699 (sec)              | 0.25%
| Max Time  | 143.791 (sec).                   | 143.206 (sec)            | 0.41%
| Avg Time   | 142.925 (sec)                    | 142.472 (sec)              | 0.32%

So overall 0.3 % improvement is observed across 10 runs.

Quoted 8 lines

Please add below tag for the patch set.

Thank You !!

Regards,
Samir.

Hi,

Apologies for the earlier email. The benchmark results table was not properly formatted in that version, so I am re-sending the results below for clarity.

I have reviewed and tested the generic IRQ entry/exist patch series. Below are my observations:


Test Coverage
• Successfully ran LTP (specially syscall) and entire LTP test suite, without observing any regressions or issues related to the implementation.


System Configuration
• CPUs: 160
• Kernel: v6.18.0-rc1+
• Processor mode: Shared (uncapped)


Performance Evaluation
• Conducted benchmarking using perf bench syscall basic -l and hackbench.
• No functional regressions observed, and results were consistent with expectations.

    •    Results for perf bench syscall

Loops = 100,000

+-----------+------------------------+------------------------+------------+
| Metric      | W/O Generic Framework     | With Generic Framework    | Improvement |
+-----------+------------------------+------------------------+------------+
| usecs/op  |           0.125328                 |  0.128839                   | ~-2.80%     |
| ops/sec    |            7,979,645               |  7,762,047                  | ~-2.73%     |
+-----------+------------------------+------------------------+------------+

Loops = 1,000,000

+-----------+------------------------+------------------------+------------+
| Metric      | W/O Generic Framework  | With Generic Framework | Improvement |
+-----------+------------------------+------------------------+------------+
| usecs/op  |          0.125015               |        0.127885                 | ~-2.30%     |
| ops/sec    |          7,999,051              |        7,819,546                  | ~-2.24%     |
+-----------+------------------------+------------------------+------------+

Loops = 10,000,000

+-----------+------------------------+------------------------+------------+
| Metric      | W/O Generic Framework  | With Generic Framework  | Improvement |
+-----------+------------------------+------------------------+------------+
| usecs/op  |         0.124613                |        0.127426                 | ~-2.26%     |
| ops/sec    |         8,024,827               |        7,847,735                  | ~-2.21%     |
+-----------+------------------------+------------------------+------------+

Overall (aggregated across all runs)

+-------------+------------------------+------------------------+----------+
| Metric         | W/O Generic Framework  | With Generic Framework | Improvement |
+-------------+------------------------+------------------------+----------+
| Total time   |        1.384 [sec]               |         1.415 [sec]                | ~-2.27%     |
| usecs/op     |        0.124656                 | 0.127480                   | ~-2.27%     |
| ops/sec       |        8,022,098                | 7,844,423                  | ~-2.21%     |
+-------------+------------------------+------------------------+----------+

A 2% performance degradation was observed with the perf bench syscall.

    •    Results for hackbench

+-----------+---------------------------+---------------------------+------+
| Metric        | W/O Generic Framework     | With Generic Framework    | Improvement |
+-----------+---------------------------+---------------------------+------+
| Min Time  |    142.055 (sec)                     |       141.699 (sec)             |  +0.25%      |
| Max Time  |   143.791 (sec)                     |       143.206 (sec)              |  +0.41%      |
| Avg Time  |   142.925 (sec)                      |      142.472 (sec)              |  +0.32%      |
+-----------+---------------------------+---------------------------+------+

So overall 0.3 % improvement is observed across 10 runs.

Please add below tag for the patch set.

Thank You !!

Regards,
Samir.

#11 lore raw
In reply to Shrikanth Hegde
Quoted 19 lines · Shrikanth Hegde

On 11/2/25 5:23 PM, Mukesh Kumar Chaurasiya wrote:

arch/powerpc/kernel/interrupt.c +3 -5
index ce59431f977c..c7cf9a3f1202 100644
@@ -118,16 +118,18 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
                 regs->exit_flags |= _TIF_RESTOREALL;
         }
 
-again:
+       local_irq_disable();
+
+       user_exit_irqoff();
         syscall_exit_to_user_mode(regs);
 
-       user_enter_irqoff();
-       if (!prep_irq_for_enabled_exit(true)) {
-               user_exit_irqoff();
-               local_irq_enable();

arch/powerpc/kernel/interrupt.c notrace unsigned long syscall_exit_prepare(unsigned long r3, · line 132

Quoted 10 lines
arch/powerpc/kernel/interrupt.c +7 -3
-               local_irq_disable();
-               goto again;
-       }
+again:
+       if (!prep_irq_for_enabled_exit(true)) {
+               local_irq_enable();
+               local_irq_disable();
+               goto again;
+       }
+

This does not look right at all.

          syscall_exit_to_user_mode(regs)
                syscall_exit_to_user_mode_work()
                exit_to_user_mode()
                   user_exit_irqoff()

What you really want to do here is:

again:

	syscall_exit_to_user_mode_work(regs);
 
	exit_to_user_mode(regs);
 	if (!prep_irq_for_enabled_exit(true)) {
        	// Re-establishes the full state required
                // to restart
		enter_from_user_mode(regs);

local_irq_enable();
local_irq_disable();
goto again;

That should cure it. Same issue in the other places.

Thanks,

tglx

#12 lore raw
Quoted 32 lines · Thomas Gleixner
Quoted 19 lines · Shrikanth Hegde

On 11/2/25 5:23 PM, Mukesh Kumar Chaurasiya wrote:

arch/powerpc/kernel/interrupt.c +3 -5
index ce59431f977c..c7cf9a3f1202 100644
@@ -118,16 +118,18 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
                  regs->exit_flags |= _TIF_RESTOREALL;
          }
 
-again:
+       local_irq_disable();
+
+       user_exit_irqoff();
          syscall_exit_to_user_mode(regs);
 
-       user_enter_irqoff();
-       if (!prep_irq_for_enabled_exit(true)) {
-               user_exit_irqoff();
-               local_irq_enable();

arch/powerpc/kernel/interrupt.c notrace unsigned long syscall_exit_prepare(unsigned long r3, · line 132

Quoted 10 lines
arch/powerpc/kernel/interrupt.c +7 -3
-               local_irq_disable();
-               goto again;
-       }
+again:
+       if (!prep_irq_for_enabled_exit(true)) {
+               local_irq_enable();
+               local_irq_disable();
+               goto again;
+       }
+

This does not look right at all.

Quoted 4 lines
           syscall_exit_to_user_mode(regs)
                 syscall_exit_to_user_mode_work()
                 exit_to_user_mode()
                    user_exit_irqoff()

yeah we also found an issue with context tracking here. I am working on fixing it.

Quoted 11 lines

What you really want to do here is:

again:

	syscall_exit_to_user_mode_work(regs);
  
	exit_to_user_mode(regs);
  	if (!prep_irq_for_enabled_exit(true)) {
         	// Re-establishes the full state required
                 // to restart
		enter_from_user_mode(regs);
Quoted 5 lines

local_irq_enable();
local_irq_disable();
goto again;

That should cure it. Same issue in the other places.

This helps. Let me try this and i'll send a new version out as soon as we are done with testing.

Quoted 3 lines

Thanks,

tglx

Thanks for the review.

Regards,

Mukesh