Skip to content

KVM: arm64: Fixes for guest-only PMU event overflows on Apple Silicon

Oliver Upton asahi kvmarm linux-arm-kernel linux-perf-users lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: arm64: Track IRQ and FIQ exceptions separatelyarch/arm64/include/asm/kvm_asm.h arch/arm64/kvm/arm.c arch/arm64/kvm/handle_exit.c +4 more+25 -82 replies
2/4perf kvm stat: Add new 'ARM_EXCEPTION_FIQ' exception typetools/perf/util/kvm-stat-arch/arm64_exception_types.h+2 -00 replies
3/4KVM: arm64: Let the irqchip provide a fixup for FIQs taken to EL2arch/arm64/kvm/arm.c arch/arm64/kvm/vgic/vgic-init.c arch/arm64/kvm/vgic/vgic.h +2 more+25 -00 replies
4/4irqchip/apple-aic: Work around FIQ storms upon vPMU counter overflowdrivers/irqchip/irq-apple-aic.c+31 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] KVM: arm64: Fixes for guest-only PMU event overflows on Apple Silicon

A rather annoying detail of the Apple CPU PMU is that the FIQ appears to depend on the event filter configuration / value of HCR_EL2.TGE. Events that filter out the host ELs do not appear to drive the FIQ line when HCR_EL2.TGE=1.

This manifests when using the vPMU for sampling inside of a KVM guest, as the overflowed PMU generates a storm of FIQs that are no longer pending by the time interrupts are unmasked.

This series performs a rather disgusting hack to work around the issue, forcing a pending FIQ by performing a self-IPI when exiting due to a FIQ and the PMU is in an interrupt condition. The mitigation works on all implementations that support PMUv3 traps as the 'fast' IPI feature (IPIs taken as a FIQ) long predates vPMU support.

Applies to 7.4-rc3, tested with various perf record invocations in an L1 KVM guest.

Oliver Upton (4):
KVM: arm64: Track IRQ and FIQ exceptions separately
perf kvm stat: Add new 'ARM_EXCEPTION_FIQ' exception type
KVM: arm64: Let the irqchip provide a fixup for FIQs taken to EL2 irqchip/apple-aic: Work around FIQ storms upon vPMU counter overflow

 arch/arm64/include/asm/kvm_asm.h              | 12 ++++---
 arch/arm64/kvm/arm.c                          |  5 ++-
 arch/arm64/kvm/handle_exit.c                  |  1 +
 arch/arm64/kvm/hyp/entry.S                    |  6 ++++
 arch/arm64/kvm/hyp/hyp-entry.S                |  6 +++-
 arch/arm64/kvm/hyp/include/hyp/switch.h       |  4 +--
 arch/arm64/kvm/hyp/nvhe/hyp-main.c            |  2 ++
 arch/arm64/kvm/vgic/vgic-init.c               |  6 ++++
 arch/arm64/kvm/vgic/vgic.h                    |  9 +++++
 drivers/irqchip/irq-apple-aic.c               | 33 +++++++++++++++++--
 include/kvm/arm_vgic.h                        |  4 +++
 include/linux/irqchip/arm-vgic-info.h         |  3 ++
 .../kvm-stat-arch/arm64_exception_types.h     |  2 ++
 13 files changed, 83 insertions(+), 10 deletions(-)

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3

Signature · 1 line
2.47.3