Skip to content

Commit

Permalink
fix(fs, vs): fix check fs/vs when executing float/vector instr (#621)
Browse files Browse the repository at this point in the history
Including fldst instrucitons under RVC extension.
  • Loading branch information
NewPaulWalker authored Oct 30, 2024
1 parent 7e6edfa commit 404753f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/isa/riscv64/instr/fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/isa/riscv64/instr/rvc/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,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);
Expand Down
13 changes: 12 additions & 1 deletion src/isa/riscv64/instr/vp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@
#include <cpu/cpu.h>

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() {
Expand Down

0 comments on commit 404753f

Please sign in to comment.