Skip to content

Commit 4a2b38f

Browse files
committed
Raise illegal instruction instead of virtual instruction on WFI when TW=1 in VU-mode
The previous implementation raises virtual instruction on WFI when TW=1 in VU-mode. According to the recent discussion, we expect an illegal instruction exception in this case. Reference: riscv/riscv-isa-manual#1234
1 parent 7c89063 commit 4a2b38f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

riscv/insns/wfi.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
if (STATE.v && STATE.prv == PRV_U) {
2-
require_novirt();
3-
} else if (get_field(STATE.mstatus->read(), MSTATUS_TW)) {
1+
if (get_field(STATE.mstatus->read(), MSTATUS_TW)) {
42
require_privilege(PRV_M);
5-
} else if (STATE.v) { // VS-mode
6-
if (get_field(STATE.hstatus->read(), HSTATUS_VTW))
3+
} else if (STATE.v) {
4+
if (STATE.prv == PRV_U || get_field(STATE.hstatus->read(), HSTATUS_VTW))
75
require_novirt();
86
} else if (p->extension_enabled('S')) {
97
// When S-mode is implemented, then executing WFI in

0 commit comments

Comments
 (0)