Add SetAddrUnsafe function to the typeclass to support proper bounds checking for PCC.
This commit is contained in:
@@ -870,6 +870,7 @@ instance CHERICap #(CapMem, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
|||||||
function setType = error("feature not implemented for this cap type");
|
function setType = error("feature not implemented for this cap type");
|
||||||
function getAddr = error("feature not implemented for this cap type");
|
function getAddr = error("feature not implemented for this cap type");
|
||||||
function setAddr = error("feature not implemented for this cap type");
|
function setAddr = error("feature not implemented for this cap type");
|
||||||
|
function setAddrUnsafe = error("feature not implemented for this cap type");
|
||||||
function getOffset = error("feature not implemented for this cap type");
|
function getOffset = error("feature not implemented for this cap type");
|
||||||
function modifyOffset = error("feature not implemented for this cap type");
|
function modifyOffset = error("feature not implemented for this cap type");
|
||||||
function getBase = error("feature not implemented for this cap type");
|
function getBase = error("feature not implemented for this cap type");
|
||||||
@@ -983,6 +984,7 @@ instance CHERICap #(CapReg, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
|||||||
function getAddr (cap) = truncate(getAddress(cap));
|
function getAddr (cap) = truncate(getAddress(cap));
|
||||||
|
|
||||||
function setAddr = error("feature not implemented for this cap type");
|
function setAddr = error("feature not implemented for this cap type");
|
||||||
|
function setAddrUnsafe = error("feature not implemented for this cap type");
|
||||||
|
|
||||||
function getOffset = error("feature not implemented for this cap type");
|
function getOffset = error("feature not implemented for this cap type");
|
||||||
function modifyOffset = error("feature not implemented for this cap type");
|
function modifyOffset = error("feature not implemented for this cap type");
|
||||||
@@ -1110,6 +1112,13 @@ instance CHERICap #(CapPipe, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
|||||||
cap.tempFields = getTempFields(cap.capFat);
|
cap.tempFields = getTempFields(cap.capFat);
|
||||||
return Exact {exact: result.v, value: cap};
|
return Exact {exact: result.v, value: cap};
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function CapPipe setAddrUnsafe (CapPipe cap, Bit#(CapAddressW) address);
|
||||||
|
let result = setCapPointer(cap.capFat, zeroExtend(address));
|
||||||
|
cap.capFat = result;
|
||||||
|
cap.tempFields = getTempFields(cap.capFat);
|
||||||
|
return cap;
|
||||||
|
endfunction
|
||||||
|
|
||||||
function getOffset (x) = getOffsetFat(x.capFat, x.tempFields);
|
function getOffset (x) = getOffsetFat(x.capFat, x.tempFields);
|
||||||
|
|
||||||
|
|||||||
10
CHERICap.bsv
10
CHERICap.bsv
@@ -120,17 +120,19 @@ typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n, n
|
|||||||
|
|
||||||
// Get the address pointed to by the capability
|
// Get the address pointed to by the capability
|
||||||
function Bit#(n) getAddr (t cap);
|
function Bit#(n) getAddr (t cap);
|
||||||
// Set the address of the capability. Result invalid if not exact
|
// Set the address of the capability. Result invalid if unrepresentable
|
||||||
function Exact#(t) setAddr (t cap, Bit#(n) addr);
|
function Exact#(t) setAddr (t cap, Bit#(n) addr);
|
||||||
|
// Set the address of the capability. Result assumed to be representable
|
||||||
|
function t setAddrUnsafe (t cap, Bit#(n) addr);
|
||||||
|
|
||||||
// Get the offset of the capability
|
// Get the offset of the capability
|
||||||
function Bit#(n) getOffset (t cap) = getAddr(cap) - getBase(cap);
|
function Bit#(n) getOffset (t cap) = getAddr(cap) - getBase(cap);
|
||||||
// Modify the offset of the capability. Result invalid if not exact
|
// Modify the offset of the capability. Result invalid if unrepresentable
|
||||||
function Exact#(t) modifyOffset (t cap, Bit#(n) offset, Bool doInc);
|
function Exact#(t) modifyOffset (t cap, Bit#(n) offset, Bool doInc);
|
||||||
// Set the offset of the capability. Result invalid if not exact
|
// Set the offset of the capability. Result invalid if unrepresentable
|
||||||
function Exact#(t) setOffset (t cap, Bit#(n) offset) =
|
function Exact#(t) setOffset (t cap, Bit#(n) offset) =
|
||||||
modifyOffset(cap, offset, False);
|
modifyOffset(cap, offset, False);
|
||||||
// Set the offset of the capability. Result invalid if not exact
|
// Set the offset of the capability. Result invalid if unrepresentable
|
||||||
function Exact#(t) incOffset (t cap, Bit#(n) inc) =
|
function Exact#(t) incOffset (t cap, Bit#(n) inc) =
|
||||||
modifyOffset(cap, inc, True);
|
modifyOffset(cap, inc, True);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user