[PATCH v1] KVM: arm64: Use the host kvm_host_data for nr_event_counters
Fuad Tabba
fuad.tabba at linux.dev
Fri Oct 23 05:29:04 PDT 2026
Hi Vincent,
On Fri, 23 Oct 2026 10:20:07 +0100, Vincent Donnefort
<vdonnefort at google.com> wrote:
[...]
> So kvm_init_host_debug_data() initialises nr_event_counters in the
> hypervisor's kvm_host_data, while kvm_arm_setup_mdcr_el2() reads the
> host copy which is 0. With a HPMN of 0, this stops programmable event
> counters from counting a non-protected guest.
I tested this in pKVM with a non-protected guest counting with
perf_event_open(). On its own the patch doesn't change what the guest
sees: every counter, the cycle counter included, still reads 0. That's
a separate bug: flush_hyp_vcpu() never copies vcpu->arch.pmu.events to
the hyp vCPU, so the guest's events are never enabled on entry. I'll
send a fix for that shortly.
With that fix applied, the cycle counter counts without your patch but
a programmable counter still reads 0, and with your patch both count.
Reviewed-by: Fuad Tabba <fuad.tabba at linux.dev>
Tested-by: Fuad Tabba <fuad.tabba at linux.dev>
Cheers,
/fuad
More information about the linux-arm-kernel
mailing list