arm64: use generic timer virtual counter for cycles()

We used to use performance cycle counter for cycles(),
but it is kind of useless in userspace as each core
has its own counter and hence not comparable between
cores. Also, the cycle counter stops counting when
the cores are idle.

Most callers expect cycles() to return a high resolution
timestamp instead, so do the best we can do here
and enable the userspace generic timer virtual counter.
This commit is contained in:
cinap_lenrek 2021-07-23 15:10:01 +00:00
parent 2c1727e55c
commit c38fcb5dc3
4 changed files with 21 additions and 5 deletions

View file

@ -1,7 +1,7 @@
#define SYSREG(op0,op1,Cn,Cm,op2) SPR(((op0)<<19|(op1)<<16|(Cn)<<12|(Cm)<<8|(op2)<<5))
#define PMCCNTR_EL0 SYSREG(3,3,9,13,0)
#define CNTVCT_EL0 SYSREG(3,3,14,0,2)
TEXT cycles(SB), 1, $-4
MRS PMCCNTR_EL0, R1
MRS CNTVCT_EL0, R1
MOV R1, (R0)
RETURN