diff --git a/src/isa/riscv64/instr/fp.c b/src/isa/riscv64/instr/fp.c index a6c4f580b..f3dbec19b 100644 --- a/src/isa/riscv64/instr/fp.c +++ b/src/isa/riscv64/instr/fp.c @@ -32,7 +32,19 @@ void fp_update_rm_cache(uint32_t rm) { } bool fp_enable() { - return MUXDEF(CONFIG_MODE_USER, true, mstatus->fs != 0); +#ifdef CONFIG_MODE_USER + return true; +#else // !CONFIG_MODE_USER + if (mstatus->fs == 0) { + return false; + } +#ifdef CONFIG_RVH + if (cpu.v && vsstatus->fs == 0) { + return false; + } +#endif // CONFIG_RVH + return true; +#endif // CONFIG_MODE_USER } void fp_set_dirty() { diff --git a/src/isa/riscv64/instr/rvc/decode.h b/src/isa/riscv64/instr/rvc/decode.h index 4cea44f52..df8e01f68 100644 --- a/src/isa/riscv64/instr/rvc/decode.h +++ b/src/isa/riscv64/instr/rvc/decode.h @@ -392,6 +392,7 @@ def_THelper(c_ldst) { def_THelper(c_fldst) { #ifndef CONFIG_FPU_NONE + if (!fp_enable()) return table_rt_inv(s); int mmu_mode = isa_mmu_state(); if (mmu_mode == MMU_DIRECT) { def_INSTR_TAB("001 ??? ??? ?? ??? ??", fld); diff --git a/src/isa/riscv64/instr/vp.c b/src/isa/riscv64/instr/vp.c index 3058eb4dd..c76f38166 100644 --- a/src/isa/riscv64/instr/vp.c +++ b/src/isa/riscv64/instr/vp.c @@ -20,8 +20,19 @@ #include bool vp_enable() { +#ifdef CONFIG_MODE_USER return true; - //return MUXDEF(CONFIG_MODE_USER, true, mstatus->vs != 0); +#else // !CONFIG_MODE_USER + if (mstatus->vs == 0) { + return false; + } +#ifdef CONFIG_RVH + if (cpu.v && vsstatus->vs == 0) { + return false; + } +#endif // CONFIG_RVH + return true; +#endif // CONFIG_MODE_USER } void vp_set_dirty() {