LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
@ 2026-06-03 14:15 Amit Machhiwal
  2026-06-03 15:11 ` Ritesh Harjani
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Amit Machhiwal @ 2026-06-03 14:15 UTC (permalink / raw)
  To: linuxppc-dev, Madhavan Srinivasan
  Cc: Amit Machhiwal, Vaibhav Jain, Harsh Prateek Bora, Ritesh Harjani,
	Anushree Mathur, Nicholas Piggin, Michael Ellerman,
	Christophe Leroy (CS GROUP), kvm, stable, linux-kernel

On IBM POWER systems, newer processor generations can operate in
compatibility modes corresponding to earlier generations. This becomes
relevant for nested virtualization, where nested KVM guests may need to
run with a specific processor compatibility level.

Currently, when running a nested KVM guest (L2) inside a Power11 pSeries
logical partition (L1) booted in Power10 compatibility mode, the guest
fails to boot while setting 'arch_compat'. This happens because the CPU
class is derived from the hardware PVR (via mfspr()), which reflects the
physical processor generation (Power11), rather than the effective
compatibility mode (Power10).

As a result, userspace may request a Power11 arch_compat for the L2
guest. However, the L1 partition, running in Power10 compatibility, has
only negotiated support up to Power10 with the Power Hypervisor (L0).
When H_GUEST_SET_STATE is invoked with a Power11 Logical PVR, the
hypervisor rejects the request, leading to a late guest boot failure:

  KVM-NESTEDv2: couldn't set guest wide elements
  [..KVM reg dump..]

This situation should be detected earlier. Rejecting unsupported
'arch_compat' values in 'kvmppc_set_arch_compat()' avoids issuing an
invalid H_GUEST_SET_STATE hcall and provides a clearer failure mode.

Add a check to reject Power11 'arch_compat' requests when the host is
running in Power10 compatibility mode, returning -EINVAL early instead
of deferring the failure to the hypervisor.

Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Tested-by: Anushree Mathur <anushree.mathur@linux.ibm.com>
Cc: <stable@vger.kernel.org> # v6.13+
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
---
Changelog:

* Moved this patch out of the v3 series [1] as discussed here [2]
* Addressed below review comments from Ritesh:
  - Based the PVR validation on cpu features
  - Fixed hcall name typo
  - Stable backport

[1] https://lore.kernel.org/all/20260522152744.55251-1-amachhiw@linux.ibm.com/
[2] https://lore.kernel.org/all/20260522152744.55251-2-amachhiw@linux.ibm.com/
---
 arch/powerpc/kvm/book3s_hv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 61dbeea317f3..e16dbb199366 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -446,7 +446,17 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
 			guest_pcr_bit = PCR_ARCH_300;
 			break;
 		case PVR_ARCH_31:
+			guest_pcr_bit = PCR_ARCH_31;
+			break;
 		case PVR_ARCH_31_P11:
+			/*
+			 * Need to check this for ISA 3.1, as Power10 and
+			 * Power11 share the same PCR. For any subsequent ISA
+			 * versions, this will be taken care of by the guest vs
+			 * host PCR comparison below.
+			 */
+			if (!cpu_has_feature(CPU_FTR_P11_PVR))
+				return -EINVAL;
 			guest_pcr_bit = PCR_ARCH_31;
 			break;
 		default:

base-commit: ba3e43a9e601636f5edb54e259a74f96ca3b8fd8
-- 
2.50.1 (Apple Git-155)



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-03 14:15 [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode Amit Machhiwal
@ 2026-06-03 15:11 ` Ritesh Harjani
  2026-06-03 17:57 ` Mukesh Kumar Chaurasiya
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Ritesh Harjani @ 2026-06-03 15:11 UTC (permalink / raw)
  To: Amit Machhiwal, linuxppc-dev, Madhavan Srinivasan
  Cc: Amit Machhiwal, Vaibhav Jain, Harsh Prateek Bora, Anushree Mathur,
	Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
	kvm, stable, linux-kernel

Amit Machhiwal <amachhiw@linux.ibm.com> writes:

> On IBM POWER systems, newer processor generations can operate in
> compatibility modes corresponding to earlier generations. This becomes
> relevant for nested virtualization, where nested KVM guests may need to
> run with a specific processor compatibility level.
>
> Currently, when running a nested KVM guest (L2) inside a Power11 pSeries
> logical partition (L1) booted in Power10 compatibility mode, the guest
> fails to boot while setting 'arch_compat'. This happens because the CPU
> class is derived from the hardware PVR (via mfspr()), which reflects the
> physical processor generation (Power11), rather than the effective
> compatibility mode (Power10).
>
> As a result, userspace may request a Power11 arch_compat for the L2
> guest. However, the L1 partition, running in Power10 compatibility, has
> only negotiated support up to Power10 with the Power Hypervisor (L0).
> When H_GUEST_SET_STATE is invoked with a Power11 Logical PVR, the
> hypervisor rejects the request, leading to a late guest boot failure:
>
>   KVM-NESTEDv2: couldn't set guest wide elements
>   [..KVM reg dump..]
>

Thanks! It make sense to return a proper error code to the user (VMM)
while the VM/VCPU are being initialized, rather then the guest failing
to boot with a weird error like this, at the time when kernel makes this
H_GUEST_SET_STATE hcall.

> This situation should be detected earlier. Rejecting unsupported
> 'arch_compat' values in 'kvmppc_set_arch_compat()' avoids issuing an
> invalid H_GUEST_SET_STATE hcall and provides a clearer failure mode.
>
> Add a check to reject Power11 'arch_compat' requests when the host is
> running in Power10 compatibility mode, returning -EINVAL early instead
> of deferring the failure to the hypervisor.
>
> Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> Tested-by: Anushree Mathur <anushree.mathur@linux.ibm.com>
> Cc: <stable@vger.kernel.org> # v6.13+

Sure, v6.13 sounds fair as you pointed out.

> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> ---
> Changelog:
>
> * Moved this patch out of the v3 series [1] as discussed here [2]
> * Addressed below review comments from Ritesh:
>   - Based the PVR validation on cpu features
>   - Fixed hcall name typo
>   - Stable backport

The changes looks good to me. Please feel free to add:

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-03 14:15 [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode Amit Machhiwal
  2026-06-03 15:11 ` Ritesh Harjani
@ 2026-06-03 17:57 ` Mukesh Kumar Chaurasiya
  2026-06-04 14:20 ` Gautam Menghani
  2026-06-05  7:30 ` Vaibhav Jain
  3 siblings, 0 replies; 9+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-06-03 17:57 UTC (permalink / raw)
  To: Amit Machhiwal
  Cc: linuxppc-dev, Madhavan Srinivasan, Vaibhav Jain,
	Harsh Prateek Bora, Ritesh Harjani, Anushree Mathur,
	Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
	kvm, stable, linux-kernel

On Wed, Jun 03, 2026 at 07:45:39PM +0530, Amit Machhiwal wrote:
> On IBM POWER systems, newer processor generations can operate in
> compatibility modes corresponding to earlier generations. This becomes
> relevant for nested virtualization, where nested KVM guests may need to
> run with a specific processor compatibility level.
> 
> Currently, when running a nested KVM guest (L2) inside a Power11 pSeries
> logical partition (L1) booted in Power10 compatibility mode, the guest
> fails to boot while setting 'arch_compat'. This happens because the CPU
> class is derived from the hardware PVR (via mfspr()), which reflects the
> physical processor generation (Power11), rather than the effective
> compatibility mode (Power10).
> 
> As a result, userspace may request a Power11 arch_compat for the L2
> guest. However, the L1 partition, running in Power10 compatibility, has
> only negotiated support up to Power10 with the Power Hypervisor (L0).
> When H_GUEST_SET_STATE is invoked with a Power11 Logical PVR, the
> hypervisor rejects the request, leading to a late guest boot failure:
> 
>   KVM-NESTEDv2: couldn't set guest wide elements
>   [..KVM reg dump..]
> 
> This situation should be detected earlier. Rejecting unsupported
> 'arch_compat' values in 'kvmppc_set_arch_compat()' avoids issuing an
> invalid H_GUEST_SET_STATE hcall and provides a clearer failure mode.
> 
> Add a check to reject Power11 'arch_compat' requests when the host is
> running in Power10 compatibility mode, returning -EINVAL early instead
> of deferring the failure to the hypervisor.
> 
> Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> Tested-by: Anushree Mathur <anushree.mathur@linux.ibm.com>
> Cc: <stable@vger.kernel.org> # v6.13+
> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> ---
> Changelog:
> 
> * Moved this patch out of the v3 series [1] as discussed here [2]
> * Addressed below review comments from Ritesh:
>   - Based the PVR validation on cpu features
>   - Fixed hcall name typo
>   - Stable backport
> 
> [1] https://lore.kernel.org/all/20260522152744.55251-1-amachhiw@linux.ibm.com/
> [2] https://lore.kernel.org/all/20260522152744.55251-2-amachhiw@linux.ibm.com/
> ---
>  arch/powerpc/kvm/book3s_hv.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 61dbeea317f3..e16dbb199366 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -446,7 +446,17 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
>  			guest_pcr_bit = PCR_ARCH_300;
>  			break;
>  		case PVR_ARCH_31:
> +			guest_pcr_bit = PCR_ARCH_31;
> +			break;
>  		case PVR_ARCH_31_P11:
> +			/*
> +			 * Need to check this for ISA 3.1, as Power10 and
> +			 * Power11 share the same PCR. For any subsequent ISA
> +			 * versions, this will be taken care of by the guest vs
> +			 * host PCR comparison below.
> +			 */
> +			if (!cpu_has_feature(CPU_FTR_P11_PVR))
> +				return -EINVAL;
>  			guest_pcr_bit = PCR_ARCH_31;
>  			break;
>  		default:
> 
> base-commit: ba3e43a9e601636f5edb54e259a74f96ca3b8fd8
> -- 
> 2.50.1 (Apple Git-155)
> 
yeah this makes sense to throw an error early.
LGTM

Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-03 14:15 [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode Amit Machhiwal
  2026-06-03 15:11 ` Ritesh Harjani
  2026-06-03 17:57 ` Mukesh Kumar Chaurasiya
@ 2026-06-04 14:20 ` Gautam Menghani
  2026-06-05  7:25   ` Vaibhav Jain
  2026-06-05  7:30 ` Vaibhav Jain
  3 siblings, 1 reply; 9+ messages in thread
From: Gautam Menghani @ 2026-06-04 14:20 UTC (permalink / raw)
  To: Amit Machhiwal
  Cc: linuxppc-dev, Madhavan Srinivasan, Vaibhav Jain,
	Harsh Prateek Bora, Ritesh Harjani, Anushree Mathur,
	Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
	kvm, stable, linux-kernel

On Wed, Jun 03, 2026 at 07:45:39PM +0530, Amit Machhiwal wrote:
> On IBM POWER systems, newer processor generations can operate in
> compatibility modes corresponding to earlier generations. This becomes
> relevant for nested virtualization, where nested KVM guests may need to
> run with a specific processor compatibility level.
> 
> Currently, when running a nested KVM guest (L2) inside a Power11 pSeries
> logical partition (L1) booted in Power10 compatibility mode, the guest
> fails to boot while setting 'arch_compat'. This happens because the CPU
> class is derived from the hardware PVR (via mfspr()), which reflects the
> physical processor generation (Power11), rather than the effective
> compatibility mode (Power10).
> 
> As a result, userspace may request a Power11 arch_compat for the L2
> guest. However, the L1 partition, running in Power10 compatibility, has
> only negotiated support up to Power10 with the Power Hypervisor (L0).
> When H_GUEST_SET_STATE is invoked with a Power11 Logical PVR, the
> hypervisor rejects the request, leading to a late guest boot failure:
> 
>   KVM-NESTEDv2: couldn't set guest wide elements
>   [..KVM reg dump..]
> 
> This situation should be detected earlier. Rejecting unsupported
> 'arch_compat' values in 'kvmppc_set_arch_compat()' avoids issuing an
> invalid H_GUEST_SET_STATE hcall and provides a clearer failure mode.
> 
> Add a check to reject Power11 'arch_compat' requests when the host is
> running in Power10 compatibility mode, returning -EINVAL early instead
> of deferring the failure to the hypervisor.
> 
> Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> Tested-by: Anushree Mathur <anushree.mathur@linux.ibm.com>
> Cc: <stable@vger.kernel.org> # v6.13+
> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> ---
> Changelog:
> 
> * Moved this patch out of the v3 series [1] as discussed here [2]
> * Addressed below review comments from Ritesh:
>   - Based the PVR validation on cpu features
>   - Fixed hcall name typo
>   - Stable backport
> 
> [1] https://lore.kernel.org/all/20260522152744.55251-1-amachhiw@linux.ibm.com/
> [2] https://lore.kernel.org/all/20260522152744.55251-2-amachhiw@linux.ibm.com/
> ---
>  arch/powerpc/kvm/book3s_hv.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 61dbeea317f3..e16dbb199366 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -446,7 +446,17 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
>  			guest_pcr_bit = PCR_ARCH_300;
>  			break;
>  		case PVR_ARCH_31:
> +			guest_pcr_bit = PCR_ARCH_31;
> +			break;
>  		case PVR_ARCH_31_P11:
> +			/*
> +			 * Need to check this for ISA 3.1, as Power10 and
> +			 * Power11 share the same PCR. For any subsequent ISA
> +			 * versions, this will be taken care of by the guest vs
> +			 * host PCR comparison below.
> +			 */
> +			if (!cpu_has_feature(CPU_FTR_P11_PVR))
> +				return -EINVAL;
>  			guest_pcr_bit = PCR_ARCH_31;
>  			break;
>  		default:
> 
> base-commit: ba3e43a9e601636f5edb54e259a74f96ca3b8fd8
> -- 
> 2.50.1 (Apple Git-155)
> 

I booted a KVM guest on LPAR with this patch in the following scenarios:
1. P10 guest on P10 host: No error observed
2. P11 guest on P11 host: No error observed
3. P11 guest on P11 host booted in P10 compat mode: No error observed

Tested-by: Gautam Menghani <gautam@linux.ibm.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-04 14:20 ` Gautam Menghani
@ 2026-06-05  7:25   ` Vaibhav Jain
  2026-06-08  8:41     ` Gautam Menghani
  0 siblings, 1 reply; 9+ messages in thread
From: Vaibhav Jain @ 2026-06-05  7:25 UTC (permalink / raw)
  To: Gautam Menghani, Amit Machhiwal
  Cc: linuxppc-dev, Madhavan Srinivasan, Harsh Prateek Bora,
	Ritesh Harjani, Anushree Mathur, Nicholas Piggin,
	Michael Ellerman, Christophe Leroy (CS GROUP), kvm, stable,
	linux-kernel

Hi Gautam,

Thanks for testing this patch. Few questions:
Gautam Menghani <gautam@linux.ibm.com> writes:

> On Wed, Jun 03, 2026 at 07:45:39PM +0530, Amit Machhiwal wrote:
>> On IBM POWER systems, newer processor generations can operate in
>> compatibility modes corresponding to earlier generations. This becomes
>> relevant for nested virtualization, where nested KVM guests may need to
>> run with a specific processor compatibility level.
>> 
<snip>
>
> I booted a KVM guest on LPAR with this patch in the following scenarios:
<snip>

> 3. P11 guest on P11 host booted in P10 compat mode: No error observed
This should have resulted in an error since booting a P11 guest on P10
compat mode host is not allowed with/without this patch. Can you please
check your test env and share the boot results.


>
> Tested-by: Gautam Menghani <gautam@linux.ibm.com>

-- 
Cheers
~ Vaibhav


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-03 14:15 [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode Amit Machhiwal
                   ` (2 preceding siblings ...)
  2026-06-04 14:20 ` Gautam Menghani
@ 2026-06-05  7:30 ` Vaibhav Jain
  3 siblings, 0 replies; 9+ messages in thread
From: Vaibhav Jain @ 2026-06-05  7:30 UTC (permalink / raw)
  To: Amit Machhiwal, linuxppc-dev, Madhavan Srinivasan
  Cc: Amit Machhiwal, Harsh Prateek Bora, Ritesh Harjani,
	Anushree Mathur, Nicholas Piggin, Michael Ellerman,
	Christophe Leroy (CS GROUP), kvm, stable, linux-kernel


Amit Machhiwal <amachhiw@linux.ibm.com> writes:

> On IBM POWER systems, newer processor generations can operate in
> compatibility modes corresponding to earlier generations. This becomes
> relevant for nested virtualization, where nested KVM guests may need to
> run with a specific processor compatibility level.
>
> Currently, when running a nested KVM guest (L2) inside a Power11 pSeries
> logical partition (L1) booted in Power10 compatibility mode, the guest
> fails to boot while setting 'arch_compat'. This happens because the CPU
> class is derived from the hardware PVR (via mfspr()), which reflects the
> physical processor generation (Power11), rather than the effective
> compatibility mode (Power10).
>
> As a result, userspace may request a Power11 arch_compat for the L2
> guest. However, the L1 partition, running in Power10 compatibility, has
> only negotiated support up to Power10 with the Power Hypervisor (L0).
> When H_GUEST_SET_STATE is invoked with a Power11 Logical PVR, the
> hypervisor rejects the request, leading to a late guest boot failure:
>
>   KVM-NESTEDv2: couldn't set guest wide elements
>   [..KVM reg dump..]
>
> This situation should be detected earlier. Rejecting unsupported
> 'arch_compat' values in 'kvmppc_set_arch_compat()' avoids issuing an
> invalid H_GUEST_SET_STATE hcall and provides a clearer failure mode.
>
> Add a check to reject Power11 'arch_compat' requests when the host is
> running in Power10 compatibility mode, returning -EINVAL early instead
> of deferring the failure to the hypervisor.
>
> Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> Tested-by: Anushree Mathur <anushree.mathur@linux.ibm.com>
> Cc: <stable@vger.kernel.org> # v6.13+
> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>

Thanks, this LGTM
Reviewed-by: Vaibhav Jain <vaibhav@linux.ibm.com>

-- 
Cheers
~ Vaibhav


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-05  7:25   ` Vaibhav Jain
@ 2026-06-08  8:41     ` Gautam Menghani
  2026-06-08 10:12       ` Amit Machhiwal
  2026-06-08 14:19       ` Vaibhav Jain
  0 siblings, 2 replies; 9+ messages in thread
From: Gautam Menghani @ 2026-06-08  8:41 UTC (permalink / raw)
  To: Vaibhav Jain
  Cc: Amit Machhiwal, linuxppc-dev, Madhavan Srinivasan,
	Harsh Prateek Bora, Ritesh Harjani, Anushree Mathur,
	Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
	kvm, stable, linux-kernel

On Fri, Jun 05, 2026 at 12:55:50PM +0530, Vaibhav Jain wrote:
> Hi Gautam,
> 
> Thanks for testing this patch. Few questions:
> Gautam Menghani <gautam@linux.ibm.com> writes:
> 
> > On Wed, Jun 03, 2026 at 07:45:39PM +0530, Amit Machhiwal wrote:
> >> On IBM POWER systems, newer processor generations can operate in
> >> compatibility modes corresponding to earlier generations. This becomes
> >> relevant for nested virtualization, where nested KVM guests may need to
> >> run with a specific processor compatibility level.
> >> 
> <snip>
> >
> > I booted a KVM guest on LPAR with this patch in the following scenarios:
> <snip>
> 
> > 3. P11 guest on P11 host booted in P10 compat mode: No error observed
> This should have resulted in an error since booting a P11 guest on P10
> compat mode host is not allowed with/without this patch. Can you please
> check your test env and share the boot results.

- lscpu output (host P11 LPAR booted in p10 compat mode)
# lscpu                                                                                                                                                   03:35:13 [3/3]
Architecture:                ppc64le
  Byte Order:                Little Endian
CPU(s):                      960
  On-line CPU(s) list:       0-959
Model name:                  POWER10 (architected), altivec supported
  Model:                     2.0 (pvr 0082 0200)
  Thread(s) per core:        8
  Core(s) per socket:        15
  Socket(s):                 8
  Physical sockets:          4
  Physical chips:            2
  Physical cores/chip:       16


- lscpu output from guest
# lscpu
Architecture:             ppc64le
  Byte Order:             Little Endian
CPU(s):                   4
  On-line CPU(s) list:    0-3
Model name:               Power11 (raw), altivec supported
  Model:                  2.0 (pvr 0082 0200)
  Thread(s) per core:     1
  Core(s) per socket:     4
  Socket(s):              1



- QEMU command line
/usr/bin/qemu-system-ppc64 -device virtio-blk-pci,drive=drive0,id=virtblk0 \
    -drive file=/home/gautam/images/fc41.qcow2,format=qcow2,if=none,id=drive0 \
    -m 100G -smp 4 -cpu host -nographic -machine pseries,ic-mode=xics -accel kvm


Thanks,
Gautam


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-08  8:41     ` Gautam Menghani
@ 2026-06-08 10:12       ` Amit Machhiwal
  2026-06-08 14:19       ` Vaibhav Jain
  1 sibling, 0 replies; 9+ messages in thread
From: Amit Machhiwal @ 2026-06-08 10:12 UTC (permalink / raw)
  To: Gautam Menghani
  Cc: Vaibhav Jain, Amit Machhiwal, linuxppc-dev, Madhavan Srinivasan,
	Harsh Prateek Bora, Ritesh Harjani, Anushree Mathur,
	Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
	kvm, stable, linux-kernel

Hi Gautam,

Thanks for testing this patch.

On 2026/06/08 02:11 PM, Gautam Menghani wrote:
> On Fri, Jun 05, 2026 at 12:55:50PM +0530, Vaibhav Jain wrote:
> > Hi Gautam,
> > 
> > Thanks for testing this patch. Few questions:
> > Gautam Menghani <gautam@linux.ibm.com> writes:
> > 
> > > On Wed, Jun 03, 2026 at 07:45:39PM +0530, Amit Machhiwal wrote:
> > >> On IBM POWER systems, newer processor generations can operate in
> > >> compatibility modes corresponding to earlier generations. This becomes
> > >> relevant for nested virtualization, where nested KVM guests may need to
> > >> run with a specific processor compatibility level.
> > >> 
> > <snip>
> > >
> > > I booted a KVM guest on LPAR with this patch in the following scenarios:
> > <snip>
> > 
> > > 3. P11 guest on P11 host booted in P10 compat mode: No error observed
> > This should have resulted in an error since booting a P11 guest on P10
> > compat mode host is not allowed with/without this patch. Can you please
> > check your test env and share the boot results.

Yes, this should have errored out if the patch were tested in
combination with the QEMU patches posted here [1]. 

> 
> - lscpu output (host P11 LPAR booted in p10 compat mode)
> # lscpu
> Architecture:                ppc64le
>   Byte Order:                Little Endian
> CPU(s):                      960
>   On-line CPU(s) list:       0-959
> Model name:                  POWER10 (architected), altivec supported
>   Model:                     2.0 (pvr 0082 0200)
>   Thread(s) per core:        8
>   Core(s) per socket:        15
>   Socket(s):                 8
>   Physical sockets:          4
>   Physical chips:            2
>   Physical cores/chip:       16
> 
> 
> - lscpu output from guest
> # lscpu
> Architecture:             ppc64le
>   Byte Order:             Little Endian
> CPU(s):                   4
>   On-line CPU(s) list:    0-3
> Model name:               Power11 (raw), altivec supported
>   Model:                  2.0 (pvr 0082 0200)
>   Thread(s) per core:     1
>   Core(s) per socket:     4
>   Socket(s):              1
> 
> 
> 
> - QEMU command line
> /usr/bin/qemu-system-ppc64 -device virtio-blk-pci,drive=drive0,id=virtblk0 \

So, this patch was indeed tested on a distro qemu binary.

But without the above mentioned QEMU patches, currently the '-EINVAL'
returned in this patch (or any other error returned for the compat
ioctl) is simply ignored by QEMU (which Patch#1 in the QEMU series is
trying to fix) and continues with arch_compat == 0, making the guest
continue with raw PVR support.

Now when we again land up in gs_msg_ops_vcpu_fill_info() in the guest
entry path, with the current logic and arch_compat being 0, we try to
set an appropriate value by looking at the cpu features, which in this
case, turns out to be the P10 LPVR. Subsequently, H_GUEST_SET_STATE is
called with this value of arch_compat and L0 never compalains about it
and guest continues to boot in P11 RAW mode while it shouldn't. The
guest booting in raw mode can be confirmed from the below information
from L2 guest:

  # lsprop /sys/firmware/devicetree/base/cpus/PowerPC\,POWER11@0/cpu-version 
  /sys/firmware/devicetree/base/cpus/PowerPC,POWER11@0/cpu-version
                   00820200 (8520192

Having said this, we should not only be relying on userspace/vmm to
handle this situation but detect this in KVM and error out as
appropriate. I'm currenlty working on the v2 of this patch for handling
this case and will post it after some more testing.


>     -drive file=/home/gautam/images/fc41.qcow2,format=qcow2,if=none,id=drive0 \
>     -m 100G -smp 4 -cpu host -nographic -machine pseries,ic-mode=xics -accel kvm

[1] https://lore.kernel.org/all/20260502140021.69712-1-amachhiw@linux.ibm.com/

Thanks,
Amit

> 
> 
> Thanks,
> Gautam


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode
  2026-06-08  8:41     ` Gautam Menghani
  2026-06-08 10:12       ` Amit Machhiwal
@ 2026-06-08 14:19       ` Vaibhav Jain
  1 sibling, 0 replies; 9+ messages in thread
From: Vaibhav Jain @ 2026-06-08 14:19 UTC (permalink / raw)
  To: Gautam Menghani
  Cc: Amit Machhiwal, linuxppc-dev, Madhavan Srinivasan,
	Harsh Prateek Bora, Ritesh Harjani, Anushree Mathur,
	Nicholas Piggin, Michael Ellerman, Christophe Leroy (CS GROUP),
	kvm, stable, linux-kernel

Gautam Menghani <gautam@linux.ibm.com> writes:

> On Fri, Jun 05, 2026 at 12:55:50PM +0530, Vaibhav Jain wrote:
>> Hi Gautam,
>> 
>> Thanks for testing this patch. Few questions:
>> Gautam Menghani <gautam@linux.ibm.com> writes:
>> 
>> > On Wed, Jun 03, 2026 at 07:45:39PM +0530, Amit Machhiwal wrote:
>> >> On IBM POWER systems, newer processor generations can operate in
>> >> compatibility modes corresponding to earlier generations. This becomes
>> >> relevant for nested virtualization, where nested KVM guests may need to
>> >> run with a specific processor compatibility level.
>> >> 
>> <snip>
>> >
>> > I booted a KVM guest on LPAR with this patch in the following scenarios:
>> <snip>
>> 
>> > 3. P11 guest on P11 host booted in P10 compat mode: No error observed
>> This should have resulted in an error since booting a P11 guest on P10
>> compat mode host is not allowed with/without this patch. Can you please
>> check your test env and share the boot results.
>
> - lscpu output (host P11 LPAR booted in p10 compat mode)
> # lscpu                                                                                                                                                   03:35:13 [3/3]
> Architecture:                ppc64le
>   Byte Order:                Little Endian
> CPU(s):                      960
>   On-line CPU(s) list:       0-959
> Model name:                  POWER10 (architected), altivec supported
>   Model:                     2.0 (pvr 0082 0200)
>   Thread(s) per core:        8
>   Core(s) per socket:        15
>   Socket(s):                 8
>   Physical sockets:          4
>   Physical chips:            2
>   Physical cores/chip:       16
>
>
> - lscpu output from guest
> # lscpu
> Architecture:             ppc64le
>   Byte Order:             Little Endian
> CPU(s):                   4
>   On-line CPU(s) list:    0-3
> Model name:               Power11 (raw), altivec supported
>   Model:                  2.0 (pvr 0082 0200)
>   Thread(s) per core:     1
>   Core(s) per socket:     4
>   Socket(s):              1
>
Argh, this doesnt look right. The kernel patch should have prevented the
P11 compat guest boot on P10 compat host. Looks like you havent used the
corrosponding Qemu patch [1] that could have prevented this from
happening.

Had a off mailing list discussion with Amit on how to address this issue
and he will be sending a new version of the patch to address this issue.


[1] https://lore.kernel.org/all/20260502140021.69712-2-amachhiw@linux.ibm.com/

>
>
> - QEMU command line
> /usr/bin/qemu-system-ppc64 -device virtio-blk-pci,drive=drive0,id=virtblk0 \
>     -drive file=/home/gautam/images/fc41.qcow2,format=qcow2,if=none,id=drive0 \
>     -m 100G -smp 4 -cpu host -nographic -machine pseries,ic-mode=xics -accel kvm
>
>
> Thanks,
> Gautam
>

-- 
Cheers
~ Vaibhav


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-06-08 14:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 14:15 [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode Amit Machhiwal
2026-06-03 15:11 ` Ritesh Harjani
2026-06-03 17:57 ` Mukesh Kumar Chaurasiya
2026-06-04 14:20 ` Gautam Menghani
2026-06-05  7:25   ` Vaibhav Jain
2026-06-08  8:41     ` Gautam Menghani
2026-06-08 10:12       ` Amit Machhiwal
2026-06-08 14:19       ` Vaibhav Jain
2026-06-05  7:30 ` Vaibhav Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox