Skip to contentSkip to conversation

powerpc/dt_cpu_ftrs: Set CPU_FTR_P11_PVR for Power11 and later processors

PATCH Applied Amit Machhiwal 4 participants 7 messages Jun 14 – Jul 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/dt_cpu_ftrs: Set CPU_FTR_P11_PVR for Power11 and later processors

When using device tree CPU features (dt-cpu-ftrs), the kernel bypasses the traditional cputable-based CPU identification and instead derives CPU features from the device tree's "ibm,powerpc-cpu-features" node provided by firmware.

However, CPU_FTR_P11_PVR is a kernel-internal feature flag used to identify Power11 and later processors, and is not represented in the device tree's ISA feature set. While ISA v3.1 support (indicated by CPU_FTR_ARCH_31) is present on both Power10 and Power11, the CPU_FTR_P11_PVR flag is specifically needed by code that must distinguish between Power10 and Power11 processors.

Without this flag set, code that checks for Power11 using cpu_has_feature(CPU_FTR_P11_PVR) will incorrectly return false on Power11+ systems using dt-cpu-ftrs, leading to incorrect behavior.

This issue manifests specifically in powernv environments (bare-metal or QEMU TCG with powernv machine type), where skiboot/OPAL firmware provides the "ibm,powerpc-cpu-features" node, causing the kernel to use dt-cpu-ftrs. The issue does not affect pseries guests, where SLOF firmware does not provide this node, causing the kernel to fall back to the traditional cputable path (identify_cpu) which correctly sets CPU_FTR_P11_PVR during PVR-based CPU identification.

In powernv TCG guests, the missing flag causes KVM code to trigger warnings when attempting to create KVM guests, as cpu_features shows 0x000c00eb8f4fb187 (missing bit 53) instead of the correct 0x002c00eb8f4fb187 (with bit 53 set).

Fix this by setting CPU_FTR_P11_PVR for all processors with PVR >= PVR_POWER11 when ISA v3.1 support is detected in cpufeatures_setup_start(). This approach ensures forward compatibility with future processor generations.

Fixes 96e266e3bcd6 ("KVM: PPC: Book3S HV: Add Power11 capability support for Nested PAPR guests")
Cc [email protected] # v6.13+

---
Related: https://lore.kernel.org/all/[email protected]/
---

 arch/powerpc/kernel/dt_cpu_ftrs.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/powerpc/kernel/dt_cpu_ftrs.c +9 -0
index 3af6c06af02f..e5853daa6a48 100644
@@ -704,6 +704,15 @@ static void __init cpufeatures_setup_start(u32 isa)
 	if (isa >= ISA_V3_1) {
 		cur_cpu_spec->cpu_features |= CPU_FTR_ARCH_31;
 		cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_ARCH_3_1;
+
+		/*
+		 * CPU_FTR_P11_PVR is a kernel-internal flag to identify
+		 * Power11 and later processors. While ISA v3.1 is supported
+		 * by Power10+, this flag specifically indicates Power11+
+		 * for code that needs to distinguish between P10 and P11.
+		 */
+		if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER11)
+			cur_cpu_spec->cpu_features |= CPU_FTR_P11_PVR;
 	}
 }
 

base-commit: 424280953322cf66314f3ba5e2d1ef345f21c770

Signature · 1 line
2.50.1 (Apple Git-155)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 65 lines · Amit Machhiwal

When using device tree CPU features (dt-cpu-ftrs), the kernel bypasses the traditional cputable-based CPU identification and instead derives CPU features from the device tree's "ibm,powerpc-cpu-features" node provided by firmware.

However, CPU_FTR_P11_PVR is a kernel-internal feature flag used to identify Power11 and later processors, and is not represented in the device tree's ISA feature set. While ISA v3.1 support (indicated by CPU_FTR_ARCH_31) is present on both Power10 and Power11, the CPU_FTR_P11_PVR flag is specifically needed by code that must distinguish between Power10 and Power11 processors.

Without this flag set, code that checks for Power11 using cpu_has_feature(CPU_FTR_P11_PVR) will incorrectly return false on Power11+ systems using dt-cpu-ftrs, leading to incorrect behavior.

This issue manifests specifically in powernv environments (bare-metal or QEMU TCG with powernv machine type), where skiboot/OPAL firmware provides the "ibm,powerpc-cpu-features" node, causing the kernel to use dt-cpu-ftrs. The issue does not affect pseries guests, where SLOF firmware does not provide this node, causing the kernel to fall back to the traditional cputable path (identify_cpu) which correctly sets CPU_FTR_P11_PVR during PVR-based CPU identification.

In powernv TCG guests, the missing flag causes KVM code to trigger warnings when attempting to create KVM guests, as cpu_features shows 0x000c00eb8f4fb187 (missing bit 53) instead of the correct 0x002c00eb8f4fb187 (with bit 53 set).

Fix this by setting CPU_FTR_P11_PVR for all processors with PVR >= PVR_POWER11 when ISA v3.1 support is detected in cpufeatures_setup_start(). This approach ensures forward compatibility with future processor generations.

Fixes 96e266e3bcd6 ("KVM: PPC: Book3S HV: Add Power11 capability support for Nested PAPR guests")
Cc [email protected] # v6.13+

---
Related: https://lore.kernel.org/all/[email protected]/
---

 arch/powerpc/kernel/dt_cpu_ftrs.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/powerpc/kernel/dt_cpu_ftrs.c +9 -0
index 3af6c06af02f..e5853daa6a48 100644
@@ -704,6 +704,15 @@ static void __init cpufeatures_setup_start(u32 isa)
 	if (isa >= ISA_V3_1) {
 		cur_cpu_spec->cpu_features |= CPU_FTR_ARCH_31;
 		cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_ARCH_3_1;
+
+		/*
+		 * CPU_FTR_P11_PVR is a kernel-internal flag to identify
+		 * Power11 and later processors. While ISA v3.1 is supported
+		 * by Power10+, this flag specifically indicates Power11+
+		 * for code that needs to distinguish between P10 and P11.
+		 */
+		if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER11)
+			cur_cpu_spec->cpu_features |= CPU_FTR_P11_PVR;
 	}
 }
 
Quoted 4 lines

base-commit: 424280953322cf66314f3ba5e2d1ef345f21c770

Signature · 1 line
2.50.1 (Apple Git-155)

LGTM

#2 lore raw
In reply to Amit Machhiwal

Le 14/06/2026 à 19:34, Amit Machhiwal a écrit :

Quoted 50 lines

When using device tree CPU features (dt-cpu-ftrs), the kernel bypasses the traditional cputable-based CPU identification and instead derives CPU features from the device tree's "ibm,powerpc-cpu-features" node provided by firmware.

However, CPU_FTR_P11_PVR is a kernel-internal feature flag used to identify Power11 and later processors, and is not represented in the device tree's ISA feature set. While ISA v3.1 support (indicated by CPU_FTR_ARCH_31) is present on both Power10 and Power11, the CPU_FTR_P11_PVR flag is specifically needed by code that must distinguish between Power10 and Power11 processors.

Without this flag set, code that checks for Power11 using cpu_has_feature(CPU_FTR_P11_PVR) will incorrectly return false on Power11+ systems using dt-cpu-ftrs, leading to incorrect behavior.

This issue manifests specifically in powernv environments (bare-metal or QEMU TCG with powernv machine type), where skiboot/OPAL firmware provides the "ibm,powerpc-cpu-features" node, causing the kernel to use dt-cpu-ftrs. The issue does not affect pseries guests, where SLOF firmware does not provide this node, causing the kernel to fall back to the traditional cputable path (identify_cpu) which correctly sets CPU_FTR_P11_PVR during PVR-based CPU identification.

In powernv TCG guests, the missing flag causes KVM code to trigger warnings when attempting to create KVM guests, as cpu_features shows 0x000c00eb8f4fb187 (missing bit 53) instead of the correct 0x002c00eb8f4fb187 (with bit 53 set).

Fix this by setting CPU_FTR_P11_PVR for all processors with PVR >= PVR_POWER11 when ISA v3.1 support is detected in cpufeatures_setup_start(). This approach ensures forward compatibility with future processor generations.

Fixes 96e266e3bcd6 ("KVM: PPC: Book3S HV: Add Power11 capability support for Nested PAPR guests")
Cc [email protected] # v6.13+

---
Related: https://lore.kernel.org/all/[email protected]/
---

  arch/powerpc/kernel/dt_cpu_ftrs.c | 9 +++++++++
  1 file changed, 9 insertions(+)
arch/powerpc/kernel/dt_cpu_ftrs.c +0 -0
index 3af6c06af02f..e5853daa6a48 100644
@@ -704,6 +704,15 @@ static void __init cpufeatures_setup_start(u32 isa)
  	if (isa >= ISA_V3_1) {

arch/powerpc/kernel/dt_cpu_ftrs.c static void __init cpufeatures_setup_start(u32 isa) · line 714

Quoted 10 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +8 -0
  		cur_cpu_spec->cpu_features |= CPU_FTR_ARCH_31;
  		cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_ARCH_3_1;
+
+		/*
+		 * CPU_FTR_P11_PVR is a kernel-internal flag to identify
+		 * Power11 and later processors. While ISA v3.1 is supported
+		 * by Power10+, this flag specifically indicates Power11+
+		 * for code that needs to distinguish between P10 and P11.
+		 */
+		if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER11)

Are we sure this test will always be correct ?

For instance PVR_PA6T is higher than PVR_POWER11 allthough it is not ISA 3.1

Wouldn't is be cleaner and safer to just do:

	PVR_VER(mfspr(SPRN_PVR)) == PVR_POWER11
Quoted 6 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +1 -0
+			cur_cpu_spec->cpu_features |= CPU_FTR_P11_PVR;
  	}
  }
 

base-commit: 424280953322cf66314f3ba5e2d1ef345f21c770

#3 lore raw

Hi Christophe,

Thanks for reviewing this patch. Please find my response inline.

Quoted 66 lines · Christophe Leroy (CS GROUP)

Le 14/06/2026 à 19:34, Amit Machhiwal a écrit :

Quoted 50 lines

When using device tree CPU features (dt-cpu-ftrs), the kernel bypasses the traditional cputable-based CPU identification and instead derives CPU features from the device tree's "ibm,powerpc-cpu-features" node provided by firmware.

However, CPU_FTR_P11_PVR is a kernel-internal feature flag used to identify Power11 and later processors, and is not represented in the device tree's ISA feature set. While ISA v3.1 support (indicated by CPU_FTR_ARCH_31) is present on both Power10 and Power11, the CPU_FTR_P11_PVR flag is specifically needed by code that must distinguish between Power10 and Power11 processors.

Without this flag set, code that checks for Power11 using cpu_has_feature(CPU_FTR_P11_PVR) will incorrectly return false on Power11+ systems using dt-cpu-ftrs, leading to incorrect behavior.

This issue manifests specifically in powernv environments (bare-metal or QEMU TCG with powernv machine type), where skiboot/OPAL firmware provides the "ibm,powerpc-cpu-features" node, causing the kernel to use dt-cpu-ftrs. The issue does not affect pseries guests, where SLOF firmware does not provide this node, causing the kernel to fall back to the traditional cputable path (identify_cpu) which correctly sets CPU_FTR_P11_PVR during PVR-based CPU identification.

In powernv TCG guests, the missing flag causes KVM code to trigger warnings when attempting to create KVM guests, as cpu_features shows 0x000c00eb8f4fb187 (missing bit 53) instead of the correct 0x002c00eb8f4fb187 (with bit 53 set).

Fix this by setting CPU_FTR_P11_PVR for all processors with PVR >= PVR_POWER11 when ISA v3.1 support is detected in cpufeatures_setup_start(). This approach ensures forward compatibility with future processor generations.

Fixes 96e266e3bcd6 ("KVM: PPC: Book3S HV: Add Power11 capability support for Nested PAPR guests")
Cc [email protected] # v6.13+

---
Related: https://lore.kernel.org/all/[email protected]/
---

  arch/powerpc/kernel/dt_cpu_ftrs.c | 9 +++++++++
  1 file changed, 9 insertions(+)
arch/powerpc/kernel/dt_cpu_ftrs.c +0 -0
index 3af6c06af02f..e5853daa6a48 100644
@@ -704,6 +704,15 @@ static void __init cpufeatures_setup_start(u32 isa)
  	if (isa >= ISA_V3_1) {

arch/powerpc/kernel/dt_cpu_ftrs.c static void __init cpufeatures_setup_start(u32 isa) · line 714

Quoted 10 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +8 -0
  		cur_cpu_spec->cpu_features |= CPU_FTR_ARCH_31;
  		cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_ARCH_3_1;
+
+		/*
+		 * CPU_FTR_P11_PVR is a kernel-internal flag to identify
+		 * Power11 and later processors. While ISA v3.1 is supported
+		 * by Power10+, this flag specifically indicates Power11+
+		 * for code that needs to distinguish between P10 and P11.
+		 */
+		if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER11)

Are we sure this test will always be correct ?

Quoted 5 lines

For instance PVR_PA6T is higher than PVR_POWER11 allthough it is not ISA 3.1

Wouldn't is be cleaner and safer to just do:

	PVR_VER(mfspr(SPRN_PVR)) == PVR_POWER11

You're absolutely right to point out the PVR ordering concern. But PA6T cannot actually reach this path because we're already gated by:

if (isa >= ISA_V3_1)

and PA6T does not implement ISA v3.1.

My rationale for using >= PVR_POWER11 is that CPU_FTR_P11_PVR is intended to be included for Power11 and later processors, not just Power11 itself, as it identifies a CPU feature. Using == PVR_POWER11 would mean we'd need to revisit this code for every future generation.

This approach is consistent with existing kernel code. For example, in arch/powerpc/perf/hv-gpci.c:

/* sysinfo interface files are only available for power10 and above platforms */ if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER10)

      add_sysinfo_interface_files();

Also, I couldn't find any current users of PVR_PA6T or PVR_BE in the kernel tree, so there doesn't appear to be a present-day ISA v3.1+ example where the comparison would misidentify a processor.

Please let me know your further thoughts on this.

Thanks,
Amit

Quoted 7 lines
Quoted 6 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +1 -0
+			cur_cpu_spec->cpu_features |= CPU_FTR_P11_PVR;
  	}
  }
 

base-commit: 424280953322cf66314f3ba5e2d1ef345f21c770

#4 lore raw

Hi Christophe,

<snip>

Quoted 42 lines
Quoted 19 lines
Quoted 6 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +0 -0
index 3af6c06af02f..e5853daa6a48 100644
@@ -704,6 +704,15 @@ static void __init cpufeatures_setup_start(u32 isa)
  	if (isa >= ISA_V3_1) {

arch/powerpc/kernel/dt_cpu_ftrs.c static void __init cpufeatures_setup_start(u32 isa) · line 714

Quoted 10 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +8 -0
  		cur_cpu_spec->cpu_features |= CPU_FTR_ARCH_31;
  		cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_ARCH_3_1;
+
+		/*
+		 * CPU_FTR_P11_PVR is a kernel-internal flag to identify
+		 * Power11 and later processors. While ISA v3.1 is supported
+		 * by Power10+, this flag specifically indicates Power11+
+		 * for code that needs to distinguish between P10 and P11.
+		 */
+		if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER11)

Are we sure this test will always be correct ?

Quoted 5 lines

For instance PVR_PA6T is higher than PVR_POWER11 allthough it is not ISA 3.1

Wouldn't is be cleaner and safer to just do:

	PVR_VER(mfspr(SPRN_PVR)) == PVR_POWER11

You're absolutely right to point out the PVR ordering concern. But PA6T cannot actually reach this path because we're already gated by:

if (isa >= ISA_V3_1)

and PA6T does not implement ISA v3.1.

My rationale for using >= PVR_POWER11 is that CPU_FTR_P11_PVR is intended to be included for Power11 and later processors, not just Power11 itself, as it identifies a CPU feature. Using == PVR_POWER11 would mean we'd need to revisit this code for every future generation.

This approach is consistent with existing kernel code. For example, in arch/powerpc/perf/hv-gpci.c:

/* sysinfo interface files are only available for power10 and above platforms */ if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER10)

Quoted 7 lines
      add_sysinfo_interface_files();

Also, I couldn't find any current users of PVR_PA6T or PVR_BE in the kernel tree, so there doesn't appear to be a present-day ISA v3.1+ example where the comparison would misidentify a processor.

Please let me know your further thoughts on this.

Just checking in — did my previous response address your concern, or do you have further comments?

Thanks,
Amit

reviewer Reviewed-by
#5 lore raw

Le 25/06/2026 à 15:14, Amit Machhiwal a écrit :

Quoted 48 lines

Hi Christophe,

<snip>

Quoted 44 lines
Quoted 19 lines
Quoted 6 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +0 -0
index 3af6c06af02f..e5853daa6a48 100644
@@ -704,6 +704,15 @@ static void __init cpufeatures_setup_start(u32 isa)
   	if (isa >= ISA_V3_1) {

arch/powerpc/kernel/dt_cpu_ftrs.c static void __init cpufeatures_setup_start(u32 isa) · line 714

Quoted 10 lines
arch/powerpc/kernel/dt_cpu_ftrs.c +8 -0
   		cur_cpu_spec->cpu_features |= CPU_FTR_ARCH_31;
   		cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_ARCH_3_1;
+
+		/*
+		 * CPU_FTR_P11_PVR is a kernel-internal flag to identify
+		 * Power11 and later processors. While ISA v3.1 is supported
+		 * by Power10+, this flag specifically indicates Power11+
+		 * for code that needs to distinguish between P10 and P11.
+		 */
+		if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER11)

Are we sure this test will always be correct ?

Quoted 5 lines

For instance PVR_PA6T is higher than PVR_POWER11 allthough it is not ISA 3.1

Wouldn't is be cleaner and safer to just do:

	PVR_VER(mfspr(SPRN_PVR)) == PVR_POWER11

You're absolutely right to point out the PVR ordering concern. But PA6T cannot actually reach this path because we're already gated by:

   if (isa >= ISA_V3_1)

and PA6T does not implement ISA v3.1.

My rationale for using >= PVR_POWER11 is that CPU_FTR_P11_PVR is intended to be included for Power11 and later processors, not just Power11 itself, as it identifies a CPU feature. Using == PVR_POWER11 would mean we'd need to revisit this code for every future generation.

This approach is consistent with existing kernel code. For example, in arch/powerpc/perf/hv-gpci.c:

   /* sysinfo interface files are only available for power10 and above platforms */
   if (PVR_VER(mfspr(SPRN_PVR)) >= PVR_POWER10)
       add_sysinfo_interface_files();
Quoted 8 lines
Quoted 5 lines

Also, I couldn't find any current users of PVR_PA6T or PVR_BE in the kernel tree, so there doesn't appear to be a present-day ISA v3.1+ example where the comparison would misidentify a processor.

Please let me know your further thoughts on this.

Just checking in — did my previous response address your concern, or do you have further comments?

That ok, no more comments.

maintainer Applied
#6 lore raw
In reply to Amit Machhiwal
Quoted 5 lines · Amit Machhiwal

When using device tree CPU features (dt-cpu-ftrs), the kernel bypasses the traditional cputable-based CPU identification and instead derives CPU features from the device tree's "ibm,powerpc-cpu-features" node provided by firmware.

Quoted 8 lines

However, CPU_FTR_P11_PVR is a kernel-internal feature flag used to identify Power11 and later processors, and is not represented in the device tree's ISA feature set. While ISA v3.1 support (indicated by CPU_FTR_ARCH_31) is present on both Power10 and Power11, the CPU_FTR_P11_PVR flag is specifically needed by code that must distinguish between Power10 and Power11 processors.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/dt_cpu_ftrs: Set CPU_FTR_P11_PVR for Power11 and later processors

      https://git.kernel.org/powerpc/c/e4de1b9cb3b5c981e4fe9bca253a7fb9161f5acd

cheers