Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv64: get clock from
rdtime
instead of rdcycle
`rdcycle` pseudo-instruction accesses the "cycle CSR" which holds the real count of CPU core clock cycles [1]. As this leaves room for side-channel attacks, access to this register from userland might be forbidden by the kernel, which results in a SIGILL [2]. Anyhow, it seems that the actual usage of the `get_cpu_clock` function in fio is about getting a wall-clock rather than the actual CPU core clock (for instance, x86 uses `rdtsc`), so this is technically a bug. The "time CSR" is the proper register to track time on riscv64. Also, the "time CSR" is more likely to be available from userspace and not cause a crash. [1] RISC-V ISA Section 10.1: https://github.com/riscv/riscv-isa-manual/releases/download/Ratified-IMAFDQC/riscv-spec-20191213.pdf [2] https://lore.kernel.org/all/YxIzgYP3MujXdqwj@aurel32.net/T/ Signed-off-by: N. Le Roux <gilbsgilbs@gmail.com> Signed-off-by: Gilbert Gilb's <gilbsgilbert@gmail.com>
- Loading branch information