-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some SMT properties for CSetBoundsRoundDown
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*! | ||
* THIS checks that CSetBoundsRoundDown meets its description: the result leaves | ||
* the base unaltered and returns a capability with length at most the requested | ||
* size. | ||
*/ | ||
$property | ||
function prop_setboundsrounddown_brief(reqBase : CapAddrBits, reqLen : CapAddrBits) -> bool = { | ||
let c = setCapBoundsRoundDown(root_cap_mem, reqBase, reqLen); | ||
let (base, top) = getCapBoundsBits(c); | ||
let reqTop = (0b0 @ reqBase) + (0b0 @ reqLen); | ||
let saneTop = reqTop <=_u 0b1@0x00000000; | ||
saneTop --> ((base == reqBase) & (top <=_u reqTop) & (0b0 @ base <=_u top)) | ||
} | ||
|
||
/*! | ||
* THIS checks that exactly representable requests give equal answers between | ||
* CSetBoundsRoundDown and CSetBounds. | ||
*/ | ||
$property | ||
function prop_setboundsrounddown_exact(reqBase : CapAddrBits, reqLen : CapAddrBits) -> bool = { | ||
let cRD = setCapBoundsRoundDown(root_cap_mem, reqBase, reqLen); | ||
let (exact, cSB) = setCapBounds(root_cap_mem, reqBase, reqLen); | ||
exact --> (cRD == cSB) | ||
} | ||
|
||
/*! | ||
* THIS checks that the resulting capability has nonzero length unless requested | ||
*/ | ||
$property | ||
function prop_setboundsrounddown_nonzero(reqBase : CapAddrBits, reqLen : CapAddrBits) -> bool = { | ||
let c = setCapBoundsRoundDown(root_cap_mem, reqBase, reqLen); | ||
let (resBase, resTop) = getCapBoundsBits(c); | ||
let reqTop = (0b0 @ reqBase) + (0b0 @ reqLen); | ||
let saneTop = reqTop <=_u 0b1@0x00000000; | ||
(saneTop & (reqLen != zeros())) --> (0b0 @ resBase <_u resTop) | ||
} | ||
|
||
/*! | ||
* THIS checks that [setCapBoundsRoundDown] returns the most precise encodable | ||
* bounds that satisfy the requested bounds. | ||
*/ | ||
$property | ||
function prop_setboundsrounddown_precise(reqBase1 : CapAddrBits, reqLen1 : CapAddrBits, | ||
c2 : CapBits) -> bool = { | ||
let c1 = setCapBoundsRoundDown(root_cap_mem, reqBase1, reqLen1); | ||
let (b1, t1) = getCapBoundsBits(c1); | ||
let reqTop1 = (0b0 @ reqBase1) + (0b0 @ reqLen1); | ||
let saneTop1 = reqTop1 <=_u 0b1@0x00000000; | ||
let (b2, t2) = getCapBoundsBits(capBitsToCapability(false, c2)); | ||
let validBase = b2 == reqBase1; | ||
let validTop = t2 <=_u reqTop1; | ||
let betterTop = t1 <_u t2; | ||
(saneTop1) --> not(validBase & validTop & betterTop) | ||
} |