summaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorPrashanth Mundkur2018-05-03 18:10:06 -0700
committerPrashanth Mundkur2018-05-03 18:19:18 -0700
commit5c6f3cf7822a7d4086031a4cf009af4b85c8949f (patch)
tree17fceef1bb3d81d60fca04f204602ddcb908e39c /riscv
parentc6efa60af323847a2f0a91f93bf6a941e58b6aa6 (diff)
Fix a typo in sret decode and privilege checks in xret.
Diffstat (limited to 'riscv')
-rw-r--r--riscv/riscv.sail18
1 files changed, 14 insertions, 4 deletions
diff --git a/riscv/riscv.sail b/riscv/riscv.sail
index 0c3fa944..d93c7dae 100644
--- a/riscv/riscv.sail
+++ b/riscv/riscv.sail
@@ -540,8 +540,12 @@ union clause ast = MRET : unit
function clause decode 0b0011000 @ 0b00010 @ 0b00000 @ 0b000 @ 0b00000 @ 0b1110011 = Some(MRET())
-function clause execute MRET() =
- nextPC = handle_exception(cur_privilege, CTL_MRET(), PC)
+function clause execute MRET() = {
+ if cur_privilege == Machine then
+ nextPC = handle_exception(cur_privilege, CTL_MRET(), PC)
+ else
+ handle_illegal()
+}
function clause print_insn (MRET()) =
"mret"
@@ -549,10 +553,16 @@ function clause print_insn (MRET()) =
/* ****************************************************************** */
union clause ast = SRET : unit
-function clause decode 0b0001000 @ 0b00010 @ 0b00000 @ 0b000 @ 0b00000 @ 0b1110011 = Some(MRET())
+function clause decode 0b0001000 @ 0b00010 @ 0b00000 @ 0b000 @ 0b00000 @ 0b1110011 = Some(SRET())
function clause execute SRET() =
- nextPC = handle_exception(cur_privilege, CTL_SRET(), PC)
+ match cur_privilege {
+ User => handle_illegal(),
+ Supervisor => if mstatus.TSR() == true
+ then handle_illegal()
+ else nextPC = handle_exception(cur_privilege, CTL_SRET(), PC),
+ Machine => nextPC = handle_exception(cur_privilege, CTL_SRET(), PC)
+ }
function clause print_insn (SRET()) =
"sret"