Browse Source

Call stash_privilege more selectively

rivosinc-etrigger_fix_exception_match
Andrew Waterman 3 years ago
parent
commit
0e83fe66fb
  1. 10
      riscv/execute.cc
  2. 1
      riscv/insns/dret.h
  3. 1
      riscv/insns/mnret.h
  4. 1
      riscv/insns/mret.h
  5. 1
      riscv/insns/sret.h
  6. 2
      riscv/processor.cc
  7. 2
      riscv/processor.h

10
riscv/execute.cc

@ -14,12 +14,12 @@ static void commit_log_reset(processor_t* p)
p->get_state()->log_mem_write.clear();
}
static void stash_privilege(processor_t* p)
void processor_t::stash_privilege()
{
state_t* state = p->get_state();
state_t* state = get_state();
state->last_inst_priv = state->prv;
state->last_inst_xlen = p->get_xlen();
state->last_inst_flen = p->get_flen();
state->last_inst_xlen = get_xlen();
state->last_inst_flen = get_flen();
state->last_v = state->v;
}
@ -161,7 +161,6 @@ inline void processor_t::update_histogram(reg_t pc)
// These two functions are expected to be inlined by the compiler separately in
// the processor_t::step() loop. The logged variant is used in the slow path
static inline reg_t execute_insn_fast(processor_t* p, reg_t pc, insn_fetch_t fetch) {
stash_privilege(p);
return fetch.func(p, fetch.insn, pc);
}
static inline reg_t execute_insn_logged(processor_t* p, reg_t pc, insn_fetch_t fetch)
@ -169,7 +168,6 @@ static inline reg_t execute_insn_logged(processor_t* p, reg_t pc, insn_fetch_t f
if (p->get_log_commits_enabled()) {
commit_log_reset(p);
}
stash_privilege(p);
reg_t npc;

1
riscv/insns/dret.h

@ -1,4 +1,5 @@
require(STATE.debug_mode);
p->stash_privilege();
set_pc_and_serialize(STATE.dpc->read());
p->set_privilege(STATE.dcsr->prv);
if (STATE.prv < PRV_M)

1
riscv/insns/mnret.h

@ -1,5 +1,6 @@
require_extension(EXT_SMRNMI);
require_privilege(PRV_M);
p->stash_privilege();
set_pc_and_serialize(p->get_state()->mnepc->read());
reg_t s = STATE.mnstatus->read();
reg_t prev_prv = get_field(s, MNSTATUS_MNPP);

1
riscv/insns/mret.h

@ -1,4 +1,5 @@
require_privilege(PRV_M);
p->stash_privilege();
set_pc_and_serialize(p->get_state()->mepc->read());
reg_t s = STATE.mstatus->read();
reg_t prev_prv = get_field(s, MSTATUS_MPP);

1
riscv/insns/sret.h

@ -1,4 +1,5 @@
require_extension('S');
p->stash_privilege();
reg_t prev_hstatus = STATE.hstatus->read();
if (STATE.v) {
if (STATE.prv == PRV_U || get_field(prev_hstatus, HSTATUS_VTSR))

2
riscv/processor.cc

@ -783,6 +783,8 @@ void processor_t::debug_output_log(std::stringstream *s)
void processor_t::take_trap(trap_t& t, reg_t epc)
{
stash_privilege();
unsigned max_xlen = isa->get_max_xlen();
if (debug) {

2
riscv/processor.h

@ -298,6 +298,8 @@ public:
void clear_waiting_for_interrupt() { in_wfi = false; };
bool is_waiting_for_interrupt() { return in_wfi; };
void stash_privilege();
private:
const isa_parser_t * const isa;
const cfg_t * const cfg;

Loading…
Cancel
Save