Use the bounds of PCC to check legacy control flow instructions rather

than the bounds of the newPCC after C(Set/Inc)Offset, which may have
become unrepresentable.
This commit is contained in:
jon
2020-05-01 12:17:20 +01:00
parent 90d9d7cbc7
commit 0177c2cd6e
3 changed files with 11 additions and 6 deletions

View File

@@ -381,7 +381,7 @@ function DecodeResult decode(Instruction inst);
dInst.csr = tagged Invalid;
dInst.execFunc = tagged Br AT;
dInst.capChecks.check_enable = True;
dInst.capChecks.check_authority_src = Src1;
dInst.capChecks.check_authority_src = Pcc;
dInst.capChecks.check_low_src = Src1Addr;
dInst.capChecks.check_high_src = Src1AddrPlus2;
dInst.capChecks.check_inclusive = True;
@@ -396,7 +396,7 @@ function DecodeResult decode(Instruction inst);
dInst.csr = tagged Invalid;
dInst.execFunc = tagged Br AT;
dInst.capChecks.check_enable = True;
dInst.capChecks.check_authority_src = Src1;
dInst.capChecks.check_authority_src = Pcc;
dInst.capChecks.check_low_src = Src1Addr;
dInst.capChecks.check_high_src = Src1AddrPlus2;
dInst.capChecks.check_inclusive = True;
@@ -418,7 +418,7 @@ function DecodeResult decode(Instruction inst);
dInst.imm = Valid(immB);
dInst.csr = tagged Invalid;
dInst.capChecks.check_enable = True;
dInst.capChecks.check_authority_src = Src1;
dInst.capChecks.check_authority_src = Pcc;
dInst.capChecks.check_low_src = Src1Addr;
dInst.capChecks.check_high_src = Src1AddrPlus2;
dInst.capChecks.check_inclusive = True;

View File

@@ -74,7 +74,7 @@ function Maybe#(CSR_XCapCause) capChecks(CapPipe a, CapPipe b, CapChecks toCheck
endfunction
(* noinline *)
function Maybe#(BoundsCheck) prepareBoundsCheck(CapPipe a, CapPipe b, CapChecks toCheck);
function Maybe#(BoundsCheck) prepareBoundsCheck(CapPipe a, CapPipe b, CapPipe pcc, CapChecks toCheck);
BoundsCheck ret = ?;
CapPipe authority = ?;
case(toCheck.check_authority_src)
@@ -86,6 +86,10 @@ function Maybe#(BoundsCheck) prepareBoundsCheck(CapPipe a, CapPipe b, CapChecks
authority = b;
ret.authority_idx = toCheck.rn2;
end
Pcc: begin
authority = pcc;
ret.authority_idx = 6'b100000;
end
endcase
ret.authority_base = getBase(authority);
ret.authority_top = getTop(authority);
@@ -297,7 +301,7 @@ function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, C
CapPipe modify_result = capModify(rVal1, aluVal2, modFunc);
CapPipe link_pcc = addPc(pcc, ((orig_inst [1:0] == 2'b11) ? 4 : 2));
Maybe#(CSR_XCapCause) capException = capChecks(rVal1, aluVal2, dInst.capChecks);
Maybe#(BoundsCheck) boundsCheck = prepareBoundsCheck(rVal1, aluVal2, dInst.capChecks);
Maybe#(BoundsCheck) boundsCheck = prepareBoundsCheck(rVal1, aluVal2, pcc, dInst.capChecks);
CapPipe cap_alu_result = case (dInst.execFunc) matches tagged CapInspect .x: nullWithAddr(inspect_result);
tagged CapModify .x: modify_result;

View File

@@ -499,7 +499,8 @@ typedef struct {
typedef enum {
Src1,
Src2
Src2,
Pcc
} CheckAuthoritySrc deriving(Bits, Eq, FShow);
typedef enum {