Skip to content

Commit

Permalink
CAndPerms: permit clearing GL on sealed caps
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf committed Nov 8, 2024
1 parent 64b2563 commit 01263b2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/cheri_insts.sail
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,23 @@ function clause execute(CAndPerm(cd, cs1, rs2)) = {
let perms = getCapPerms(cs1_val);
let mask = truncate(rs2_val, cap_perms_width);

let inCap = clearTagIfSealed(cs1_val);
let newCap = setCapPerms(inCap, (perms & mask));
let newperms = perms & mask;

let inCap = clearTagIf(cs1_val,
isCapSealed(cs1_val) &
/*
* Option 1: require the mask to be all ones except for the bottom bit, i.e.,
* GL(obal) (see cheri_cap_common.sail).
(~(mask | zero_extend(0b1)) != zeros())
*/
/*
* Option 2: require that the new permissions differ from the existing ones
* in at most the bottom bit, i.e., GL(obal).
*/
(((newperms ^ perms) | zero_extend(0b1)) != zero_extend(0b1))
);

let newCap = setCapPerms(inCap, newperms);

C(cd) = newCap;
RETIRE_SUCCESS
Expand Down

0 comments on commit 01263b2

Please sign in to comment.