Re: [PATCH] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode

From: Vaibhav Jain

Date: Fri Jun 05 2026 - 03:31:06 EST



Amit Machhiwal <amachhiw@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>
> Tested-by: Anushree Mathur <anushree.mathur@xxxxxxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx> # v6.13+
> Signed-off-by: Amit Machhiwal <amachhiw@xxxxxxxxxxxxx>

Thanks, this LGTM
Reviewed-by: Vaibhav Jain <vaibhav@xxxxxxxxxxxxx>

--
Cheers
~ Vaibhav