linux-stable/include/kvm
Marc Zyngier eb3df96102 KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode
[ Upstream commit bead02204e ]

Ricardo recently pointed out that the PMU chained counter emulation
in KVM wasn't quite behaving like the one on actual hardware, in
the sense that a chained counter would expose an overflow on
both halves of a chained counter, while KVM would only expose the
overflow on the top half.

The difference is subtle, but significant. What does the architecture
say (DDI0087 H.a):

- Up to PMUv3p4, all counters but the cycle counter are 32bit

- A 32bit counter that overflows generates a CHAIN event on the
  adjacent counter after exposing its own overflow status

- The CHAIN event is accounted if the counter is correctly
  configured (CHAIN event selected and counter enabled)

This all means that our current implementation (which uses 64bit
perf events) prevents us from emulating this overflow on the lower half.

How to fix this? By implementing the above, to the letter.

This largely results in code deletion, removing the notions of
"counter pair", "chained counters", and "canonical counter".
The code is further restructured to make the CHAIN handling similar
to SWINC, as the two are now extremely similar in behaviour.

Reported-by: Ricardo Koller <ricarkol@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Reiji Watanabe <reijiw@google.com>
Link: https://lore.kernel.org/r/20221113163832.3154370-3-maz@kernel.org
Stable-dep-of: f6da81f650 ("KVM: arm64: PMU: Don't save PMCR_EL0.{C,P} for the vCPU")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-13 16:55:17 +02:00
..
arm_arch_timer.h KVM: arm64: Simplify kvm_cpu_has_pending_timer() 2022-04-20 13:24:44 +01:00
arm_hypercalls.h KVM: arm64: Setup a framework for hypercall bitmap firmware registers 2022-05-03 21:30:19 +01:00
arm_pmu.h KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode 2023-04-13 16:55:17 +02:00
arm_psci.h KVM: arm64: Factor out firmware register handling from psci.c 2022-05-03 14:48:54 +01:00
arm_vgic.h KVM: arm64: vgic: Consolidate userspace access for base address setting 2022-07-17 11:55:33 +01:00
iodev.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 342 2019-06-05 17:37:07 +02:00