On 11/19/2024 10:54 PM, Sean Christopherson wrote: > On Thu, Aug 01, 2024, Mingwei Zhang wrote: >> Plumb through pass-through PMU setting from kvm->arch into kvm_pmu on each >> vcpu created. Note that enabling PMU is decided by VMM when it sets the >> CPUID bits exposed to guest VM. So plumb through the enabling for each pmu >> in intel_pmu_refresh(). > Why? As with the per-VM snapshot, I see zero reason for this to exist, it's > simply: > > kvm->arch.enable_pmu && enable_mediated_pmu && pmu->version; > > And in literally every correct usage of pmu->passthrough, kvm->arch.enable_pmu > and pmu->version have been checked (though implicitly), i.e. KVM can check > enable_mediated_pmu and nothing else. Ok, too many passthrough_pmu flags indeed confuse readers. Besides these dependencies, mediated vPMU also depends on lapic_in_kernel(). We need to set enable_mediated_pmu to false as well if lapic_in_kernel() returns false.