Checkpoint work to propagate register numbers into the exception code.

There's another half of this left to do to propagate all the way into the CSR file.
This commit is contained in:
jon
2020-04-16 17:28:28 +01:00
parent 3add2cac5e
commit a77ecc59af
3 changed files with 23 additions and 19 deletions

View File

@@ -1082,6 +1082,8 @@ function DecodeResult decode(Instruction inst);
illegalInst = True;
end
endcase
dInst.capChecks.rn1 = {1'b0, regs.src1.Valid.Gpr};
dInst.capChecks.rn2 = {1'b0, regs.src2.Valid.Gpr};
end
default: begin
illegalInst = True;

View File

@@ -1,4 +1,3 @@
// Copyright (c) 2017 Massachusetts Institute of Technology
//
// Permission is hereby granted, free of charge, to any person
@@ -32,42 +31,43 @@ import ISA_Decls_CHERI::*;
(* noinline *)
function Maybe#(CapException) capChecks(CapPipe a, CapPipe b, CapChecks toCheck);
// TODO plumb register indices here
function Maybe#(CapException) e1(CHERIException e) = Valid(CapException{cheri_exc_reg: toCheck.rn1, cheri_exc_code: e});
function Maybe#(CapException) e2(CHERIException e) = Valid(CapException{cheri_exc_reg: toCheck.rn2, cheri_exc_code: e});
Maybe#(CapException) result = Invalid;
if (toCheck.src1_tag && !isValidCap(a))
result = Valid (CapException {cheri_exc_code: TagViolation});
result = e1(TagViolation);
else if (toCheck.src2_tag && !isValidCap(b))
result = Valid (CapException {cheri_exc_code: TagViolation});
result = e2(TagViolation);
else if (toCheck.src1_sealed_with_type && getKind(a) != SEALED_WITH_TYPE)
result = Valid (CapException {cheri_exc_code: SealViolation});
result = e1(SealViolation);
else if (toCheck.src1_unsealed && isValidCap(a) && isSealed(a))
result = Valid (CapException {cheri_exc_code: SealViolation});
result = e1(SealViolation);
else if (toCheck.src2_unsealed && isValidCap(b) && isSealed(b))
result = Valid (CapException {cheri_exc_code: SealViolation});
result = e2(SealViolation);
else if (toCheck.src1_sealed && isValidCap(a) && !isSealed(a))
result = Valid (CapException {cheri_exc_code: SealViolation});
result = e1(SealViolation);
else if (toCheck.src2_sealed && isValidCap(b) && !isSealed(b))
result = Valid (CapException {cheri_exc_code: SealViolation});
result = e2(SealViolation);
else if (toCheck.src1_src2_types_match && getType(a) != getType(b))
result = Valid (CapException {cheri_exc_code: TypeViolation});
result = e1(TypeViolation);
else if (toCheck.src1_permit_ccall && !getHardPerms(a).permitCCall)
result = Valid (CapException {cheri_exc_code: PermitCCallViolation});
result = e1(PermitCCallViolation);
else if (toCheck.src2_permit_ccall && !getHardPerms(b).permitCCall)
result = Valid (CapException {cheri_exc_code: PermitCCallViolation});
result = e2(PermitCCallViolation);
else if (toCheck.src1_permit_x && !getHardPerms(a).permitExecute)
result = Valid (CapException {cheri_exc_code: PermitXViolation});
result = e1(PermitXViolation);
else if (toCheck.src2_no_permit_x && getHardPerms(b).permitExecute)
result = Valid (CapException {cheri_exc_code: PermitXViolation});
result = e2(PermitXViolation);
else if (toCheck.src2_permit_unseal && !getHardPerms(b).permitUnseal)
result = Valid (CapException {cheri_exc_code: PermitUnsealViolation});
result = e2(PermitUnsealViolation);
else if (toCheck.src2_permit_seal && !getHardPerms(b).permitSeal)
result = Valid (CapException {cheri_exc_code: PermitSealViolation});
result = e2(PermitSealViolation);
else if (toCheck.src2_points_to_src1_type && getAddr(b) != zeroExtend(getType(a)))
result = Valid (CapException {cheri_exc_code: TypeViolation});
result = e2(TypeViolation);
else if (toCheck.src2_addr_valid_type && !validAsType(b, truncate(getAddr(b))))
result = Valid (CapException {cheri_exc_code: LengthViolation});
result = e2(LengthViolation);
else if (toCheck.src2_perm_subset_src1 && (getPerms(a) & getPerms(b)) != getPerms(b))
result = Valid (CapException {cheri_exc_code: SoftwarePermViolation});
result = e2(SoftwarePermViolation);
return result;
endfunction

View File

@@ -693,6 +693,8 @@ typedef struct {
Bool src2_addr_valid_type;
Bool src2_perm_subset_src1;
Bool src2_derivable;
Bit#(6) rn1;
Bit#(6) rn2;
} CapChecks deriving(Bits, Eq, FShow);
typedef CSR_XCapCause CapException;