KVM: arm64: Fix the issues when guest PMCCFILTR is configured
authorWei Huang <wei@redhat.com>
Wed, 16 Nov 2016 17:09:20 +0000 (11:09 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2016 08:56:53 +0000 (09:56 +0100)
commitf271087fb2ea6eb4352340893225655f6ab491d0
treef6650905b667b9d1b471d78c0a033197d43377b9
parent8d8b37e242decffb789cd86f501100dd881ded10
KVM: arm64: Fix the issues when guest PMCCFILTR is configured

commit b112c84a6ff035271d41d548c10215f18443d6a6 upstream.

KVM calls kvm_pmu_set_counter_event_type() when PMCCFILTR is configured.
But this function can't deals with PMCCFILTR correctly because the evtCount
bits of PMCCFILTR, which is reserved 0, conflits with the SW_INCR event
type of other PMXEVTYPER<n> registers. To fix it, when eventsel == 0, this
function shouldn't return immediately; instead it needs to check further
if select_idx is ARMV8_PMU_CYCLE_IDX.

Another issue is that KVM shouldn't copy the eventsel bits of PMCCFILTER
blindly to attr.config. Instead it ought to convert the request to the
"cpu cycle" event type (i.e. 0x11).

To support this patch and to prevent duplicated definitions, a limited
set of ARMv8 perf event types were relocated from perf_event.c to
asm/perf_event.h.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/include/asm/perf_event.h
arch/arm64/kernel/perf_event.c
virt/kvm/arm/pmu.c