Skip to content

Commit

Permalink
Added updated support for xTIDC registers
Browse files Browse the repository at this point in the history
  • Loading branch information
francislaus committed May 8, 2024
1 parent af2586b commit 1f7b0e4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/cheri_insts.sail
Original file line number Diff line number Diff line change
Expand Up @@ -361,30 +361,34 @@ union clause ast = CSpecialRW : (regidx, screg, regidx)
* **DDC** should need clearing, which can be done with [CClear].
*/
function clause execute (CSpecialRW(cd, scr, cs1)) = {
let (specialExists, ro, priv, needASR) : (bool, bool, Privilege, bool) = match unsigned(scr) {
0 => (true, true, User, false),
1 => (true, false, User, false),
3 if haveUsrMode() => (true, true, User, false),
4 if haveNExt() => (true, false, User, true),
5 if haveNExt() => (true, false, User, true),
6 if haveNExt() => (true, false, User, true),
7 if haveNExt() => (true, false, User, true),
11 if haveSupMode() => (true, false, Supervisor, true),
12 if haveSupMode() => (true, false, Supervisor, true),
13 if haveSupMode() => (true, false, Supervisor, true),
14 if haveSupMode() => (true, false, Supervisor, true),
15 if haveSupMode() => (true, false, Supervisor, true),
28 => (true, false, Machine, true),
29 => (true, false, Machine, true),
30 => (true, false, Machine, true),
31 => (true, false, Machine, true),
_ => (false, true, Machine, true)
let (specialExists, ro, priv, needASR, needASRW) : (bool, bool, Privilege, bool, bool) = match unsigned(scr) {
0 => (true, true, User, false, false),
1 => (true, false, User, false, false),
3 if haveUsrMode() => (true, true, User, false, true),
4 if haveNExt() => (true, false, User, true, true),
5 if haveNExt() => (true, false, User, true, true),
6 if haveNExt() => (true, false, User, true, true),
7 if haveNExt() => (true, false, User, true, true),
11 if haveSupMode() => (true, false, Supervisor, false, true),
12 if haveSupMode() => (true, false, Supervisor, true, true),
13 if haveSupMode() => (true, false, Supervisor, true, true),
14 if haveSupMode() => (true, false, Supervisor, true, true),
15 if haveSupMode() => (true, false, Supervisor, true, true),
27 => (true, false, Machine, false, true),
28 => (true, false, Machine, true, true),
29 => (true, false, Machine, true, true),
30 => (true, false, Machine, true, true),
31 => (true, false, Machine, true, true),
_ => (false, true, Machine, true, true)
};
if (not(specialExists) |
ro & cs1 != zeros() |
(privLevel_to_bits(cur_privilege) <_u privLevel_to_bits(priv))) then {
handle_illegal();
RETIRE_FAIL
} else if (needASRW & (cs1 != zeros()) & not(pcc_access_system_regs())) then {
handle_cheri_cap_exception(CapEx_AccessSystemRegsViolation, 0b1 @ scr);
RETIRE_FAIL
} else if (needASR & not(pcc_access_system_regs())) then {
handle_cheri_cap_exception(CapEx_AccessSystemRegsViolation, 0b1 @ scr);
RETIRE_FAIL
Expand All @@ -397,7 +401,7 @@ function clause execute (CSpecialRW(cd, scr, cs1)) = {
pcc
},
1 => DDC,
3 => STIDC,
3 => UTIDC,
4 => UTCC,
5 => UTDC,
6 => UScratchC,
Expand All @@ -407,6 +411,7 @@ function clause execute (CSpecialRW(cd, scr, cs1)) = {
13 => STDC,
14 => SScratchC,
15 => legalize_epcc(SEPCC),
27 => MTIDC,
28 => MTCC,
29 => MTDC,
30 => MScratchC,
Expand Down
1 change: 1 addition & 0 deletions src/cheri_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ function ext_init_regs () = {
SScratchC = null_cap;
SEPCC = default_cap;

MTIDC = null_cap;
MTCC = default_cap;
MTDC = null_cap;
MScratchC = null_cap;
Expand Down
2 changes: 2 additions & 0 deletions src/cheri_scr_map.sail
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ mapping clause scr_name_map = 0b00101 <-> "utdc"
mapping clause scr_name_map = 0b00110 <-> "uscratchc"
mapping clause scr_name_map = 0b00111 <-> "uepcc"

mapping clause scr_name_map = 0b01011 <-> "stidc"
mapping clause scr_name_map = 0b01100 <-> "stcc"
mapping clause scr_name_map = 0b01101 <-> "stdc"
mapping clause scr_name_map = 0b01110 <-> "sscratchc"
mapping clause scr_name_map = 0b01111 <-> "sepcc"

mapping clause scr_name_map = 0b11011 <-> "mtidc"
mapping clause scr_name_map = 0b11100 <-> "mtcc"
mapping clause scr_name_map = 0b11101 <-> "mtdc"
mapping clause scr_name_map = 0b11110 <-> "mscratchc"
Expand Down
1 change: 1 addition & 0 deletions src/cheri_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ register STCC : Capability
register STDC : Capability
register SScratchC : Capability
register SEPCC : Capability
register MTIDC : Capability
register MTCC : Capability
register MTDC : Capability
register MScratchC : Capability
Expand Down

0 comments on commit 1f7b0e4

Please sign in to comment.