require_privilege(PRV_M);
set_pc_and_serialize(STATE.dpc);
-/* The debug spec says we can't crash when prv is set to an invalid value. */
-if (p->validate_priv(STATE.dcsr.prv)) {
- p->set_privilege(STATE.dcsr.prv);
-}
+p->set_privilege(STATE.dcsr.prv);
/* We're not in Debug Mode anymore. */
STATE.dcsr.cause = 0;
raise_interrupt(ctz(enabled_interrupts));
}
-bool processor_t::validate_priv(reg_t priv)
-{
- return priv == PRV_U || priv == PRV_S || priv == PRV_M;
-}
-
void processor_t::set_privilege(reg_t prv)
{
- assert(validate_priv(prv));
+ assert(prv <= PRV_M);
+ if (prv == PRV_H)
+ prv = PRV_U;
mmu->flush_tlb();
state.prv = prv;
}
reg_t mask = MSTATUS_SIE | MSTATUS_SPIE | MSTATUS_MIE | MSTATUS_MPIE
| MSTATUS_SPP | MSTATUS_FS | MSTATUS_MPRV | MSTATUS_PUM
- | MSTATUS_MXR | (ext ? MSTATUS_XS : 0);
+ | MSTATUS_MPP | MSTATUS_MXR | (ext ? MSTATUS_XS : 0);
if (validate_vm(max_xlen, get_field(val, MSTATUS_VM)))
mask |= MSTATUS_VM;
- if (validate_priv(get_field(val, MSTATUS_MPP)))
- mask |= MSTATUS_MPP;
state.mstatus = (state.mstatus & ~mask) | (val & mask);
if (ext >= 'a' && ext <= 'z') ext += 'A' - 'a';
return ext >= 'A' && ext <= 'Z' && ((isa >> (ext - 'A')) & 1);
}
- bool validate_priv(reg_t priv);
void set_privilege(reg_t);
void yield_load_reservation() { state.load_reservation = (reg_t)-1; }
void update_histogram(reg_t pc);