From: Sean Christopherson Date: Sat, 11 Jun 2022 00:57:50 +0000 (+0000) Subject: KVM: VMX: Give host userspace full control of MSR_IA32_PERF_CAPABILITIES X-Git-Tag: v6.1-rc5~719^2~6^2~186 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f4a7185270c4879fa40b33d7e07b6ac38353b34;p=platform%2Fkernel%2Flinux-starfive.git KVM: VMX: Give host userspace full control of MSR_IA32_PERF_CAPABILITIES Do not clear manipulate MSR_IA32_PERF_CAPABILITIES in intel_pmu_refresh(), i.e. give userspace full control over capability/read-only MSRs. KVM is not a babysitter, it is userspace's responsiblity to provide a valid and coherent vCPU model. Attempting to "help" the guest by forcing a consistent model creates edge cases, and ironicially leads to inconsistent behavior. Example #1: KVM doesn't do intel_pmu_refresh() when userspace writes the MSR. Example #2: KVM doesn't clear the bits when the PMU is disabled, or when there's no architectural PMU. Signed-off-by: Sean Christopherson Message-Id: <20220611005755.753273-3-seanjc@google.com> Signed-off-by: Paolo Bonzini --- diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 3b324ce..b620127 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -619,8 +619,6 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) pmu->pebs_enable_mask = ~((1ull << pmu->nr_arch_gp_counters) - 1); } - } else { - vcpu->arch.perf_capabilities &= ~PERF_CAP_PEBS_MASK; } }