From 8cc8f71cb91cf22e08ce33582ffc7df3f0fa40d9 Mon Sep 17 00:00:00 2001 From: Peter Rugg Date: Wed, 22 Apr 2020 14:27:11 +0100 Subject: [PATCH] Perform bounds check on requested length rather than rounded length. This prevents issues with overflow in the top, and should be correct based on the rounding used in the SetBounds function. --- src_Core/RISCY_OOO/procs/lib/Exec.bsv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src_Core/RISCY_OOO/procs/lib/Exec.bsv b/src_Core/RISCY_OOO/procs/lib/Exec.bsv index 7681a34..51a82c5 100755 --- a/src_Core/RISCY_OOO/procs/lib/Exec.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Exec.bsv @@ -74,7 +74,7 @@ function Maybe#(CapException) capChecks(CapPipe a, CapPipe b, CapChecks toCheck) endfunction (* noinline *) -function Maybe#(BoundsCheck) prepareBoundsCheck(CapPipe a, CapPipe b, CapPipe c, CapChecks toCheck); +function Maybe#(BoundsCheck) prepareBoundsCheck(CapPipe a, CapPipe b, CapChecks toCheck); BoundsCheck ret = ?; CapPipe authority = ?; case(toCheck.check_authority_src) @@ -99,9 +99,9 @@ function Maybe#(BoundsCheck) prepareBoundsCheck(CapPipe a, CapPipe b, CapPipe c, case(toCheck.check_high_src) Src1Top: ret.check_high = getTop(a); - Src2Addr: ret.check_high = {0,getAddr(b)}; + Src2Addr: ret.check_high = {1'b0,getAddr(b)}; Src2Type: ret.check_high = zeroExtend(getType(b)); - ResultTop: ret.check_high = {0,getTop(c)}; // TODO will be bad for timing + ResultTop: ret.check_high = {1'b0,getAddr(a)} + {1'b0,getAddr(b)}; endcase ret.check_inclusive = toCheck.check_inclusive; @@ -284,7 +284,7 @@ function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, C CapModifyFunc modFunc = ccall ? (Unseal (Src2)):dInst.execFunc.CapModify; CapPipe modify_result = capModify(rVal1, aluVal2, modFunc); Maybe#(CapException) capException = capChecks(rVal1, aluVal2, dInst.capChecks); - Maybe#(BoundsCheck) boundsCheck = prepareBoundsCheck(rVal1, aluVal2, modify_result, dInst.capChecks); + Maybe#(BoundsCheck) boundsCheck = prepareBoundsCheck(rVal1, aluVal2, dInst.capChecks); CapPipe cap_alu_result = case (dInst.execFunc) matches tagged CapInspect .x: nullWithAddr(inspect_result); tagged CapModify .x: modify_result;