From 2d761dec9fd4ba26793ff44fb27fad0c17c30db8 Mon Sep 17 00:00:00 2001 From: Robert Norton Date: Thu, 25 May 2017 17:12:41 +0100 Subject: Update ctoptr instruction to check that all of ct is within bounds of cb and that cb is not sealed as per ISAv6. --- cheri/cheri_insts.sail | 12 ++++++++++-- 1 file 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 *) } -- cgit v1.2.3