Skip to content

Commit

Permalink
Proposed relaxing of cjalr sealing
Browse files Browse the repository at this point in the history
Attempt at capturing #85
  • Loading branch information
nwf committed Nov 13, 2024
1 parent 01ace11 commit 54497f9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/cheri_insts.sail
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,24 @@ function clause execute(CJALR(imm, cs1, cd)) = {
let (success, linkCap) = setCapAddr(PCC, nextPC); /* Note that nextPC accounts for compressed instructions */
assert(success, "Link cap should always be representable.");
assert(not (isCapSealed(linkCap)), "Link cap should always be unsealed");
let sentry_type = if mstatus.MIE() == 0b1 then otype_sentry_bie else otype_sentry_bid;
C(cd) = sealCap(linkCap, to_bits(cap_otype_width, sentry_type));

if (cd != zreg) & (cd != ra) {
/*
* Generate an unsealed return capability. From the conditions above, it
* must be the case that cs1 is unsealed or a forward inheriting sentry.
*/
C(cd) = linkCap;
} else if (cd == ra) {
/*
* When writing to ra, generate a sealed return capability. We can get
* here with cs1 unsealed or any forward sentry type.
*/
let sentry_type = if mstatus.MIE() == 0b1 then otype_sentry_bie else otype_sentry_bid;
C(cd) = sealCap(linkCap, to_bits(cap_otype_width, sentry_type));
} else {
/* No writeback to zreg */
}

nextPC = newPC;
nextPCC = unsealCap(cs1_val);
if unsigned(cs1_val.otype) == otype_sentry_id | unsigned(cs1_val.otype) == otype_sentry_bid then
Expand Down

0 comments on commit 54497f9

Please sign in to comment.