From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07649313E31 for ; Tue, 16 Dec 2025 10:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765881796; cv=none; b=Jvnjrk1u70sh81NeWo/jPho40urdOFYBlN3nOa6kLhWKEuO3v6mvzT0nv/URPAzttFUwAEKOZ49K8dTjLCdWzqt+rJop37+4sELzh6C63D8Guj0jWUBz7bmFkc44Ausgz88gJZdcE1bE7k5z5D9bHp+aGzIHro81MGIVPO7Nsjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765881796; c=relaxed/simple; bh=eRzo0nGpPZV7pKWhWM8sw/iza/GTpTdjz4hBzUhMixA=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=WzfO0C13Uied9RYnyacvgYXEGm2h5MeK354m+O8fXu28EvQJY4i2W6pNE/jRpInk9cVKG70JuUiht6OnaRVFpDVNq7uJzwhuasGAsod5qpJLkiI4U4wJODaSqhirli3lvIUsAmqMsoQrTHRpURZPU0+LEW2IFvmIaQXLUD07alI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kKV43/7i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kKV43/7i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ABAAC4CEF1; Tue, 16 Dec 2025 10:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765881795; bh=eRzo0nGpPZV7pKWhWM8sw/iza/GTpTdjz4hBzUhMixA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=kKV43/7iYWeXCKaTRxkUzSAj8vub8vCzU7I34embwR3mIUll3RmWculudc514nOz+ H/oDntPe8vUyWOK/IawRh/wF6OawJ4oYyKg9EnSNH3Rbq/slc2Tu3tEwKepn7ulsIl nm4tJgeQiEc9fs09BmXwuKGvZ6gWR4YlhCXI8UKM96UkiQrGW5OZLupjruhw32QSch RewDXH9Lm7sjgx0JH7XYQCnJ179aKdqzj24NhfbY6O2HSd/8zsbiOJKFQxwxEw/Hi/ CWl807rhFET955Nlq047ydPJw5PbBrKuxgvOHb1DzDxMPE/QMDdPgc7l5zyLzmXcX2 9q0NrixO8QDDQ== Message-ID: <3de95000-19ce-499e-b6b6-7e207c02c73c@kernel.org> Date: Tue, 16 Dec 2025 11:43:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 7/8] powerpc: Enable IRQ generic entry/exit path. To: Mukesh Kumar Chaurasiya , 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 References: <20251214130245.43664-1-mkchauras@linux.ibm.com> <20251214130245.43664-8-mkchauras@linux.ibm.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20251214130245.43664-8-mkchauras@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 14/12/2025 à 14:02, Mukesh Kumar Chaurasiya a écrit : > From: Mukesh Kumar Chaurasiya > > 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 > --- > 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