Skip to content

Commit 3aa5759

Browse files
committed
Fix mret and mnret instructions to support correctly Smdbltrp (MDT bit) and MPRV bit
Signed-off-by: Albert Yosher <[email protected]>
1 parent f9ac10e commit 3aa5759

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

arch/inst/I/mret.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ access:
1414
encoding:
1515
match: "00110000001000000000000001110011"
1616
operation(): |
17-
if (implemented?(ExtensionName::S) && CSR[mstatus].MPP != 2'b11) {
17+
if (CSR[mstatus].MPP != 2'b11) {
1818
CSR[mstatus].MPRV = 0;
1919
}
20+
if (implemented?(ExtensionName::Smdbltrp)) {
21+
if (xlen() == 64) {
22+
CSR[mstatus].MDT = 1'b0;
23+
} else {
24+
CSR[mstatush].MDT = 1'b0;
25+
}
26+
}
2027
CSR[mstatus].MIE = CSR[mstatus].MPIE;
2128
CSR[mstatus].MPIE = 1;
2229
if (CSR[mstatus].MPP == 2'b00) {

arch/inst/Smrnmi/mnret.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: mnret
6-
long_name: No synopsis available.
6+
long_name: Machine NMI Return
77
description: |
8-
No description available.
8+
Returns from an NMI in M-mode.
99
definedBy: Smrnmi
1010
assembly: mnret
1111
encoding:
@@ -18,9 +18,17 @@ access:
1818
vu: always
1919
data_independent_timing: false
2020
operation(): |
21-
if (implemented?(ExtensionName::S) && CSR[mstatus].MPP != 2'b11) {
21+
if (CSR[mnstatus].MNPP != 2'b11) {
2222
CSR[mstatus].MPRV = 0;
23+
if (implemented?(ExtensionName::Smdbltrp)) {
24+
if (xlen() == 64) {
25+
CSR[mstatus].MDT = 1'b0;
26+
} else {
27+
CSR[mstatush].MDT = 1'b0;
28+
}
29+
}
2330
}
31+
CSR[mnstatus].NMIE = 1'b1;
2432
if (CSR[mnstatus].MNPP == 2'b00) {
2533
set_mode(PrivilegeMode::U);
2634
} else if (CSR[mnstatus].MNPP == 2'b01) {

0 commit comments

Comments
 (0)