summaryrefslogtreecommitdiff
path: root/cheri
diff options
context:
space:
mode:
authorRobert Norton2017-10-16 16:24:59 +0100
committerRobert Norton2017-10-16 16:24:59 +0100
commit7bd52dedf93ccaf4811307e12b8402fad6ab2312 (patch)
tree978255883962ed8fc25316967dac07507591c8ae /cheri
parent1522c658263cb1f646e44489ba8a19764fe8f4c4 (diff)
add CTestSubset instruction.
Diffstat (limited to 'cheri')
-rw-r--r--cheri/cheri_insts.sail37
1 files changed, 36 insertions, 1 deletions
diff --git a/cheri/cheri_insts.sail b/cheri/cheri_insts.sail
index 1d6c4a13..c27f6dc7 100644
--- a/cheri/cheri_insts.sail
+++ b/cheri/cheri_insts.sail
@@ -133,7 +133,7 @@ function clause decode (0b010010 : 0b00000 : (regno) rd : (regno) cb : (regno) c
function clause decode (0b010010 : 0b00000 : (regno) rd : (regno) cb : (regno) cs : 0b011010) = Some(CPtrCmp(rd, cb, cs, CEXEQ))
function clause decode (0b010010 : 0b00000 : (regno) rd : (regno) cb : (regno) cs : 0b100001) = Some(CPtrCmp(rd, cb, cs, CNEXEQ))
-(* function clause decode (0b010010 : 0b00000 : (regno) rd : (regno) cb : (regno) ct : 0b100000) = Some(CTestSubset(rd, cb, ct)) *)
+function clause decode (0b010010 : 0b00000 : (regno) rd : (regno) cb : (regno) ct : 0b100000) = Some(CTestSubset(rd, cb, ct))
function clause decode (0b010010 : 0b01001 : (regno) cd : (bit[16]) imm) = Some(CBX(cd, imm, true)) (* CBTU *)
function clause decode (0b010010 : 0b01010 : (regno) cd : (bit[16]) imm) = Some(CBX(cd, imm, false)) (* CBTS *)
@@ -826,6 +826,41 @@ function clause execute (CCheckType(cs, cb)) =
(* END_CCheckType *)
}
+union ast member regregreg CTestSubset
+function clause execute (CTestSubset(rd, cb, ct)) =
+{
+ (* START_CTestSubset *)
+ checkCP2usable();
+ cb_val := readCapReg(cb);
+ ct_val := readCapReg(ct);
+ ct_top := getCapTop(ct_val);
+ ct_base := getCapBase(ct_val);
+ ct_perms := getCapPerms(ct_val);
+ cb_top := getCapTop(cb_val);
+ cb_base := getCapBase(cb_val);
+ cb_perms := getCapPerms(cb_val);
+ if (register_inaccessible(cb)) then
+ raise_c2_exception(CapEx_AccessSystemRegsViolation, cb)
+ else if (register_inaccessible(ct)) then
+ raise_c2_exception(CapEx_AccessSystemRegsViolation, ct)
+ else {
+ (bit[64]) result := EXTZ(if (cb_val.tag != ct_val.tag) then
+ 0x0
+ else if (cb_val.sealed != ct_val.sealed) then
+ 0x0
+ else if (ct_base < cb_base) then
+ 0x0
+ else if (ct_top > cb_top) then
+ 0x0
+ else if ((ct_perms & cb_perms) != cb_perms) then
+ 0x0
+ else
+ 0x1);
+ wGPR(rd) := result;
+ }
+ (* END_CTestSubset *)
+}
+
union ast member regregreg CSeal
function clause execute (CSeal(cd, cs, ct)) =
{