From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Mukesh Kumar Chaurasiya <mkchauras@linux.ibm.com>,
maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
oleg@redhat.com, kees@kernel.org, luto@amacapital.net,
wad@chromium.org, mchauras@linux.ibm.com, thuth@redhat.com,
sshegde@linux.ibm.com, charlie@rivosinc.com, macro@orcam.me.uk,
akpm@linux-foundation.org, ldv@strace.io, deller@gmx.de,
ankur.a.arora@oracle.com, segher@kernel.crashing.org,
tglx@linutronix.de, thomas.weissschuh@linutronix.de,
peterz@infradead.org, menglong8.dong@gmail.com,
bigeasy@linutronix.de, namcao@linutronix.de,
kan.liang@linux.intel.com, mingo@kernel.org,
atrajeev@linux.vnet.ibm.com, mark.barnett@arm.com,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/8] powerpc: Enable IRQ generic entry/exit path.
Date: Tue, 16 Dec 2025 11:43:02 +0100 [thread overview]
Message-ID: <3de95000-19ce-499e-b6b6-7e207c02c73c@kernel.org> (raw)
In-Reply-To: <20251214130245.43664-8-mkchauras@linux.ibm.com>
Le 14/12/2025 à 14:02, Mukesh Kumar Chaurasiya a écrit :
> From: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
>
> 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.
Did you look into resulting code ?
do_IRQ() is bigger and calls irqentry_enter() which is bigger than
irq_enter().
And irq_enter_rcu() was tail-called from irq_enter(), now is it called
after irqentry_enter().
>
> Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
> ---
> 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(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index e24f4d88885a..b0c602c3bbe1 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -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
> diff --git a/arch/powerpc/include/asm/entry-common.h b/arch/powerpc/include/asm/entry-common.h
> index e8bde4c67eaf..e2ae7416dee1 100644
> --- a/arch/powerpc/include/asm/entry-common.h
> +++ b/arch/powerpc/include/asm/entry-common.h
> @@ -257,6 +257,17 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
> */
> static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
> {
> + if (user_mode(regs)) {
> + BUG_ON(regs_is_unrecoverable(regs));
> + BUG_ON(regs_irqs_disabled(regs));
> + /*
> + * We don't need to restore AMR on the way back to userspace for KUAP.
> + * AMR can only have been unlocked if we interrupted the kernel.
> + */
> + kuap_assert_locked();
> +
> + local_irq_disable();
> + }
> }
>
> static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
> @@ -275,7 +286,6 @@ static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
> !test_thread_local_flags(_TLF_RUNLATCH))
> __ppc64_runlatch_on();
> #endif
> - irq_enter();
> }
>
> static inline void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
> @@ -288,7 +298,6 @@ static inline void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
> */
> nap_adjust_return(regs);
>
> - irq_exit();
> arch_interrupt_exit_prepare(regs);
> }
>
> @@ -354,59 +363,11 @@ static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,
> 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).
> @@ -435,6 +396,8 @@ static inline void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,
>
> static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
> {
> + kuap_lock();
> +
A reason why this change comes now and not in the patch that added
arch_enter_from_user_mode() ?
> if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
> BUG_ON(irq_soft_mask_return() != IRQS_ALL_DISABLED);
>
> @@ -467,11 +430,8 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
> } else
> #endif
> kuap_assert_locked();
> -
> booke_restore_dbcr0();
> -
This is cosmetic, should have been done when adding
arch_enter_from_user_mode()
> account_cpu_user_entry();
> -
> account_stolen_time();
>
> /*
Christophe
next prev parent reply other threads:[~2025-12-16 10:43 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-14 13:02 [PATCH v2 0/8] Generic IRQ entry/exit support for powerpc Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 1/8] powerpc: rename arch_irq_disabled_regs Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 2/8] powerpc: Prepare to build with generic entry/exit framework Mukesh Kumar Chaurasiya
2025-12-16 9:27 ` Christophe Leroy (CS GROUP)
2025-12-16 14:42 ` Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 3/8] powerpc: introduce arch_enter_from_user_mode Mukesh Kumar Chaurasiya
2025-12-16 9:38 ` Christophe Leroy (CS GROUP)
2025-12-16 14:47 ` Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 4/8] powerpc: Introduce syscall exit arch functions Mukesh Kumar Chaurasiya
2025-12-16 9:46 ` Christophe Leroy (CS GROUP)
2025-12-16 14:51 ` Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 5/8] powerpc: add exit_flags field in pt_regs Mukesh Kumar Chaurasiya
2025-12-16 9:52 ` Christophe Leroy (CS GROUP)
2025-12-16 14:56 ` Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 6/8] powerpc: Prepare for IRQ entry exit Mukesh Kumar Chaurasiya
2025-12-16 9:58 ` Christophe Leroy (CS GROUP)
2025-12-16 15:00 ` Mukesh Kumar Chaurasiya
2025-12-16 22:40 ` Christophe Leroy (CS GROUP)
2025-12-17 4:43 ` Mukesh Kumar Chaurasiya
2025-12-19 4:56 ` Mukesh Kumar Chaurasiya
2025-12-14 13:02 ` [PATCH v2 7/8] powerpc: Enable IRQ generic entry/exit path Mukesh Kumar Chaurasiya
2025-12-16 6:29 ` kernel test robot
2025-12-16 15:02 ` Mukesh Kumar Chaurasiya
2025-12-16 10:43 ` Christophe Leroy (CS GROUP) [this message]
2025-12-16 15:06 ` Mukesh Kumar Chaurasiya
2025-12-17 2:10 ` kernel test robot
2025-12-17 21:32 ` kernel test robot
2025-12-14 13:02 ` [PATCH v2 8/8] powerpc: Enable Generic Entry/Exit for syscalls Mukesh Kumar Chaurasiya
2025-12-14 16:20 ` Segher Boessenkool
2025-12-15 18:32 ` Mukesh Kumar Chaurasiya
2025-12-15 20:27 ` kernel test robot
2025-12-16 15:08 ` Mukesh Kumar Chaurasiya
2025-12-16 22:57 ` Christophe Leroy (CS GROUP)
2025-12-16 6:41 ` Christophe Leroy (CS GROUP)
2025-12-16 15:09 ` Mukesh Kumar Chaurasiya
2025-12-16 11:01 ` Christophe Leroy (CS GROUP)
2025-12-16 15:13 ` Mukesh Kumar Chaurasiya
2026-01-04 12:36 ` [PATCH v2 0/8] Generic IRQ entry/exit support for powerpc Samir M
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3de95000-19ce-499e-b6b6-7e207c02c73c@kernel.org \
--to=chleroy@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ankur.a.arora@oracle.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=bigeasy@linutronix.de \
--cc=charlie@rivosinc.com \
--cc=deller@gmx.de \
--cc=kan.liang@linux.intel.com \
--cc=kees@kernel.org \
--cc=ldv@strace.io \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@amacapital.net \
--cc=macro@orcam.me.uk \
--cc=maddy@linux.ibm.com \
--cc=mark.barnett@arm.com \
--cc=mchauras@linux.ibm.com \
--cc=menglong8.dong@gmail.com \
--cc=mingo@kernel.org \
--cc=mkchauras@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=namcao@linutronix.de \
--cc=npiggin@gmail.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=segher@kernel.crashing.org \
--cc=sshegde@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
--cc=thuth@redhat.com \
--cc=wad@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).