* Re: [PATCH 00/18] KVM: arm64: Support FEAT_PMUv3 on Apple hardware
[not found] <20241217212048.3709204-1-oliver.upton@linux.dev>
@ 2024-12-21 13:45 ` Janne Grunau
2024-12-21 22:00 ` Oliver Upton
0 siblings, 1 reply; 2+ messages in thread
From: Janne Grunau @ 2024-12-21 13:45 UTC (permalink / raw)
To: Oliver Upton
Cc: kvmarm, Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Mingwei Zhang, Colton Lewis, Raghavendra Rao Ananta,
Catalin Marinas, Will Deacon, Mark Rutland, linux-arm-kernel,
linux-kernel, asahi
On Tue, Dec 17, 2024 at 01:20:30PM -0800, Oliver Upton wrote:
> One of the interesting features of some Apple M* parts is an IMPDEF trap
> that routes EL1/EL0 accesses of the PMUv3 registers to EL2. This allows
> a hypervisor to emulate an architectural PMUv3 on top of the IMPDEF PMU
> hardware present in the CPU.
>
> And if you squint, this _might_ look like a CPU erratum :-)
>
> This series takes advantage of these IMPDEF traps to provide PMUv3 to
> KVM guests. As a starting point, only expose the fixed CPU cycle counter
> and no event counters. Conveniently, this is enough to get Windows
> running as a KVM guest on Apple hardware.
>
> I've tried to keep the deviation to a minimum by refactoring some of the
> flows used for PMUv3, e.g. computing PMCEID from the arm_pmu bitmap
> instead of reading hardware directly.
>
> RFC -> v1:
> - Rebase to 6.13-rc3
> - Add support for 1 event counter in addition to CPU cycle counter
> - Don't sneak past the PMU event filter (Marc)
> - Have the PMU driver provide a PMUv3 -> HW event ID mapping (Marc)
>
> Tested on my M2 with Linux and Windows guests. If possible, I'd
> appreciate someone testing on an M1 as I haven't added those MIDRs to
> the erratum yet.
Tested on M1 (t8103) with perf in a Linux guest and the patch below
Tested-by: Janne Grunau <j@jannau.net>
I'll import this into the downstream asahi kernel as there was a request
for performance counters to aid FEX-Emu development recently.
Janne
---
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 441ee4ffc7709..45ef67ec970f5 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -195,6 +195,12 @@ has_neoverse_n1_erratum_1542419(const struct arm64_cpu_capabilities *entry,
}
static const struct midr_range impdef_pmuv3_cpus[] = {
+ MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM),
+ MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM),
+ MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM_PRO),
+ MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM_PRO),
+ MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM_MAX),
+ MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM_MAX),
MIDR_ALL_VERSIONS(MIDR_APPLE_M2_BLIZZARD),
MIDR_ALL_VERSIONS(MIDR_APPLE_M2_AVALANCHE),
MIDR_ALL_VERSIONS(MIDR_APPLE_M2_BLIZZARD_PRO),
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 00/18] KVM: arm64: Support FEAT_PMUv3 on Apple hardware
2024-12-21 13:45 ` [PATCH 00/18] KVM: arm64: Support FEAT_PMUv3 on Apple hardware Janne Grunau
@ 2024-12-21 22:00 ` Oliver Upton
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Upton @ 2024-12-21 22:00 UTC (permalink / raw)
To: Janne Grunau
Cc: kvmarm, Marc Zyngier, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Mingwei Zhang, Colton Lewis, Raghavendra Rao Ananta,
Catalin Marinas, Will Deacon, Mark Rutland, linux-arm-kernel,
linux-kernel, asahi
On Sat, Dec 21, 2024 at 02:45:49PM +0100, Janne Grunau wrote:
> On Tue, Dec 17, 2024 at 01:20:30PM -0800, Oliver Upton wrote:
> > One of the interesting features of some Apple M* parts is an IMPDEF trap
> > that routes EL1/EL0 accesses of the PMUv3 registers to EL2. This allows
> > a hypervisor to emulate an architectural PMUv3 on top of the IMPDEF PMU
> > hardware present in the CPU.
> >
> > And if you squint, this _might_ look like a CPU erratum :-)
> >
> > This series takes advantage of these IMPDEF traps to provide PMUv3 to
> > KVM guests. As a starting point, only expose the fixed CPU cycle counter
> > and no event counters. Conveniently, this is enough to get Windows
> > running as a KVM guest on Apple hardware.
> >
> > I've tried to keep the deviation to a minimum by refactoring some of the
> > flows used for PMUv3, e.g. computing PMCEID from the arm_pmu bitmap
> > instead of reading hardware directly.
> >
> > RFC -> v1:
> > - Rebase to 6.13-rc3
> > - Add support for 1 event counter in addition to CPU cycle counter
> > - Don't sneak past the PMU event filter (Marc)
> > - Have the PMU driver provide a PMUv3 -> HW event ID mapping (Marc)
> >
> > Tested on my M2 with Linux and Windows guests. If possible, I'd
> > appreciate someone testing on an M1 as I haven't added those MIDRs to
> > the erratum yet.
>
> Tested on M1 (t8103) with perf in a Linux guest and the patch below
>
> Tested-by: Janne Grunau <j@jannau.net>
>
> I'll import this into the downstream asahi kernel as there was a request
> for performance counters to aid FEX-Emu development recently.
>
> Janne
Awesome, greatly appreciate the testing Janne. Hopefully we can get this
worked out for upstream too :)
--
Thanks,
Oliver
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-21 22:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241217212048.3709204-1-oliver.upton@linux.dev>
2024-12-21 13:45 ` [PATCH 00/18] KVM: arm64: Support FEAT_PMUv3 on Apple hardware Janne Grunau
2024-12-21 22:00 ` Oliver Upton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox