KVM: x86: Init vcpu->arch.perf_capabilities in common x86 code
authorSean Christopherson <seanjc@google.com>
Thu, 6 Oct 2022 00:03:12 +0000 (00:03 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 9 Nov 2022 17:31:12 +0000 (12:31 -0500)
Initialize vcpu->arch.perf_capabilities in x86's kvm_arch_vcpu_create()
instead of deferring initialization to vendor code.  For better or worse,
common x86 handles reads and writes to the MSR, and so common x86 should
also handle initializing the MSR.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221006000314.73240-7-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/pmu_intel.c
arch/x86/kvm/x86.c

index 9fabfe71fd87959f62792cea4dd7e6d92c291756..b7c3a9874a93cc8de5c9273711be861f0af0b075 100644 (file)
@@ -631,7 +631,6 @@ static void intel_pmu_init(struct kvm_vcpu *vcpu)
                pmu->fixed_counters[i].current_config = 0;
        }
 
-       vcpu->arch.perf_capabilities = kvm_caps.supported_perf_cap;
        lbr_desc->records.nr = 0;
        lbr_desc->event = NULL;
        lbr_desc->msr_passthrough = false;
index ecea83f0da498fbba6e4f1887012cbd59fa95390..6ce7c80180d242de80e6ca6e2aaad8cfff85cc1b 100644 (file)
@@ -11893,6 +11893,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
        vcpu->arch.pat = MSR_IA32_CR_PAT_DEFAULT;
 
        kvm_async_pf_hash_reset(vcpu);
+
+       vcpu->arch.perf_capabilities = kvm_caps.supported_perf_cap;
        kvm_pmu_init(vcpu);
 
        vcpu->arch.pending_external_vector = -1;