Starting with Linux 6.6 [1], RDCYCLE is a privileged instruction on
RISC-V and can't be used directly from userland.Use RDTIME instead,
which while less accurate has the advantage of being synchronized
between CPU (and thus monotonic) and of constant frequency.
Type: fix
Change-Id: I53ab9cd1d0fcdd8f0e88d189840ba1d3b5ddd67a
Signed-off-by: Shubing Guo <[email protected]>
return result;
}
-#elif defined(__riscv)
+#elif defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen == 64)
always_inline u64
clib_cpu_time_now (void)
{
u64 result;
- asm volatile("rdcycle %0\n" : "=r"(result));
+ asm volatile ("rdtime %0\n" : "=r"(result));
return result;
}
#else