CPU detection does not match kernel support
The current code for detecting CPU features on Linux relies on parsing /proc/cpuinfo
.
This poses a number of problems:
- It fails when running on user-mode emulator (such as QEMU or Spike), as we get the CPU infos for the host architecture instead of the emulated ISA.
- On RISC-V, the ISA field comes straight from the Device Tree, and may not reflect actual kernel support.
- It is also very cumbersome due to the idiosyncratic syntax of RISC-V extensions.
- The current code fails to handle setups with asymmetric CPU capabilities.
Not sure about x86, but on all other platforms with run-time CPU detection (ARM, PPC, RISC-V), the support is supposed to be checked from auxiliary vector auxv
. libc provides a convenience wrapper getauxval()
.
Edited by Rémi Denis-Courmont