Browse Source

csr: hyper: fix mstatus.mpp after mret

By spec 3.1.6.1 (original behavior)
  "x PP is set to the least-privileged supported
   mode (U if U-mode is implemented, else M)"

By spec 8.6.4 (h-extension)
  "MRET first determines what the new privilege mode will be according to
   the values of MPP and MPV in mstatus or mstatush, as encoded in Table 8.8.
   MRET then in mstatus/mstatush sets MPV=0, MPP=0, MIE=MPIE, and
   MPIE=1"

Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
pull/926/head
Chih-Min Chao 4 years ago
parent
commit
7fd56cfbb0
  1. 2
      riscv/insns/mret.h

2
riscv/insns/mret.h

@ -7,7 +7,7 @@ if (prev_prv != PRV_M)
s = set_field(s, MSTATUS_MPRV, 0);
s = set_field(s, MSTATUS_MIE, get_field(s, MSTATUS_MPIE));
s = set_field(s, MSTATUS_MPIE, 1);
s = set_field(s, MSTATUS_MPP, PRV_U);
s = set_field(s, MSTATUS_MPP, p->extension_enabled('U') ? PRV_U : PRV_M);
s = set_field(s, MSTATUS_MPV, 0);
p->set_csr(CSR_MSTATUS, s);
p->set_privilege(prev_prv);

Loading…
Cancel
Save