KVM: x86: Allow HWCR.McStatusWrEn to be cleared once set
authorJim Mattson <jmattson@google.com>
Fri, 29 Sep 2023 23:02:44 +0000 (16:02 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 9 Oct 2023 19:36:15 +0000 (12:36 -0700)
When HWCR is set to 0, store 0 in vcpu->arch.msr_hwcr.

Fixes: 191c8137a939 ("x86/kvm: Implement HWCR support")
Signed-off-by: Jim Mattson <jmattson@google.com>
Link: https://lore.kernel.org/r/20230929230246.1954854-2-jmattson@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index 42b33ef997a5d40bd6d9a308979ca95ffed43285..6f4534046803a9f2f72688de626e55685049cf67 100644 (file)
@@ -3791,12 +3791,11 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
                data &= ~(u64)0x8;      /* ignore TLB cache disable */
 
                /* Handle McStatusWrEn */
-               if (data == BIT_ULL(18)) {
-                       vcpu->arch.msr_hwcr = data;
-               } else if (data != 0) {
+               if (data & ~BIT_ULL(18)) {
                        kvm_pr_unimpl_wrmsr(vcpu, msr, data);
                        return 1;
                }
+               vcpu->arch.msr_hwcr = data;
                break;
        case MSR_FAM10H_MMIO_CONF_BASE:
                if (data != 0) {