riscv-software-src / riscv-pk

RISC-V Proxy Kernel
Other
593 stars 308 forks source link

FP emulation #159

Open evgenypim opened 5 years ago

evgenypim commented 5 years ago

HI,

I'm trying to check fp-emulation. bbl compiled with flags --with-arch=rv64imac, so __riscv_flen is undefined and PK_ENABLE_FP_EMULATION is defined.

BBL is starting in qemu with CPU without F and D extensions. FP emulation not working - it checks for FS bit of mstatus in emulate_float_load and in emulate_fp, which is set to 0 in mstatus_init. So in this case fp-emulation not working. Can you point me if i'm doing something wrong?

And second question regarding exceptions handling. In riscv privileged spec v1.10 i found register mtval that replaces mbadaddr and should contain first XLEN bits of illegal instruction, but illegal_insn_trap still using only mbadaddr and next get_insn. So, my question is - if it reasonable to use also mtval?

Thanks.

aswaterman commented 5 years ago

The OS needs to set FS to a nonzero value for emulation to proceed. That way, the OS knows it needs to save/restore FP state for a process.

(On systems with S-mode, FS must be writable even when FP is not implemented.)