diff --git a/src/isa/riscv64/system/intr.c b/src/isa/riscv64/system/intr.c index c525f795..accbd209 100644 --- a/src/isa/riscv64/system/intr.c +++ b/src/isa/riscv64/system/intr.c @@ -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; @@ -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