Avoid shift amount overflow in maskAddr
This commit is contained in:
@@ -1021,8 +1021,9 @@ instance CHERICap #(CapReg, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
|
||||
function CapReg maskAddr (CapReg cap, Bit#(TSub#(MW, 3)) mask);
|
||||
cap.address[valueOf(TSub#(MW, 4)):0] = cap.address[valueOf(TSub#(MW, 4)):0] & mask;
|
||||
UInt#(TAdd#(ExpW,1)) expExt = zeroExtend(cap.bounds.exp);
|
||||
//Update addrBits. Since exp can be up to 64, extend to 64 + 8 bits so bit-select is always in range
|
||||
cap.addrBits = (({40'b0,cap.address})[cap.bounds.exp+fromInteger(valueOf(TSub#(MW,1))):cap.bounds.exp]); //TODO avoid shift?
|
||||
cap.addrBits = (({40'b0,cap.address})[expExt+fromInteger(valueOf(TSub#(MW,1))):expExt]); //TODO avoid shift?
|
||||
return cap;
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user