From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 D517342B751 for ; Wed, 3 Jun 2026 10:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481525; cv=none; b=IQVCcPkPTbXUWOkUE2CtzzXA8GenyJ/pqAyAILnRVJtaVxNOtKsC01MTpQfoJN4YAwPnPxSFENpXjvunrQc293TNe0rt+YITRg3CMi2khw5nyKwlTaZitTHho2GRWyNbsqDizJ9Osv0dmwCNOK33Hy9e4hTDTECTwaGTRRJVwVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481525; c=relaxed/simple; bh=kSco68ckPIMkcTPGMLzSkbZ2wcQXjjyRW93AjTdf6kU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ksn5XbnzjTDX4eQRNaOtTQneqARp4O5QPamcrw+v4MVVu7PdFOeEtgoB0pngyeJ6QjgQFb8BTOu9mdQO5bS2aKewAp2ktqVO6WAiqQU9+M80EhNlvxlFUfFjLZxPmTbyqKyMi/UY3+oZn1/5oLLnFTP398GlC3VHgZrQQYhm/34= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=YD6xz+z2; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YD6xz+z2" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GJm322gPuQfTwo1jcz0N68dPOIxhXt9XqKhOnmKExww=; b=YD6xz+z2/DhAQvKzOSbxegjeTZ MfQq2Dj/qZ3ZHMdrimh3O1jWL1v9g2tXaLKMpusB/Ek6W0TEG8SeKQsIC3jh//ENHmYBsSQiLTJGu DKNiCQIMxf9Rs2Bo+alfxktZmR4DpQKcpFAjQeMelxPYfpvj3JwLb8mbDeQl2LFxNoTaYoCyHK6Ct R1v3COBXXoT0VI+tYKDBsQyTMgU+Dgp/tFc1T0BGRa5zsBQ7N7nJTySjeAC769mCzetGxvoLzliD+ Tkjy4wJuMNguJilKaq8z+qP+9qd6DAFffpEzUsHLUUrNa/l1K1Q2Zyk85OxG7UooXQpyJ2qNCuUlZ z0TBuAmw==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wUiZp-00000003fL5-0Qek; Wed, 03 Jun 2026 10:11:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 49C33300642; Wed, 03 Jun 2026 12:11:55 +0200 (CEST) Date: Wed, 3 Jun 2026 12:11:55 +0200 From: Peter Zijlstra To: Shrikanth Hegde Cc: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, tglx@kernel.org, christophe.leroy@csgroup.eu, linux-kernel@vger.kernel.org, venkat88@linux.ibm.com, mkchauras@gmail.com Subject: Re: [PATCH] powerpc/entry: Disable interrupts before irqentry_exit Message-ID: <20260603101155.GV3493090@noisy.programming.kicks-ass.net> References: <20260603095521.198267-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260603095521.198267-1-sshegde@linux.ibm.com> On Wed, Jun 03, 2026 at 03:25:21PM +0530, Shrikanth Hegde wrote: > Venkat reported a panic on powerpc-next tree where GENERIC_ENTRY has > been enabled. > > kernel BUG at kernel/sched/core.c:7512! > NIP preempt_schedule_irq+0x44/0x118 > LR dynamic_irqentry_exit_cond_resched+0x40/0x1a4 > Call Trace: > dynamic_irqentry_exit_cond_resched+0x40/0x1a4 > do_page_fault+0xc0/0x104 > data_access_common_virt+0x210/0x220 > > This happens since __do_page_fault ends up enabling the interrupts and > it could take significant time such that need_resched could be set. This > leads to schedule call in irqentry_exit leading to the bug. > > There are many such irq handlers which enables the interrupts. > Fix it by disabling the irq before calling irqentry_exit. The same > pattern exists today in interrupt_exit_kernel_prepare. > > While there, make those BUG_ON into WARN_ON. Interrupt is disabled right > after so it is not that severe. This will still help to catch the > offending callsites. > > Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature") > Reported-by: Venkat Rao Bagalkote > Closes: https://lore.kernel.org/all/7904105b-9dfa-4efd-a5ef-bc0276ed255d@linux.ibm.com/ > Signed-off-by: Shrikanth Hegde > --- > > This applies on top on powerpc/next tree. > base: 6ed60999d33d '("powerpc: Remove unused functions")' > > arch/powerpc/include/asm/entry-common.h | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/arch/powerpc/include/asm/entry-common.h b/arch/powerpc/include/asm/entry-common.h > index de5601282755..7da373a56813 100644 > --- a/arch/powerpc/include/asm/entry-common.h > +++ b/arch/powerpc/include/asm/entry-common.h > @@ -253,16 +253,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)); > + WARN_ON(regs_is_unrecoverable(regs)); > + WARN_ON(regs_irqs_disabled(regs)); So while you will indeed disable IRQs righ below. This checks the IRQ state of regs, not the current state. What you are allowing through it a *userspace* state that has IRQs disabled. That is an invalid state. > /* > * 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(); > } > + > + /* irqentry_exit expects to be called with interrupts disabled */ > + local_irq_disable(); > } > > static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs) > -- > 2.47.3 >