On Fri, 15 Dec 2023, Sebastian Ott wrote:
On Thu, 14 Dec 2023, Eric Auger wrote:
On 12/7/23 11:36, Shaoqin Huang wrote:
+ if (kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr)) {
+ warn_report("The kernel doesn't support the PMU Event
Filter!\n");
+ return;
+ }
+
+ /* The filter only needs to be initialized for 1 vcpu. */
Are you sure? This is a per vcpu device ctrl. Where is it written in the
doc that this shall not be called for each vcpu
The interface is per vcpu but the filters are actually managed per vm
(kvm->arch.pmu_filter). From (kernel) commit 6ee7fca2a ("KVM: arm64: Add
KVM_ARM_VCPU_PMU_V3_SET_PMU attribute"):
To ensure that KVM doesn't expose an asymmetric system to the guest, the
PMU set for one VCPU will be used by all other VCPUs. Once a VCPU has run,
the PMU cannot be changed in order to avoid changing the list of available
events for a VCPU, or to change the semantics of existing events.
I've managed to quote the wrong commit. It's that one:
d7eec2360e3 ("KVM: arm64: Add PMU event filtering infrastructure")
Note that although the ioctl is per-vcpu, the map of allowed events is
global to the VM (it can be setup from any vcpu until the vcpu PMU is
initialized).
Sebastian