diff options
| author | Robert Norton | 2017-05-25 17:12:41 +0100 |
|---|---|---|
| committer | Robert Norton | 2017-05-26 09:27:23 +0100 |
| commit | 2d761dec9fd4ba26793ff44fb27fad0c17c30db8 (patch) | |
| tree | 2218f869c7339bc35a3d12d5113eaf7d68d5f3d1 | |
| parent | 9062322b77dbdb27ede7b47b76fd4eff9af98d47 (diff) | |
Update ctoptr instruction to check that all of ct is within bounds of cb and that cb is not sealed as per ISAv6.
| -rw-r--r-- | cheri/cheri_insts.sail | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cheri/cheri_insts.sail b/cheri/cheri_insts.sail index d63a0cc2..08a58516 100644 --- a/cheri/cheri_insts.sail +++ b/cheri/cheri_insts.sail @@ -243,12 +243,20 @@ function clause execute(CToPtr(rd, cb, ct)) = raise_c2_exception(CapEx_AccessSystemRegsViolation, ct) else if not (ct_val.tag) then raise_c2_exception(CapEx_TagViolation, ct) + else if (cb_val.tag) & (cb_val.sealed) then + raise_c2_exception(CapEx_SealViolation, cb) else { - wGPR(rd) := if not (cb_val.tag) then + let cbBase = getCapBase(cb_val) in + let cbTop = getCapTop(cb_val) in + let ctBase = getCapBase(ct_val) in + let ctTop = getCapTop(ct_val) in + wGPR(rd) := if (not (cb_val.tag)) | + (cbBase < ctBase) | + (cbTop > ctTop) then ((bit[64]) 0) else - (bit[64])(getCapCursor(cb_val) - getCapBase(ct_val)) + (bit[64])(getCapCursor(cb_val) - ctBase) } (* END_CToPtr *) } |
