Remove traps from CSeal and CCSeal

This commit is contained in:
Peter Rugg
2023-01-16 10:43:32 +00:00
parent ecdc2e0107
commit 9f24a516e6
2 changed files with 6 additions and 28 deletions

View File

@@ -1022,16 +1022,6 @@ function DecodeResult decode(Instruction inst, Bool cap_mode);
dInst.capFunc = CapModify (ModifyOffset (IncOffset));
end
f7_cap_CSeal: begin
dInst.capChecks.src2_tag = True;
dInst.capChecks.src2_permit_seal = True;
dInst.capChecks.src2_addr_valid_type = True;
dInst.capChecks.check_enable = True;
dInst.capChecks.check_authority_src = Src2;
dInst.capChecks.check_low_src = Src2Addr;
dInst.capChecks.check_high_src = Src2Addr;
dInst.capChecks.check_inclusive = False;
dInst.iType = Cap;
regs.dst = Valid(tagged Gpr rd);
regs.src1 = Valid(tagged Gpr rs1);
@@ -1039,16 +1029,6 @@ function DecodeResult decode(Instruction inst, Bool cap_mode);
dInst.capFunc = CapModify (Seal);
end
f7_cap_CCSeal: begin
dInst.capChecks.src2_addr_valid_type = True;
dInst.capChecks.src2_permit_seal = True;
dInst.capChecks.ccseal_bypass = True;
dInst.capChecks.check_enable = True;
dInst.capChecks.check_authority_src = Src2;
dInst.capChecks.check_low_src = Src2Addr;
dInst.capChecks.check_high_src = Src2Addr;
dInst.capChecks.check_inclusive = False;
dInst.iType = Cap;
regs.dst = Valid(tagged Gpr rd);
regs.src1 = Valid(tagged Gpr rs1);

View File

@@ -255,6 +255,8 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
let a_mut = setValidCap(a, isValidCap(a) && getKind(a) == UNSEALED);
let b_mut = setValidCap(b, isValidCap(b) && getKind(b) == UNSEALED);
match {.a_type, .a_res} = extractType(a);
Bool sealPassthrough = !isValidCap(b) || getKind(a) != UNSEALED || !isInBounds(b, False) || getAddr(b) == otype_unsealed_ext;
Bool sealIllegal = getKind(b) != UNSEALED || !getHardPerms(b).permitSeal || !validAsType(b, getAddr(b));
CapPipe res = (case(func) matches
tagged ModifyOffset .offsetOp :
modifyOffset(a_mut, getAddr(b), offsetOp == IncOffset).value;
@@ -273,11 +275,11 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
tagged SealEntry :
setKind(a_mut, SENTRY);
tagged Seal :
clearTagIf(setKind(a_mut, SEALED_WITH_TYPE (truncate(getAddr(b)))), getKind(b) != UNSEALED);
clearTagIf( setKind(a_mut, SEALED_WITH_TYPE (truncate(getAddr(b))))
, sealPassthrough || sealIllegal);
tagged CSeal :
((validAsType(b, getAddr(b)) && isValidCap(b) && getKind(a) == UNSEALED) ?
setKind(a_mut, SEALED_WITH_TYPE (truncate(getAddr(b))))
: a);
(sealPassthrough ? a :
clearTagIf(setKind(a_mut, SEALED_WITH_TYPE (truncate(getAddr(b)))), sealIllegal));
tagged Unseal .src :
clearTagIf(setKind(((src == Src1) ? a:b), UNSEALED), (src == Src1) && (getKind(b) != UNSEALED));
tagged AndPerm :
@@ -439,10 +441,6 @@ function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, C
if (dInst.capChecks.cfromptr_bypass && getAddr(rVal1) == 0) begin
capException = Invalid;
end
if (dInst.capChecks.ccseal_bypass && (!isValidCap(rVal2) || getAddr(rVal2) == -1 || getKind(rVal1) != UNSEALED || !isInBounds(rVal2, False)) && isValidCap(rVal1)) begin
capException = Invalid;
boundsCheck = Invalid;
end
cf.nextPc = setKind(cf.nextPc, UNSEALED);
cf.mispredict = cf.nextPc != ppc;