[PATCH v3 00/14] KVM: arm64: FEAT_PMUv3 on Apple hardware

Oliver Upton posted 14 patches 11 months, 1 week ago
arch/arm64/include/asm/apple_m1_pmu.h   |   1 +
arch/arm64/include/asm/cpucaps.h        |   2 +
arch/arm64/include/asm/cpufeature.h     |  28 +----
arch/arm64/kernel/cpu_errata.c          |  44 ++++++++
arch/arm64/kernel/cpufeature.c          |  28 +++++
arch/arm64/kernel/image-vars.h          |   5 -
arch/arm64/kvm/arm.c                    |   4 +-
arch/arm64/kvm/hyp/include/hyp/switch.h |   4 +-
arch/arm64/kvm/hyp/vhe/switch.c         |  22 ++++
arch/arm64/kvm/pmu-emul.c               | 138 +++++++++++++++++-------
arch/arm64/kvm/pmu.c                    |  10 +-
arch/arm64/tools/cpucaps                |   2 +
drivers/perf/apple_m1_cpu_pmu.c         | 101 +++++++++++++----
include/kvm/arm_pmu.h                   |  12 +--
include/linux/perf/arm_pmu.h            |   4 +
15 files changed, 301 insertions(+), 104 deletions(-)
[PATCH v3 00/14] KVM: arm64: FEAT_PMUv3 on Apple hardware
Posted by Oliver Upton 11 months, 1 week ago
Hopefully close to the last spin, this time addressing Marc's comments
on v2.

Full details found in the v1 cover letter.

v1: https://lore.kernel.org/kvmarm/20241217212048.3709204-1-oliver.upton@linux.dev/
v2: https://lore.kernel.org/kvmarm/20250203183111.191519-1-oliver.upton@linux.dev/

v2 -> v3:
 - Reorder and restructure patches to include map_pmuv3_event()
   definition w/ KVM usage.
 - Disallow events that lack a valid PMUv3 -> HW mapping
 - Various minor fixes/typos

Oliver Upton (14):
  drivers/perf: apple_m1: Refactor event select/filter configuration
  drivers/perf: apple_m1: Support host/guest event filtering
  KVM: arm64: Compute PMCEID from arm_pmu's event bitmaps
  KVM: arm64: Always support SW_INCR PMU event
  KVM: arm64: Use a cpucap to determine if system supports FEAT_PMUv3
  KVM: arm64: Drop kvm_arm_pmu_available static key
  KVM: arm64: Use guard() to cleanup usage of arm_pmus_lock
  KVM: arm64: Move PMUVer filtering into KVM code
  KVM: arm64: Compute synthetic sysreg ESR for Apple PMUv3 traps
  KVM: arm64: Advertise PMUv3 if IMPDEF traps are present
  KVM: arm64: Remap PMUv3 events onto hardware
  drivers/perf: apple_m1: Provide helper for mapping PMUv3 events
  KVM: arm64: Provide 1 event counter on IMPDEF hardware
  arm64: Enable IMP DEF PMUv3 traps on Apple M*

 arch/arm64/include/asm/apple_m1_pmu.h   |   1 +
 arch/arm64/include/asm/cpucaps.h        |   2 +
 arch/arm64/include/asm/cpufeature.h     |  28 +----
 arch/arm64/kernel/cpu_errata.c          |  44 ++++++++
 arch/arm64/kernel/cpufeature.c          |  28 +++++
 arch/arm64/kernel/image-vars.h          |   5 -
 arch/arm64/kvm/arm.c                    |   4 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h |   4 +-
 arch/arm64/kvm/hyp/vhe/switch.c         |  22 ++++
 arch/arm64/kvm/pmu-emul.c               | 138 +++++++++++++++++-------
 arch/arm64/kvm/pmu.c                    |  10 +-
 arch/arm64/tools/cpucaps                |   2 +
 drivers/perf/apple_m1_cpu_pmu.c         | 101 +++++++++++++----
 include/kvm/arm_pmu.h                   |  12 +--
 include/linux/perf/arm_pmu.h            |   4 +
 15 files changed, 301 insertions(+), 104 deletions(-)


base-commit: 0ad2507d5d93f39619fc42372c347d6006b64319
-- 
2.39.5
Re: [PATCH v3 00/14] KVM: arm64: FEAT_PMUv3 on Apple hardware
Posted by Marc Zyngier 11 months ago
On Wed, 05 Mar 2025 20:26:27 +0000,
Oliver Upton <oliver.upton@linux.dev> wrote:
> 
> Hopefully close to the last spin, this time addressing Marc's comments
> on v2.
> 
> Full details found in the v1 cover letter.
> 
> v1: https://lore.kernel.org/kvmarm/20241217212048.3709204-1-oliver.upton@linux.dev/
> v2: https://lore.kernel.org/kvmarm/20250203183111.191519-1-oliver.upton@linux.dev/
> 
> v2 -> v3:
>  - Reorder and restructure patches to include map_pmuv3_event()
>    definition w/ KVM usage.
>  - Disallow events that lack a valid PMUv3 -> HW mapping
>  - Various minor fixes/typos
> 
> Oliver Upton (14):
>   drivers/perf: apple_m1: Refactor event select/filter configuration
>   drivers/perf: apple_m1: Support host/guest event filtering
>   KVM: arm64: Compute PMCEID from arm_pmu's event bitmaps
>   KVM: arm64: Always support SW_INCR PMU event
>   KVM: arm64: Use a cpucap to determine if system supports FEAT_PMUv3
>   KVM: arm64: Drop kvm_arm_pmu_available static key
>   KVM: arm64: Use guard() to cleanup usage of arm_pmus_lock
>   KVM: arm64: Move PMUVer filtering into KVM code
>   KVM: arm64: Compute synthetic sysreg ESR for Apple PMUv3 traps
>   KVM: arm64: Advertise PMUv3 if IMPDEF traps are present
>   KVM: arm64: Remap PMUv3 events onto hardware
>   drivers/perf: apple_m1: Provide helper for mapping PMUv3 events
>   KVM: arm64: Provide 1 event counter on IMPDEF hardware
>   arm64: Enable IMP DEF PMUv3 traps on Apple M*
> 
>  arch/arm64/include/asm/apple_m1_pmu.h   |   1 +
>  arch/arm64/include/asm/cpucaps.h        |   2 +
>  arch/arm64/include/asm/cpufeature.h     |  28 +----
>  arch/arm64/kernel/cpu_errata.c          |  44 ++++++++
>  arch/arm64/kernel/cpufeature.c          |  28 +++++
>  arch/arm64/kernel/image-vars.h          |   5 -
>  arch/arm64/kvm/arm.c                    |   4 +-
>  arch/arm64/kvm/hyp/include/hyp/switch.h |   4 +-
>  arch/arm64/kvm/hyp/vhe/switch.c         |  22 ++++
>  arch/arm64/kvm/pmu-emul.c               | 138 +++++++++++++++++-------
>  arch/arm64/kvm/pmu.c                    |  10 +-
>  arch/arm64/tools/cpucaps                |   2 +
>  drivers/perf/apple_m1_cpu_pmu.c         | 101 +++++++++++++----
>  include/kvm/arm_pmu.h                   |  12 +--
>  include/linux/perf/arm_pmu.h            |   4 +
>  15 files changed, 301 insertions(+), 104 deletions(-)
> 
> 
> base-commit: 0ad2507d5d93f39619fc42372c347d6006b64319

I'm quite happy with the way this looks now (well, apart from patch
#9, but that's not something you can fix...).

Reviewed-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.
Re: [PATCH v3 00/14] KVM: arm64: FEAT_PMUv3 on Apple hardware
Posted by Oliver Upton 11 months ago
On Wed, 05 Mar 2025 12:26:27 -0800, Oliver Upton wrote:
> Hopefully close to the last spin, this time addressing Marc's comments
> on v2.
> 
> Full details found in the v1 cover letter.
> 
> v1: https://lore.kernel.org/kvmarm/20241217212048.3709204-1-oliver.upton@linux.dev/
> v2: https://lore.kernel.org/kvmarm/20250203183111.191519-1-oliver.upton@linux.dev/
> 
> [...]

Applied to next, thanks!

[01/14] drivers/perf: apple_m1: Refactor event select/filter configuration
        https://git.kernel.org/kvmarm/kvmarm/c/75ecffc361bb
[02/14] drivers/perf: apple_m1: Support host/guest event filtering
        https://git.kernel.org/kvmarm/kvmarm/c/46573d944f00
[03/14] KVM: arm64: Compute PMCEID from arm_pmu's event bitmaps
        https://git.kernel.org/kvmarm/kvmarm/c/93b01528586b
[04/14] KVM: arm64: Always support SW_INCR PMU event
        https://git.kernel.org/kvmarm/kvmarm/c/ed335722b457
[05/14] KVM: arm64: Use a cpucap to determine if system supports FEAT_PMUv3
        https://git.kernel.org/kvmarm/kvmarm/c/6f34024d185e
[06/14] KVM: arm64: Drop kvm_arm_pmu_available static key
        https://git.kernel.org/kvmarm/kvmarm/c/a38b67d15183
[07/14] KVM: arm64: Use guard() to cleanup usage of arm_pmus_lock
        https://git.kernel.org/kvmarm/kvmarm/c/3d6d9172128e
[08/14] KVM: arm64: Move PMUVer filtering into KVM code
        https://git.kernel.org/kvmarm/kvmarm/c/56290316a443
[09/14] KVM: arm64: Compute synthetic sysreg ESR for Apple PMUv3 traps
        https://git.kernel.org/kvmarm/kvmarm/c/2c433f70dccc
[10/14] KVM: arm64: Advertise PMUv3 if IMPDEF traps are present
        https://git.kernel.org/kvmarm/kvmarm/c/bed9b8ec8c71
[11/14] KVM: arm64: Remap PMUv3 events onto hardware
        https://git.kernel.org/kvmarm/kvmarm/c/1e7dcbfa4b7c
[12/14] drivers/perf: apple_m1: Provide helper for mapping PMUv3 events
        https://git.kernel.org/kvmarm/kvmarm/c/2d00cab849be
[13/14] KVM: arm64: Provide 1 event counter on IMPDEF hardware
        https://git.kernel.org/kvmarm/kvmarm/c/1b92e65f5006
[14/14] arm64: Enable IMP DEF PMUv3 traps on Apple M*
        https://git.kernel.org/kvmarm/kvmarm/c/e1231aacb065

--
Best,
Oliver