riscv-software-src / riscv-pk

RISC-V Proxy Kernel
Other
570 stars 304 forks source link

Implementation of riscv_hwprobe syscall from Linux #325

Closed WojciechMula closed 3 months ago

WojciechMula commented 3 months ago

See: https://www.kernel.org/doc/html/latest/arch/riscv/hwprobe.html

Please note that there is just a partial support, as I aimed to dynamic detection of the V extension. TBH I'm not 100% happy with solution, as I feel like we should use mstatus rather than misa. Appreciate any feedback.

WojciechMula commented 3 months ago

@aswaterman rebased

The output from sample program https://github.com/WojciechMula/toys/tree/master/detect-rvv:

~/github/toys/detect-rvv$ make && spike --isa=rv64gc `which pk` ./detect 
make: 'detect' is up to date.
RISCV_HWPROBE_KEY_IMA_EXT_0:
- RISCV_HWPROBE_IMA_C
key 0xffffffffffffffff: value 0x0000000000000000
~/github/toys/detect-rvv$ make && spike --isa=rv64gcv `which pk` ./detect 
make: 'detect' is up to date.
RISCV_HWPROBE_KEY_IMA_EXT_0:
- RISCV_HWPROBE_IMA_C
- RISCV_HWPROBE_IMA_V
key 0xffffffffffffffff: value 0x0000000000000000
aswaterman commented 3 months ago

Thank you!