Browse Source

[arm] Use CNTVCT_EL0 as profiling timestamp

The raw cycle counter at PMCCNTR_EL0 works in qemu but seems to always
read as zero on physical hardware (tested on Juno r1 and Cavium
ThunderX), even after ensuring that PMCR_EL0.E and PMCNTENSET_EL0.C
are both enabled.

Use CNTVCT_EL0 instead; this seems to count at a lower resolution
(tens of CPU cycles), but is usable for profiling.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
601706688b
1 changed files with 1 additions and 3 deletions
  1. 1
    3
      src/arch/arm64/include/bits/profile.h

+ 1
- 3
src/arch/arm64/include/bits/profile.h View File

@@ -21,9 +21,7 @@ profile_timestamp ( void ) {
21 21
 	uint64_t cycles;
22 22
 
23 23
 	/* Read cycle counter */
24
-	__asm__ __volatile__ ( "msr PMCR_EL0, %1\n\t"
25
-			       "mrs %0, PMCCNTR_EL0\n\t"
26
-			       : "=r" ( cycles ) : "r" ( 1 ) );
24
+	__asm__ __volatile__ ( "mrs %0, CNTVCT_EL0\n\t" : "=r" ( cycles ) );
27 25
 	return cycles;
28 26
 }
29 27
 

Loading…
Cancel
Save