From 601706688bbb5502538627feb92752760d0d9f24 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 11 May 2016 21:44:23 +0100 Subject: [PATCH] [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 --- src/arch/arm64/include/bits/profile.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/arch/arm64/include/bits/profile.h b/src/arch/arm64/include/bits/profile.h index cad02ea4b..62ffa3772 100644 --- a/src/arch/arm64/include/bits/profile.h +++ b/src/arch/arm64/include/bits/profile.h @@ -21,9 +21,7 @@ profile_timestamp ( void ) { uint64_t cycles; /* Read cycle counter */ - __asm__ __volatile__ ( "msr PMCR_EL0, %1\n\t" - "mrs %0, PMCCNTR_EL0\n\t" - : "=r" ( cycles ) : "r" ( 1 ) ); + __asm__ __volatile__ ( "mrs %0, CNTVCT_EL0\n\t" : "=r" ( cycles ) ); return cycles; }