summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Norton2016-04-19 11:59:43 +0100
committerRobert Norton2016-04-19 12:00:13 +0100
commit0f517f09b7708b95cb260e6c297414b0ba4c5075 (patch)
tree9eaea6836cd7e92f0031df7fbc68b3d2004af2c7
parent7de107d34f066ebee1f978ea8a270e17cc055221 (diff)
use unsigned for register offset and signed for immediate offset when computing capability relative address. This is a little counter-intuitive but seems to be what is written in the spec. and passes more tests. Will consult with mroe to check logic here and possibly extract into a function for clarity.
-rw-r--r--cheri/cheri_insts.sail8
1 files changed, 4 insertions, 4 deletions
diff --git a/cheri/cheri_insts.sail b/cheri/cheri_insts.sail
index c8ca156d..e008b46e 100644
--- a/cheri/cheri_insts.sail
+++ b/cheri/cheri_insts.sail
@@ -502,7 +502,7 @@ function clause execute (CLoad(rd, cb, rt, offset, signext, width, linked)) =
{
size := wordWidthBytes(width);
cursor := getCapCursor(cb_val);
- vAddr := cursor + signed(rGPR(rt)) + signed(offset);
+ vAddr := cursor + unsigned(rGPR(rt)) + signed(offset);
vAddr64:= (bit[64]) vAddr;
if ((vAddr + size) > ((nat) (cb_val.base) + ((nat) (cb_val.length)))) then
exit (raise_c2_exception(CapEx_LengthViolation, cb))
@@ -556,7 +556,7 @@ function clause execute (CStore(rs, cb, rt, rd, offset, width, conditional)) =
{
size := wordWidthBytes(width);
cursor := getCapCursor(cb_val);
- vAddr := cursor + signed(rGPR(rt)) + signed(offset);
+ vAddr := cursor + unsigned(rGPR(rt)) + signed(offset);
vAddr64:= (bit[64]) vAddr;
if ((vAddr + size) > ((nat) (cb_val.base) + ((nat) (cb_val.length)))) then
exit (raise_c2_exception(CapEx_LengthViolation, cb))
@@ -616,7 +616,7 @@ function clause execute (CSC(cs, cb, rt, rd, offset, conditional)) =
else
{
cursor := getCapCursor(cb_val);
- vAddr := cursor + signed(rGPR(rt)) + signed(offset);
+ vAddr := cursor + unsigned(rGPR(rt)) + signed(offset);
vAddr64:= (bit[64]) vAddr;
if ((vAddr + cap_size) > ((nat) (cb_val.base) + ((nat) (cb_val.length)))) then
exit (raise_c2_exception(CapEx_LengthViolation, cb))
@@ -660,7 +660,7 @@ function clause execute (CLC(cd, cb, rt, offset, linked)) =
else
{
cursor := getCapCursor(cb_val);
- vAddr := cursor + signed(rGPR(rt)) + signed(offset);
+ vAddr := cursor + unsigned(rGPR(rt)) + signed(offset);
vAddr64:= (bit[64]) vAddr;
if ((vAddr + cap_size) > ((nat) (cb_val.base) + ((nat) (cb_val.length)))) then
exit (raise_c2_exception(CapEx_LengthViolation, cb))