Browse Source

When disabling hypervisor via misa, clear hypervisor state

Otherwise, mstatus.MPV and hstatus.SPV could remain 1, and executing
mret/sret would then set state.v=1, which would be bad since
hypervisor's supposed to be disabled.
pull/658/head
Scott Johnson 5 years ago
parent
commit
1ef7fe3e19
No known key found for this signature in database GPG Key ID: 61C1F01D3D1410C9
  1. 10
      riscv/processor.cc

10
riscv/processor.cc

@ -1130,11 +1130,17 @@ void processor_t::set_csr(int which, reg_t val)
state.misa = (val & mask) | (state.misa & ~mask);
// update the forced bits in MIDELEG
// update the forced bits in MIDELEG and other CSRs
if (supports_extension('H'))
state.mideleg |= MIDELEG_FORCED_MASK;
else
else {
state.mideleg &= ~MIDELEG_FORCED_MASK;
state.medeleg &= ~hypervisor_exceptions;
state.mstatus &= ~(MSTATUS_GVA | MSTATUS_MPV);
state.mie &= ~MIP_HS_MASK; // also takes care of hip, sip, hvip
state.mip &= ~MIP_HS_MASK; // also takes care of hie, sie
set_csr(CSR_HSTATUS, 0);
}
break;
}
case CSR_HSTATUS: {

Loading…
Cancel
Save