KVM: vmx, pmu: accept 0 for host-initiated write to MSR_IA32_DS_AREA
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 1 Jun 2022 07:21:19 +0000 (03:21 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Jun 2022 08:48:37 +0000 (04:48 -0400)
Whenever an MSR is part of KVM_GET_MSR_INDEX_LIST, as is the case
for MSR_IA32_DS_AREA, it has to be always settable with KVM_SET_MSR.
Accept a zero value for these MSRs to obey the contract.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/pmu_intel.c

index 2fc90080dcce0d706b2b6b610252a3591b6dc931..5bc7cfc753fc149f4da063acdd5cdbc233782f22 100644 (file)
@@ -443,6 +443,8 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
                }
                break;
        case MSR_IA32_DS_AREA:
+               if (msr_info->host_initiated && data && !guest_cpuid_has(vcpu, X86_FEATURE_DS))
+                       return 1;
                if (is_noncanonical_address(data, vcpu))
                        return 1;
                pmu->ds_area = data;