]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: x86: Return "unsupported" instead of "invalid" on access to unsupported PV MSR
authorSean Christopherson <seanjc@google.com>
Tue, 30 Dec 2025 20:59:48 +0000 (12:59 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 8 Jan 2026 19:59:53 +0000 (11:59 -0800)
commit5bb9ac1865123356337a389af935d3913ee917ed
tree38f57d5023a574581b6af3cbd8c71a5545752094
parentb47b93c15b12c7a9e560729aa6ad609466f83f0e
KVM: x86: Return "unsupported" instead of "invalid" on access to unsupported PV MSR

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@vger.kernel.org
Reviewed-by: Jim Mattson <jmattson@google.com>
Link: https://patch.msgid.link/20251230205948.4094097-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c