Skip to contentSkip to conversation

arm: pmu: Actually use counter 0 in test_event_counter_config()

PATCH In review Oliver Upton 3 participants 3 messages Feb 3, 2025 – Feb 4, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: pmu: Actually use counter 0 in test_event_counter_config()

test_event_counter_config() checks that there is at least one event counter but mistakenly uses counter 1 for part of the test.

Most implementations have more than a single event counter which is probably why this went unnoticed. However, due to limitations of the underlying hardware, KVM's PMUv3 emulation on Apple silicon can only provide 1 event counter.

Consistenly use counter 0 throughout the test, matching the precondition and allowing the test to pass on Apple parts.

Cc Eric Auger <[email protected]>
Fixes 4ce2a804 ("arm: pmu: Basic event counter Tests")
---
 arm/pmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arm/pmu.c +3 -3
index 9ff7a301..2dc0822b 100644
@@ -396,13 +396,13 @@ static void test_event_counter_config(void)
 	 * Test setting through PMESELR/PMXEVTYPER and PMEVTYPERn read,
 	 * select counter 0
 	 */
-	write_sysreg(1, PMSELR_EL0);
+	write_sysreg(0, PMSELR_EL0);
 	/* program this counter to count unsupported event */
 	write_sysreg(0xEA, PMXEVTYPER_EL0);
 	write_sysreg(0xdeadbeef, PMXEVCNTR_EL0);
-	report((read_regn_el0(pmevtyper, 1) & 0xFFF) == 0xEA,
+	report((read_regn_el0(pmevtyper, 0) & 0xFFF) == 0xEA,
 		"PMESELR/PMXEVTYPER/PMEVTYPERn");
-	report((read_regn_el0(pmevcntr, 1) == 0xdeadbeef),
+	report((read_regn_el0(pmevcntr, 0) == 0xdeadbeef),
 		"PMESELR/PMXEVCNTR/PMEVCNTRn");
 
 	/* try to configure an unsupported event within the range [0x0, 0x3F] */

base-commit: 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea

Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw

Hi Oliver,

Quoted 27 lines · Oliver Upton

test_event_counter_config() checks that there is at least one event counter but mistakenly uses counter 1 for part of the test.

Most implementations have more than a single event counter which is probably why this went unnoticed. However, due to limitations of the underlying hardware, KVM's PMUv3 emulation on Apple silicon can only provide 1 event counter.

Consistenly use counter 0 throughout the test, matching the precondition and allowing the test to pass on Apple parts.

Cc Eric Auger <[email protected]>
Fixes 4ce2a804 ("arm: pmu: Basic event counter Tests")
---
 arm/pmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arm/pmu.c +0 -1
index 9ff7a301..2dc0822b 100644
@@ -396,13 +396,13 @@ static void test_event_counter_config(void)
 	 * Test setting through PMESELR/PMXEVTYPER and PMEVTYPERn read,
 	 * select counter 0
 	 */
-	write_sysreg(1, PMSELR_EL0);

arm/pmu.c static void test_event_counter_config(void) · line 406

Quoted 10 lines
arm/pmu.c +3 -2
+	write_sysreg(0, PMSELR_EL0);
 	/* program this counter to count unsupported event */
 	write_sysreg(0xEA, PMXEVTYPER_EL0);
 	write_sysreg(0xdeadbeef, PMXEVCNTR_EL0);
-	report((read_regn_el0(pmevtyper, 1) & 0xFFF) == 0xEA,
+	report((read_regn_el0(pmevtyper, 0) & 0xFFF) == 0xEA,
 		"PMESELR/PMXEVTYPER/PMEVTYPERn");
-	report((read_regn_el0(pmevcntr, 1) == 0xdeadbeef),
+	report((read_regn_el0(pmevcntr, 0) == 0xdeadbeef),
 		"PMESELR/PMXEVCNTR/PMEVCNTRn");

Thank you for noticing and fixing that

Eric

Quoted 4 lines
arm/pmu.c +0 -0
 	/* try to configure an unsupported event within the range [0x0, 0x3F] */
 

base-commit: 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea

#2 lore raw
In reply to Oliver Upton
Quoted 40 lines · Oliver Upton

test_event_counter_config() checks that there is at least one event counter but mistakenly uses counter 1 for part of the test.

Most implementations have more than a single event counter which is probably why this went unnoticed. However, due to limitations of the underlying hardware, KVM's PMUv3 emulation on Apple silicon can only provide 1 event counter.

Consistenly use counter 0 throughout the test, matching the precondition and allowing the test to pass on Apple parts.

Cc Eric Auger <[email protected]>
Fixes 4ce2a804 ("arm: pmu: Basic event counter Tests")
---
 arm/pmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arm/pmu.c +3 -3
index 9ff7a301..2dc0822b 100644
@@ -396,13 +396,13 @@ static void test_event_counter_config(void)
 	 * Test setting through PMESELR/PMXEVTYPER and PMEVTYPERn read,
 	 * select counter 0
 	 */
-	write_sysreg(1, PMSELR_EL0);
+	write_sysreg(0, PMSELR_EL0);
 	/* program this counter to count unsupported event */
 	write_sysreg(0xEA, PMXEVTYPER_EL0);
 	write_sysreg(0xdeadbeef, PMXEVCNTR_EL0);
-	report((read_regn_el0(pmevtyper, 1) & 0xFFF) == 0xEA,
+	report((read_regn_el0(pmevtyper, 0) & 0xFFF) == 0xEA,
 		"PMESELR/PMXEVTYPER/PMEVTYPERn");
-	report((read_regn_el0(pmevcntr, 1) == 0xdeadbeef),
+	report((read_regn_el0(pmevcntr, 0) == 0xdeadbeef),
 		"PMESELR/PMXEVCNTR/PMEVCNTRn");
 
 	/* try to configure an unsupported event within the range [0x0, 0x3F] */
Quoted 4 lines

base-commit: 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea

Signature · 1 line
2.39.5

Merged.

Thanks,
drew