Re: [RFC PATCH v3 7/8] perf: arm_pmuv3: Keep out of guest counter partition

2025-03-25 Thread Colton Lewis
James Clark writes: On 13/02/2025 6:03 pm, Colton Lewis wrote: If the PMU is partitioned, keep the driver out of the guest counter partition and only use the host counter partition. Partitioning is defined by the MDCR_EL2.HPMN register field and saved in cpu_pmu->hpmn. The range 0..HPMN-1

Re: [RFC PATCH v3 5/8] KVM: arm64: Introduce module param to partition the PMU

2025-03-25 Thread Colton Lewis
Hi James, Thanks for the review. James Clark writes: On 13/02/2025 6:03 pm, Colton Lewis wrote: For PMUv3, the register MDCR_EL2.HPMN partitiones the PMU counters into two ranges where counters 0..HPMN-1 are accessible by EL1 and, if allowed, EL0 while counters HPMN..N are only accessible

Re: [RFC PATCH v3 5/8] KVM: arm64: Introduce module param to partition the PMU

2025-02-13 Thread Colton Lewis
Colton Lewis writes: For PMUv3, the register MDCR_EL2.HPMN partitiones the PMU counters into two ranges where counters 0..HPMN-1 are accessible by EL1 and, if allowed, EL0 while counters HPMN..N are only accessible by EL2. Introduce a module parameter in KVM to set this register. The name

[RFC PATCH v3 7/8] perf: arm_pmuv3: Keep out of guest counter partition

2025-02-13 Thread Colton Lewis
EL2. Define some macros that take HPMN as an argument and construct mutually exclusive bitmaps for testing which partition a particular counter is in. Note that despite their different position in the bitmap, the cycle and instruction counters are always in the guest partition. Signed-off-by: Col

[RFC PATCH v3 8/8] KVM: arm64: selftests: Reword selftests error

2025-02-13 Thread Colton Lewis
It's possible the host has that many counters, but HPMN restricts us from using them. Signed-off-by: Colton Lewis --- tools/testing/selftests/kvm/arm64/vpmu_counter_access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/

[RFC PATCH v3 5/8] KVM: arm64: Introduce module param to partition the PMU

2025-02-13 Thread Colton Lewis
accessible to EL2. The parameter is only configurable at boot time. Making the parameter configurable on a running system is dangerous due to the difficulty of knowing for sure no counters are in use anywhere so it is safe to reporgram HPMN. Signed-off-by: Colton Lewis --- arch/arm64/include/asm

[RFC PATCH v3 6/8] perf: arm_pmuv3: Generalize counter bitmasks

2025-02-13 Thread Colton Lewis
These bitmasks are valid for enable and interrupt registers as well as overflow registers. Generalize the names. Signed-off-by: Colton Lewis --- include/linux/perf/arm_pmuv3.h | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/perf/arm_pmuv3.h

[RFC PATCH v3 4/8] KVM: arm64: Reorganize PMU functions

2025-02-13 Thread Colton Lewis
A lot of functions in pmu-emul.c aren't specific to the emulated PMU implementation. Move them to the more appropriate pmu.c file where shared PMU functions should live. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/pmu-emul.c

[RFC PATCH v3 0/8] PMU partitioning driver support

2025-02-13 Thread Colton Lewis
scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/pmu-includes Colton Lewis (7): arm64: cpufeature: Add cap for HPMN0 arm64: Generate sign macro for sysreg Enums KVM: arm64: Reorganize PMU functions KVM: arm64: Introduce module param to partition the PMU perf: arm_pmuv3: General

[RFC PATCH v3 3/8] KVM: arm64: Cleanup PMU includes

2025-02-13 Thread Colton Lewis
Zyngier Signed-off-by: Colton Lewis --- arch/arm64/include/asm/arm_pmuv3.h | 2 +- arch/arm64/include/asm/kvm_host.h | 198 +-- arch/arm64/include/asm/kvm_pmu.h| 38 + arch/arm64/kvm/arm.c| 1 - arch/arm64/kvm/debug.c

[RFC PATCH v3 2/8] arm64: Generate sign macro for sysreg Enums

2025-02-13 Thread Colton Lewis
There's no reason Enums shouldn't be equivalent to UnsignedEnums and explicitly specify they are unsigned. Signed-off-by: Colton Lewis --- arch/arm64/tools/gen-sysreg.awk | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg

[RFC PATCH v3 1/8] arm64: cpufeature: Add cap for HPMN0

2025-02-13 Thread Colton Lewis
: Colton Lewis --- arch/arm64/kernel/cpufeature.c | 8 arch/arm64/tools/cpucaps | 1 + arch/arm64/tools/sysreg| 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 4eb7c6698ae4..396327b4da7d

Re: [RFC PATCH v2 2/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-02-10 Thread Colton Lewis
Hi Oliver, thanks for the review. Oliver Upton writes: Hi Colton, On Sat, Feb 08, 2025 at 02:01:09AM +, Colton Lewis wrote: For PMUv3, the register MDCR_EL2.HPMN partitiones the PMU counters into two ranges where counters 0..HPMN-1 are accessible by EL1 and, if allowed, EL0 while

Re: [RFC PATCH v2 4/4] KVM: arm64: Make guests see only counters they can access

2025-02-10 Thread Colton Lewis
Hi Oliver, thanks for the review. Oliver Upton writes: On Sat, Feb 08, 2025 at 02:01:11AM +, Colton Lewis wrote: The ARM architecture specifies that when MDCR_EL2.HPMN is set, EL1 and EL0, which includes KVM guests, should read that value for PMCR.N. Signed-off-by: Colton Lewis

[RFC PATCH v2 4/4] KVM: arm64: Make guests see only counters they can access

2025-02-07 Thread Colton Lewis
The ARM architecture specifies that when MDCR_EL2.HPMN is set, EL1 and EL0, which includes KVM guests, should read that value for PMCR.N. Signed-off-by: Colton Lewis --- arch/arm64/kvm/debug.c | 3 +-- arch/arm64/kvm/pmu-emul.c | 8

[RFC PATCH v2 2/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-02-07 Thread Colton Lewis
erous due to the difficulty of knowing for sure no counters are in use anywhere so it is safe to reporgram HPMN. Signed-off-by: Colton Lewis --- arch/arm/include/asm/arm_pmuv3.h | 13 + arch/arm64/include/asm/arm_pmuv3.h | 10 +++ drivers/perf/arm_pmuv3.c

[RFC PATCH v2 3/4] perf: arm_pmuv3: Keep out of guest counter partition

2025-02-07 Thread Colton Lewis
EL2. Define some macros that take HPMN as an argument and construct mutually exclusive bitmaps for testing which partition a particular counter is in. Note that despite their different position in the bitmap, the cycle and instruction counters are always in the guest partition. Signed-off-by: Col

[RFC PATCH v2 1/4] perf: arm_pmuv3: Generalize counter bitmasks

2025-02-07 Thread Colton Lewis
These bitmasks are valid for enable and interrupt registers as well as overflow registers. Generalize the names. Signed-off-by: Colton Lewis --- include/linux/perf/arm_pmuv3.h | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/perf/arm_pmuv3.h

[RFC PATCH v2 0/4] PMU partitioning driver support

2025-02-07 Thread Colton Lewis
asks are only defined for arm64. I'm not sure how to avoid the duplication. * Wrap code for determining if a counter index belongs to the host or guest partition in functions * Typo fixes and additional testing v1: https://lore.kernel.org/kvm/20250127222031.3078945-1-coltonle...@google.c

Re: [RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-02-03 Thread Colton Lewis
Colton Lewis writes: Marc Zyngier writes: On Tue, 28 Jan 2025 22:08:27 +, Colton Lewis wrote: >> + bitmap_set(cpu_pmu->cntr_mask, 0, pmcr_n); >> + >> + if (reserved_guest_counters > 0 && reserved_guest_counters < pmcr_n

Re: [RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-01-29 Thread Colton Lewis
Marc Zyngier writes: On Tue, 28 Jan 2025 22:08:27 +, Colton Lewis wrote: >> + bitmap_set(cpu_pmu->cntr_mask, 0, pmcr_n); >> + >> + if (reserved_guest_counters > 0 && reserved_guest_counters < pmcr_n) { >> +

Re: [RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-01-28 Thread Colton Lewis
Colton Lewis writes: Hey Marc, thanks for looking. *for the review Marc Zyngier writes: On Mon, 27 Jan 2025 22:20:27 +, Colton Lewis wrote: /* Read the nb of CNTx counters supported from PMNC */ - bitmap_set(cpu_pmu->cntr_mask, - 0, FIELD_

Re: [RFC PATCH 4/4] perf: arm_pmuv3: Keep out of guest counter partition

2025-01-28 Thread Colton Lewis
Suzuki K Poulose writes: On 27/01/2025 22:20, Colton Lewis wrote: /* Disable all counters */ - armv8pmu_pmcr_write(armv8pmu_pmcr_read() & ~ARMV8_PMU_PMCR_E); + if (cpu_pmu->partitioned) + armv8pmu_mdcr_write(armv8pmu_pmcr_read() & ~ARMV8_PM

Re: [RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-01-28 Thread Colton Lewis
Hey Rob, thanks for the review. Rob Herring writes: On Mon, Jan 27, 2025 at 4:26 PM Colton Lewis wrote: @@ -1215,10 +1243,19 @@ static void __armv8pmu_probe_pmu(void *info) cpu_pmu->pmuver = pmuver; probe->present = true; + pmcr_n = FIELD_GET(ARMV8_PMU_

Re: [RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-01-28 Thread Colton Lewis
Hey Marc, thanks for looking. Marc Zyngier writes: On Mon, 27 Jan 2025 22:20:27 +, Colton Lewis wrote: For PMUv3, the register MDCR_EL2.HPMN partitiones the PMU counters into two ranges where counters 0..HPMN-1 are accessible by EL1 and, if allowed, EL0 while counters HPMN..N are only

[RFC PATCH 4/4] perf: arm_pmuv3: Keep out of guest counter partition

2025-01-27 Thread Colton Lewis
EL2. Define some macros that take HPMN as an argument and construct mutually exclusive bitmaps for testing which partition a particular counter is in. Note that despite their different position in the bitmap, the cycle and instruction counters are always in the guest partition. Signed-off-by: Col

[RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

2025-01-27 Thread Colton Lewis
patch specifically disallows that case because it's not useful given the intention to allow guests access to their own counters. Signed-off-by: Colton Lewis --- arch/arm/include/asm/arm_pmuv3.h | 10 +++ arch/arm64/include/asm/arm_pmuv3.h | 10 +++ drivers/perf/arm_pmuv3.c

[RFC PATCH 3/4] perf: arm_pmuv3: Generalize counter bitmasks

2025-01-27 Thread Colton Lewis
These bitmasks are valid for enable and interrupt registers as well as overflow registers. Generalize the names. Signed-off-by: Colton Lewis --- include/linux/perf/arm_pmuv3.h | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/perf/arm_pmuv3.h

[RFC PATCH 2/4] KVM: arm64: Make guests see only counters they can access

2025-01-27 Thread Colton Lewis
The ARM architecture specifies that when MDCR_EL2.HPMN is set, EL1 and EL0, which includes KVM guests, should read that value for PMCR.N. Signed-off-by: Colton Lewis --- arch/arm64/kvm/pmu-emul.c | 8 +++- tools/testing/selftests/kvm/aarch64

[RFC PATCH 0/4] PMU partitioning driver support

2025-01-27 Thread Colton Lewis
eading the register. [1] https://lore.kernel.org/kvmarm/20241219224116.3941496-3-oliver.up...@linux.dev/ Colton Lewis (4): perf: arm_pmuv3: Introduce module param to partition the PMU KVM: arm64: Make guests see only counters they can access perf: arm_pmuv3: Generalize counter bitmasks perf:

Re: [PATCH v2 0/6] Extend pmu_counters_test to AMD CPUs

2025-01-20 Thread Colton Lewis
Sean Christopherson writes: On Wed, 18 Sep 2024 20:53:13 +, Colton Lewis wrote: Extend pmu_counters_test to AMD CPUs. As the AMD PMU is quite different from Intel with different events and feature sets, this series introduces a new code path to test it, specifically focusing on the

Re: [PATCH v2 6/6] KVM: x86: selftests: Test PerfMonV2

2025-01-20 Thread Colton Lewis
Sean Christopherson writes: On Wed, Sep 18, 2024, Colton Lewis wrote: Test PerfMonV2, which defines global registers to enable multiple performance counters with a single MSR write, in its own function. If the feature is available, ensure the global control register has the ability to

Re: [PATCH v2 5/6] KVM: x86: selftests: Test core events

2025-01-20 Thread Colton Lewis
Sean Christopherson writes: On Wed, Sep 18, 2024, Colton Lewis wrote: Test events on core counters by iterating through every combination of events in amd_pmu_zen_events with every core counter. For each combination, calculate the appropriate register addresses for the event selection

Re: [PATCH v2 4/6] KVM: x86: selftests: Test read/write core counters

2025-01-20 Thread Colton Lewis
Sean Christopherson writes: On Wed, Sep 18, 2024, Colton Lewis wrote: Run a basic test to ensure we can write an arbitrary value to the core counters and read it back. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 54 +++ 1 file changed

Re: [PATCH v2 3/6] KVM: x86: selftests: Set up AMD VM in pmu_counters_test

2025-01-20 Thread Colton Lewis
Hey Sean, Thanks for the review. Sean Christopherson writes: On Wed, Sep 18, 2024, Colton Lewis wrote: Branch in main() depending on if the CPU is Intel or AMD. They are subject to vastly different requirements because the AMD PMU lacks many properties defined by the Intel PMU including the

Re: [PATCH v2 2/6] KVM: x86: selftests: Define AMD PMU CPUID leaves

2025-01-20 Thread Colton Lewis
Noted about the changelog and the ordering. No objections for how you want to apply it. Sean Christopherson writes: The shortlog is misleading. It's the *leaves* that are being defined, it's the features and properties. On Wed, Sep 18, 2024, Colton Lewis wrote: This defined

Re: [PATCH v2 0/6] Extend pmu_counters_test to AMD CPUs

2024-10-31 Thread Colton Lewis
Bumping this for Mingwei Colton Lewis writes: Extend pmu_counters_test to AMD CPUs. As the AMD PMU is quite different from Intel with different events and feature sets, this series introduces a new code path to test it, specifically focusing on the core counters including the

[PATCH v2 5/6] KVM: x86: selftests: Test core events

2024-09-18 Thread Colton Lewis
loop instruction being counted differently. Presumably, when the counter reaches 0 and execution continues to the next instruction, AMD counts this as a branch and Intel doesn't. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 87 --- 1 file c

[PATCH v2 6/6] KVM: x86: selftests: Test PerfMonV2

2024-09-18 Thread Colton Lewis
flags an overflow by the associated counter. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 53 +++ 1 file changed, 53 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools/testing/selftests/kvm/x86_64

[PATCH v2 4/6] KVM: x86: selftests: Test read/write core counters

2024-09-18 Thread Colton Lewis
Run a basic test to ensure we can write an arbitrary value to the core counters and read it back. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 54 +++ 1 file changed, 54 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64

[PATCH v2 3/6] KVM: x86: selftests: Set up AMD VM in pmu_counters_test

2024-09-18 Thread Colton Lewis
notion of PMU versions as Intel does. Every feature is a separate flag and they aren't the same features as Intel. Set up a VM for testing core AMD counters and ensure proper CPUID features are set. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c

[PATCH v2 2/6] KVM: x86: selftests: Define AMD PMU CPUID leaves

2024-09-18 Thread Colton Lewis
: Colton Lewis --- tools/testing/selftests/kvm/include/x86_64/processor.h | 7 +++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index a0c1440017bb..44ddfc4c1673 100644 --- a/tools

[PATCH v2 1/6] KVM: x86: selftests: Fix typos in macro variable use

2024-09-18 Thread Colton Lewis
ned-off-by: Colton Lewis --- tools/testing/selftests/kvm/x86_64/pmu_counters_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c index 698cb36989db..0e305e43a

[PATCH v2 0/6] Extend pmu_counters_test to AMD CPUs

2024-09-18 Thread Colton Lewis
...@tencent.com/ v2: * Test all combinations of VM setup rather than only the maximum allowed by hardware * Add fixes tag to bug fix in patch 1 * Refine some names v1: https://lore.kernel.org/kvm/20240813164244.751597-1-coltonle...@google.com/ Colton Lewis (6): KVM: x86: selftests: Fix typos in

[PATCH] regulator: Correct kernel-doc inconsistency

2020-07-15 Thread Colton Lewis
r or member 'resume' not described in 'regulator_ops' Signed-off-by: Colton Lewis --- include/linux/regulator/driver.h | 2 +- include/linux/regulator/machine.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/regulator/driver.h b/include/lin