Re: [PATCH] KVM: x86: Return "unsupported" instead of "invalid" on access to unsupported PV MSR

From: Jim Mattson

Date: Mon Jan 05 2026 - 13:25:51 EST


On Tue, Dec 30, 2025 at 12:59 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> Return KVM_MSR_RET_UNSUPPORTED instead of '1' (which for all intents and
> purposes means "invalid") when rejecting accesses to KVM PV MSRs to adhere
> to KVM's ABI of allowing host reads and writes of '0' to MSRs that are
> advertised to userspace via KVM_GET_MSR_INDEX_LIST, even if the vCPU model
> doesn't support the MSR.
>
> E.g. running a QEMU VM with
>
> -cpu host,-kvmclock,kvm-pv-enforce-cpuid
>
> yields:
>
> qemu: error: failed to set MSR 0x12 to 0x0
> qemu: target/i386/kvm/kvm.c:3301: kvm_buf_set_msrs:
> Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed.
>
> Fixes: 66570e966dd9 ("kvm: x86: only provide PV features if enabled in guest's CPUID")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>