Skip to content

Commit

Permalink
fix(gva): fix gva bit set/clear logic in mstatus/hstatus.
Browse files Browse the repository at this point in the history
  • Loading branch information
NewPaulWalker committed Nov 6, 2024
1 parent 34ba225 commit df325cc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/isa/riscv64/system/intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ word_t raise_intr(word_t NO, vaddr_t epc) {
trap_pc = get_trap_pc(vstvec->val, vscause->val);
}
else if(delegS && !s_EX_DT){
int v = (mstatus->mprv)? mstatus->mpv : cpu.v;
hstatus->gva = (NO == EX_IGPF || NO == EX_LGPF || NO == EX_SGPF ||
((v || hld_st_temp) && ((0 <= NO && NO <= 7 && NO != 2) || NO == EX_IPF || NO == EX_LPF || NO == EX_SPF)));
bool v = mstatus->mprv && mstatus->mpv && (mstatus->mpp != MODE_M);
hstatus->gva = (NO == EX_IAM || NO == EX_IAF || NO == EX_BP || NO == EX_IPF) && cpu.v ||
(NO == EX_LAM || NO == EX_LAF || NO == EX_SAM || NO == EX_SAF || NO == EX_LPF || NO == EX_SPF) && (hld_st_temp || cpu.v || v) ||
(NO == EX_IGPF || NO == EX_LGPF || NO == EX_SGPF);
hstatus->spv = cpu.v;
if(cpu.v){
hstatus->spvp = cpu.mode;
Expand Down Expand Up @@ -243,9 +244,10 @@ word_t raise_intr(word_t NO, vaddr_t epc) {
trap_pc = get_trap_pc(stvec->val, scause->val);
} else if((delegM || vs_EX_DT || s_EX_DT) && !m_EX_DT){
#ifdef CONFIG_RVH
int v = (mstatus->mprv)? mstatus->mpv : cpu.v;
mstatus->gva = (NO == EX_IGPF || NO == EX_LGPF || NO == EX_SGPF ||
((v || hld_st_temp) && ((0 <= NO && NO <= 7 && NO != 2) || NO == EX_IPF || NO == EX_LPF || NO == EX_SPF)));
bool v = mstatus->mprv && mstatus->mpv && (mstatus->mpp != MODE_M);
mstatus->gva = (NO == EX_IAM || NO == EX_IAF || NO == EX_BP || NO == EX_IPF) && cpu.v ||
(NO == EX_LAM || NO == EX_LAF || NO == EX_SAM || NO == EX_SAF || NO == EX_LPF || NO == EX_SPF) && (hld_st_temp || cpu.v || v) ||
(NO == EX_IGPF || NO == EX_LGPF || NO == EX_SGPF)
mstatus->mpv = cpu.v;
cpu.v = 0;set_sys_state_flag(SYS_STATE_FLUSH_TCACHE);
#endif
Expand Down

0 comments on commit df325cc

Please sign in to comment.