On Tue, Jan 31, 2023 at 04:50:31PM +0800, Like Xu wrote: > From: Like Xu <likexu@xxxxxxxxxxx> > > Disable KVM support for virtualizing PMUs on hosts with hybrid PMUs until > KVM gains a sane way to enumeration the hybrid vPMU to userspace and/or > gains a mechanism to let userspace opt-in to the dangers of exposing a > hybrid vPMU to KVM guests. > > Virtualizing a hybrid PMU, or at least part of a hybrid PMU, is possible, > but it requires userspace to pin vCPUs to pCPUs to prevent migrating a > vCPU between a big core and a little core, requires the VMM to accurately > enumerate the topology to the guest (if exposing a hybrid CPU to the > guest), and also requires the VMM to accurately enumerate the vPMU > capabilities to the guest. > > The last point is especially problematic, as KVM doesn't control which > pCPU it runs on when enumerating KVM's vPMU capabilities to userspace. > For now, simply disable vPMU support on hybrid CPUs to avoid inducing > seemingly random #GPs in guests. > > Reported-by: Jianfeng Gao <jianfeng.gao@xxxxxxxxx> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx> > Signed-off-by: Like Xu <likexu@xxxxxxxxxxx> This seems reasonable; Paolo, will you take this through the KVM tree? Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> > --- > v1: https://lore.kernel.org/all/20230120004051.2043777-1-seanjc@xxxxxxxxxx/ > arch/x86/kvm/pmu.h | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h > index 79988dafb15b..6a3995657e1e 100644 > --- a/arch/x86/kvm/pmu.h > +++ b/arch/x86/kvm/pmu.h > @@ -166,9 +166,11 @@ static inline void kvm_init_pmu_capability(const struct kvm_pmu_ops *pmu_ops) > > /* > * For Intel, only support guest architectural pmu > - * on a host with architectural pmu. > + * on a non-hybrid host with architectural pmu. > */ > - if ((is_intel && !kvm_pmu_cap.version) || !kvm_pmu_cap.num_counters_gp) > + if (!kvm_pmu_cap.num_counters_gp || > + (is_intel && (!kvm_pmu_cap.version || > + boot_cpu_has(X86_FEATURE_HYBRID_CPU)))) > enable_pmu = false; > > if (!enable_pmu) { > -- > 2.39.1 >