From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387613; b=vVQ17cYL3/nnoX88UMa+Bp1tk9LkNNu6swlQhC3pXLAgC3FCL5D9t22Ns1S1W55FgF/P vBBpy26UJn/9Rl3K6CILqsEyi95XTF8lN3OQ3rCvDLtbsp16d3PC6vItoOSUXrJDwfbBA TetOW8oHznWWKESz7I8ULtBgCoKeXnz9IgYnrfcWsZH1PVJ8s+eKTwZiVsA/eY/O0voRs SQs2RZvgTz3y2JPmPH+Kt1w+REgAzyOMLfPH+Dxgg617x7fNp4jma7ApM+MECqhPmq+db hwHykZp/xzaPJcN1IWZbEMnWD7BTpmsYDuunckm8xaElfhBvli83FPQ7yEbg0VTcpEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387613; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=V8r/TaAV5137nO22zeNnRxk04z+M/zeIIXHAo76DX1A=; b=CCRxqAn8bpCfh/D17cYFXQaJ0kmgrk6MXxnA4wl5FAquELpvAtFHz5TRgJzedbkNDvNZ W2azkIsQ4mwFccLexeTA9kKlxUjRIJSE5Wn/EU5rmuK4cdeuMXg9KilhXgazfA02GnaqT 4BsZoFCR9aEp7a/Qq0on/RuSzwB9MUbm8eKILphebBx0F36z8G9Q9+e6sPhQEZSaHcYqi Tcy+duOhy66qzvOCl5K03ex3UBAynoiXUj+pm5Y1Zj733yn0kMaeofzssgF6mkQYuTIjo nrVIPKWPa7/j96bmNjLPuDQNP1Xo/yivfv/GJefApzovXJHYc0wmm9uryxQqtYPVoXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="Y/X4Bm7n"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D31C8606A322; Fri, 4 Dec 2026 12:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Y/X4Bm7n Received: by smtp.kernel.org (Postfix) with ESMTPSA id 487351F00897; Fri, 4 Dec 2026 12:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387613; bh=V8r/TaAV5137nO22zeNnRxk04z+M/zeIIXHAo76DX1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y/X4Bm7nTVgdMDThH2MLleiZnOBVgyCTh5uF/ldjCHvo3Ste8nOftK74LNRmFy+zv +YWWOwHZJDaPIp+9oPlN3wjkd6Fd5KHqeTQ/2Gcns40uuVSvX46O6vxSKDy7doauIO SkQprn64aucrVNIQ3cbd/avsxW/U225Y2fC314yE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Venkat Rao Bagalkote , Mukesh Kumar Chaurasiya , Shrikanth Hegde , Madhavan Srinivasan , Sasha Levin Subject: [PATCH 6.1 0316/1059] powerpc/interrupt: Use early_radix_enabled() in NMI real-mode guard Date: Fri, 4 Dec 2026 18:57:27 +0900 Message-ID: <20261204100652.455977084@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Venkat Rao Bagalkote [ Upstream commit 644ffb02746690c0ebfe143e066f81c9bde2975e ] radix_enabled() uses a jump label which is only valid after setup_feature_keys() is called. Before that point, on a pSeries hash guest, early_check_vec5() clears MMU_FTR_TYPE_RADIX in cur_cpu_spec->mmu_features, but the jump label has not yet been patched, so radix_enabled() incorrectly returns true. The dangerous usage window where it goes wrong in early_setup(): early_setup: configure_exceptions(); setup_feature_keys(); If an NMI occurs in this window, !radix_enabled() evaluates to false in DEFINE_INTERRUPT_HANDLER_NMI. The handler fails to skip NMI entry in real mode and attempts to access memory outside the Real Mode Area (RMA), hanging the boot. Since common interrupt wrappers do not have the context of early or late, using early_radix_enabled() is the safer option. It does a plain bitmask check against cur_cpu_spec->mmu_features and is correct at all times. Console logs from a pSeries HASH guest showing values across boot stages: [ 0.000000] DEBUG: after early_init_devtree: early_radix_enabled=0 radix_enabled=1 (mismatch means NMI real-mode check is unsafe!) [ 0.000000] DEBUG: after configure_exceptions (DANGEROUS WINDOW): early_radix_enabled=0 radix_enabled=1 [ 0.000000] DEBUG: after setup_feature_keys (jump labels initialized): early_radix_enabled=0 radix_enabled=0 (should now match!) [ 0.057124] DEBUG: post secondary CPU bringup: early_radix_enabled=0 radix_enabled=0 (should match!) Console logs from a RADIX guest showing values across boot stages: [ 0.000000] DEBUG: after early_init_devtree: early_radix_enabled=1 radix_enabled=1 (mismatch means NMI real-mode check is unsafe!) [ 0.000000] DEBUG: after configure_exceptions (DANGEROUS WINDOW): early_radix_enabled=1 radix_enabled=1 [ 0.000000] DEBUG: after setup_feature_keys (jump labels initialized): early_radix_enabled=1 radix_enabled=1 (should now match!) [ 0.057016] DEBUG: post secondary CPU bringup: early_radix_enabled=1 radix_enabled=1 (should match!) Add the missing #include in alphabetical order since early_radix_enabled() is declared there. Fixes: 8d0e21012743 ("powerpc/mce: Avoid nmi_enter/exit in real mode on pseries hash") Signed-off-by: Venkat Rao Bagalkote Reviewed-by: Mukesh Kumar Chaurasiya Reviewed-by: Shrikanth Hegde Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/20260909123240.58786-1-venkat88@linux.ibm.com [ sashal: Applied the same !radix_enabled() to !early_radix_enabled() change in the inline functions interrupt_nmi_enter_prepare() and interrupt_nmi_exit_prepare(), since the DEFINE_INTERRUPT_HANDLER_NMI macro lacks the guard here. ] Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/interrupt.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h index 4999de47b4a38..b2517538bcaea 100644 --- a/arch/powerpc/include/asm/interrupt.h +++ b/arch/powerpc/include/asm/interrupt.h @@ -72,6 +72,7 @@ #include #include #include +#include #include #ifdef CONFIG_PPC64 @@ -345,7 +346,7 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte */ if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && firmware_has_feature(FW_FEATURE_LPAR) && - !radix_enabled()) + !early_radix_enabled()) return; /* @@ -374,7 +375,7 @@ static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct inter nmi_exit(); } else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && firmware_has_feature(FW_FEATURE_LPAR) && - !radix_enabled()) { + !early_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 -- 2.53.0