1 require_privilege(PRV_M
);
2 set_pc_and_serialize(p
->get_state()->mepc
);
3 reg_t s
= STATE
.mstatus
;
4 reg_t prev_prv
= get_field(s
, MSTATUS_MPP
);
5 s
= set_field(s
, MSTATUS_UIE
<< prev_prv
, get_field(s
, MSTATUS_MPIE
));
6 s
= set_field(s
, MSTATUS_MPIE
, 0);
7 s
= set_field(s
, MSTATUS_MPP
, PRV_U
);
8 p
->set_privilege(prev_prv
);
9 p
->set_csr(CSR_MSTATUS
, s
);