[PATCH v2] powerpc/interrupt: Use early_radix_enabled() in NMI real-mode guard

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

COLD38d REVIEWED: 1 (0M)

1 review trailer.

2 messages, 2 authors, 2026-09-09 · open the first message on its own page

[PATCH v2] powerpc/interrupt: Use early_radix_enabled() in NMI real-mode guard

From: Venkat Rao Bagalkote <hidden>
Date: 2026-09-09 09:13:02

radix_enabled() uses a jump label which is only valid after
mmu_feature_keys_init() 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.

Replace radix_enabled() with early_radix_enabled() which does a plain
bitmask check against cur_cpu_spec->mmu_features and is correct at all
times, including before jump label initialization.

Add the missing #include <asm/mmu.h> 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 <redacted>
Reviewed-by: Mukesh Kumar Chaurasiya <redacted>
---
v2:
 - Added Fixes: tag referencing commit 8d0e21012743.
 - Included <asm/mmu.h> in alphabetical order.
 - Added Reviewed-by tag from Mukesh.

 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 1b45a49e9bed..355f6bbf9894 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -70,6 +70,7 @@
 #include <linux/irq-entry-common.h>
 
 #include <asm/kprobes.h>
+#include <asm/mmu.h>
 #include <asm/runlatch.h>
 
 #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
@@ -290,7 +291,7 @@ interrupt_handler long func(struct pt_regs *regs)			\
 		state = irqentry_nmi_enter(regs);			\
 	} else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) &&			\
 		   firmware_has_feature(FW_FEATURE_LPAR) &&		\
-		   !radix_enabled()) {					\
+		   !early_radix_enabled()) {				\
 		/* no nmi_entry for a pseries hash guest		\
 		 * taking a real mode exception */			\
 	} else if (IS_ENABLED(CONFIG_KASAN)) {				\
@@ -307,7 +308,7 @@ interrupt_handler long func(struct pt_regs *regs)			\
 		irqentry_nmi_exit(regs, state);				\
 	} 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)) {				\
-- 
2.45.2

Re: [PATCH v2] powerpc/interrupt: Use early_radix_enabled() in NMI real-mode guard

From: Shrikanth Hegde <sshegde@linux.ibm.com>
Date: 2026-09-09 09:46:36


On 9/9/26 2:42 PM, Venkat Rao Bagalkote wrote:
radix_enabled() uses a jump label which is only valid after
mmu_feature_keys_init() 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 usage window where it goes wrong is:

early_setup:
	configure_exceptions();
	<exception can happen now, and could prepare/exit of corresponding exception>
		<those could use radix_enabled() >
	setup_feature_keys();
	<jump labels are setup and post this it is safe to use radix_enabled()>

But since common wrappers don't have the context of early or late,
using early_radix_enabled() is safer option.

Commit message could convey the same.
Replace radix_enabled() with early_radix_enabled() which does a plain
bitmask check against cur_cpu_spec->mmu_features and is correct at all
times, including before jump label initialization.
If you have data, please put the values of both early_radix_enabled and radix_enabled()
in hash/radix guests in the chaneglog to ensure replacing with early variant
is functionally safe.
quoted hunk
Add the missing #include <asm/mmu.h> 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 <redacted>
Reviewed-by: Mukesh Kumar Chaurasiya <redacted>
---
v2:
  - Added Fixes: tag referencing commit 8d0e21012743.
  - Included <asm/mmu.h> in alphabetical order.
  - Added Reviewed-by tag from Mukesh.

  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 1b45a49e9bed..355f6bbf9894 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -70,6 +70,7 @@
  #include <linux/irq-entry-common.h>
  
  #include <asm/kprobes.h>
+#include <asm/mmu.h>
  #include <asm/runlatch.h>
  
  #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
@@ -290,7 +291,7 @@ interrupt_handler long func(struct pt_regs *regs)			\
  		state = irqentry_nmi_enter(regs);			\
  	} else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) &&			\
  		   firmware_has_feature(FW_FEATURE_LPAR) &&		\
-		   !radix_enabled()) {					\
+		   !early_radix_enabled()) {				\
  		/* no nmi_entry for a pseries hash guest		\
  		 * taking a real mode exception */			\
  	} else if (IS_ENABLED(CONFIG_KASAN)) {				\
@@ -307,7 +308,7 @@ interrupt_handler long func(struct pt_regs *regs)			\
  		irqentry_nmi_exit(regs, state);				\
  	} 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)) {				\

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help