From 1f7b0e471fe9eae0e0f60dcde9113e298644ac2f Mon Sep 17 00:00:00 2001 From: Franz Fuchs Date: Wed, 8 May 2024 09:07:16 +0100 Subject: [PATCH] Added updated support for xTIDC registers --- src/cheri_insts.sail | 43 +++++++++++++++++++++++------------------ src/cheri_regs.sail | 1 + src/cheri_scr_map.sail | 2 ++ src/cheri_sys_regs.sail | 1 + 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/cheri_insts.sail b/src/cheri_insts.sail index c7a4807..aac396d 100644 --- a/src/cheri_insts.sail +++ b/src/cheri_insts.sail @@ -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 @@ -397,7 +401,7 @@ function clause execute (CSpecialRW(cd, scr, cs1)) = { pcc }, 1 => DDC, - 3 => STIDC, + 3 => UTIDC, 4 => UTCC, 5 => UTDC, 6 => UScratchC, @@ -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, diff --git a/src/cheri_regs.sail b/src/cheri_regs.sail index 336cbdf..7b31e79 100644 --- a/src/cheri_regs.sail +++ b/src/cheri_regs.sail @@ -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; diff --git a/src/cheri_scr_map.sail b/src/cheri_scr_map.sail index 75700b0..53e14b1 100644 --- a/src/cheri_scr_map.sail +++ b/src/cheri_scr_map.sail @@ -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" diff --git a/src/cheri_sys_regs.sail b/src/cheri_sys_regs.sail index e68bdd6..3ee3d58 100644 --- a/src/cheri_sys_regs.sail +++ b/src/cheri_sys_regs.sail @@ -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