From d98b6571f6ca2ad709ba16e61a8d316b396610ee Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 20 Feb 2026 01:59:39 +0000 Subject: [PATCH] hack for fromMem function to pass compile time checks --- libs/cheri-cap-lib | 2 +- src_Core/ISA/ISA_Decls_CHERI.bsv | 2 +- src_Core/RISCY_OOO/procs/lib/Exec.bsv | 39 +++++++++++++++++++++------ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/libs/cheri-cap-lib b/libs/cheri-cap-lib index bd95a8b..f7884bb 160000 --- a/libs/cheri-cap-lib +++ b/libs/cheri-cap-lib @@ -1 +1 @@ -Subproject commit bd95a8b5b129ff3dd2134082e8dc70bce11ad988 +Subproject commit f7884bb932b33355be650d0bc9be9ef8702fafcd diff --git a/src_Core/ISA/ISA_Decls_CHERI.bsv b/src_Core/ISA/ISA_Decls_CHERI.bsv index 13db74d..9763cd4 100755 --- a/src_Core/ISA/ISA_Decls_CHERI.bsv +++ b/src_Core/ISA/ISA_Decls_CHERI.bsv @@ -228,4 +228,4 @@ Bit #(3) f3_AMO_CAP = w_SIZE_CAP; Bit #(XLEN) otype_unsealed_ext = -1; Bit #(XLEN) otype_sentry_ext = -2; Bit #(XLEN) otype_res0_ext = -3; -Bit #(XLEN) otype_res1_ext = -4; +Bit #(XLEN) otype_res1_ext = -4; \ No newline at end of file diff --git a/src_Core/RISCY_OOO/procs/lib/Exec.bsv b/src_Core/RISCY_OOO/procs/lib/Exec.bsv index ccc0c00..78b32b6 100644 --- a/src_Core/RISCY_OOO/procs/lib/Exec.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Exec.bsv @@ -285,7 +285,7 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func); tagged FromPtr : (getAddr(a) == 0 ? nullCap : setAddr(b_mut, getAddr(a)).value); tagged SetHigh: - // fromMem(tuple2(False, {getAddr(b), getAddr(a)} :: Bit#(CapW))); + // fromMemTest(tuple2(False, {getAddr(b), getAddr(a)})); capFromAddrs(a,b); // getTruncatedTuple(getAddr(b)) tagged BuildCap : @@ -299,14 +299,37 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func); return res; endfunction -function CapPipe capFromAddrs (capT a, capT b); +// function CapPipe capFromAddrs (CapPipe a, CapPipe b) +// provisos ( +// CHERICap#(CapPipe, o, f, addrW, CapW, m, d) +// ); + +// // Get full serialized capability of 'a' +// match {.tag, .rawA} = toMem(a); // rawA : Bit#(inMemW) + +// // Replace low addrW bits with address from b +// Bit#(addrW) newAddr = getAddr(b); + +// Bit#(inMemW) newRaw = +// { rawA[CapW-1 : addrW] // keep upper metadata +// , newAddr // replace address field +// }; + +// return fromMem(tuple2(tag, newRaw)); + +// endfunction +function CapPipe capFromAddrs(capT a, capT b) + provisos (CHERICap#(capT, a, b, 64, d, e, f)); // exact instance // Extract addresses - Bit#(0) addrA = getAddr(a); - Bit#(116) addrB = getAddr(b); - // Concatenate into a 180-bit raw capability - Bit#(116) rawCap = {addrB, addrA}; - // Convert to CapPipe using fromMem - return fromMem(tuple2(False, rawCap)); + Bit#(64) addrA = getAddr(a); + Bit#(64) addrB = getAddr(b); + // Extra bits to reach inMemW = 180 + Bit#(52) extra = 0; // can be zeros or delta bits if needed + + // Concatenate explicitly typed + Bit#(180) rawBits = {addrB, addrA, extra}; + + return fromMem(tuple2(False, rawBits)); endfunction (* noinline *)