Skip to content

Commit 2091e00

Browse files
authored
revert(csr): htinst/mtinst should follow the origin spike behaviour
This reverts commit 347cd0e (#33). According to RISC-V priv spec, htinst/mtinst could be zero when traps into HS/M-mode, except the both following conditions are met: * the fault is caused by an implicit memory access for VS-stage address translation * a nonzero value (the faulting guest physical address) is written to mtval2 or htval Actually, XiangShan would write a nonzero value in such trap, so mtinst could not be written 0. Acctually, spike only implements this nonzero situation for htinst/mtinst, so no more warps are needed.
1 parent 8b54e28 commit 2091e00

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

riscv/processor.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,7 @@ void processor_t::take_trap(trap_t& t, reg_t epc)
503503
#endif
504504
state.nonvirtual_stval->write(t.get_tval());
505505
state.htval->write(t.get_tval2());
506-
#ifdef CPU_XIANGSHAN
507-
state.htinst->write(0);
508-
#else
509506
state.htinst->write(t.get_tinst());
510-
#endif
511507

512508
reg_t s = state.nonvirtual_sstatus->read();
513509
s = set_field(s, MSTATUS_SPIE, get_field(s, MSTATUS_SIE));
@@ -557,11 +553,7 @@ void processor_t::take_trap(trap_t& t, reg_t epc)
557553
state.mcause->write(supv_double_trap ? CAUSE_DOUBLE_TRAP : t.cause());
558554
state.mtval->write(t.get_tval());
559555
state.mtval2->write(supv_double_trap ? t.cause() : t.get_tval2());
560-
#ifdef CPU_XIANGSHAN
561-
state.mtinst->write(0);
562-
#else
563556
state.mtinst->write(t.get_tinst());
564-
#endif
565557

566558
s = set_field(s, MSTATUS_MPIE, get_field(s, MSTATUS_MIE));
567559
s = set_field(s, MSTATUS_MPP, state.prv);

0 commit comments

Comments
 (0)