diff options
author | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2020-02-12 09:24:11 -0800 |
---|---|---|
committer | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2020-02-12 09:24:11 -0800 |
commit | 83df28ae4128babc55157756b63f8684e94e55ca (patch) | |
tree | d8e92236c389bb0c26576a1865ba3997babd5016 /model/riscv_insts_base.sail | |
parent | c34a5ce3e05624eff9daa89770e5d6be627393a4 (diff) | |
parent | ca57c1be19447a5ec831292f0ca4081ffc13b436 (diff) | |
download | sail-riscv-gdb.zip sail-riscv-gdb.tar.gz sail-riscv-gdb.tar.bz2 |
Merge branch 'master' into gdbgdb
Diffstat (limited to 'model/riscv_insts_base.sail')
-rw-r--r-- | model/riscv_insts_base.sail | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/model/riscv_insts_base.sail b/model/riscv_insts_base.sail index d80d34d..bc86859 100644 --- a/model/riscv_insts_base.sail +++ b/model/riscv_insts_base.sail @@ -714,9 +714,11 @@ mapping clause encdec = MRET() <-> 0b0011000 @ 0b00010 @ 0b00000 @ 0b000 @ 0b00000 @ 0b1110011 function clause execute MRET() = { - if cur_privilege == Machine - then set_next_pc(exception_handler(cur_privilege, CTL_MRET(), PC)) - else handle_illegal(); + if cur_privilege != Machine + then handle_illegal() + else if ~(ext_check_xret_priv (Machine)) + then ext_fail_xret_priv () + else set_next_pc(exception_handler(cur_privilege, CTL_MRET(), PC)); RETIRE_FAIL } @@ -729,15 +731,16 @@ mapping clause encdec = SRET() <-> 0b0001000 @ 0b00010 @ 0b00000 @ 0b000 @ 0b00000 @ 0b1110011 function clause execute SRET() = { - match cur_privilege { - User => handle_illegal(), - Supervisor => if (~ (haveSupMode ())) | mstatus.TSR() == 0b1 - then handle_illegal() - else set_next_pc(exception_handler(cur_privilege, CTL_SRET(), PC)), - Machine => if (~ (haveSupMode ())) - then handle_illegal() - else set_next_pc(exception_handler(cur_privilege, CTL_SRET(), PC)) + let sret_illegal : bool = match cur_privilege { + User => true, + Supervisor => ~ (haveSupMode ()) | mstatus.TSR() == 0b1, + Machine => ~ (haveSupMode ()) }; + if sret_illegal + then handle_illegal() + else if ~(ext_check_xret_priv (Supervisor)) + then ext_fail_xret_priv () + else set_next_pc(exception_handler(cur_privilege, CTL_SRET(), PC)); RETIRE_FAIL } |