On Thu, Nov 18, 2021 at 5:25 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote: > > On 11/17/21 09:03, Like Xu wrote: > > From: Like Xu <likexu@xxxxxxxxxxx> > > > > For Intel, the guest PMU can be disabled via clearing the PMU CPUID. > > For AMD, all hw implementations support the base set of four > > performance counters, with current mainstream hardware indicating > > the presence of two additional counters via X86_FEATURE_PERFCTR_CORE. > > > > In the virtualized world, the AMD guest driver may detect > > the presence of at least one counter MSR. Most hypervisor > > vendors would introduce a module param (like lbrv for svm) > > to disable PMU for all guests. > > > > Another control proposal per-VM is to pass PMU disable information > > via MSR_IA32_PERF_CAPABILITIES or one bit in CPUID Fn4000_00[FF:00]. > > Both of methods require some guest-side changes, so a module > > parameter may not be sufficiently granular, but practical enough. > > > > Signed-off-by: Like Xu <likexu@xxxxxxxxxxx> > > --- Thanks for this patch. It saves us from upstreaming our equivalent patch. In the long run, I'd like to be able to override this system-wide setting on a per-VM basis, for VMs that I trust. (Of course, this implies that I trust the userspace process as well.) How would you feel if we were to add a kvm ioctl to override this setting, for a particular VM, guarded by an appropriate permissions check, like capable(CAP_SYS_ADMIN) or capable(CAP_SYS_MODULE)?