From 6263041aa1fd3b04eb8288860f1d5a3ce4925184 Mon Sep 17 00:00:00 2001 From: Akilan Date: Mon, 23 Feb 2026 12:26:03 +0000 Subject: [PATCH] fixed removing areas where delta values were used --- CHERICC_Fat.bsv | 52 ++++++++++++++++++++++++------------------------- CHERICap.bsv | 3 +-- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/CHERICC_Fat.bsv b/CHERICC_Fat.bsv index b186450..38840fb 100644 --- a/CHERICC_Fat.bsv +++ b/CHERICC_Fat.bsv @@ -145,7 +145,7 @@ typedef SizeOf#(Perms) PermsW; typedef TSub#(CapW, TAdd#( CapAddrW , TAdd#( OTypeW , TAdd#( CBoundsW - , TAdd#(PermsW, FlagsW)))))) ResW; + , TAdd#(PermsW, FlagsW))))) ResW; // The full capability structure, including the "tag" bit. typedef struct { Bool isCapability; @@ -1548,31 +1548,29 @@ typedef struct { Bit#(VA_Width) address; Bool validAddress; } CapTrim deriving(Bits, Eq, FShow); -// function CapTrim trimCap(CapMem cm); -// CapabilityInMemory cap = unpack(cm); -// Bit#(TSub#(CapAddrW,VA_Width)) addr_upper = truncateLSB(cap.address); -// return CapTrim{perms: cap.perms, -// flags: cap.flags, -// delta: cap.delta, -// bounds: cap.bounds, -// address: truncate(cap.address), -// validAddress: (addr_upper==signExtend(cap.address[valueOf(VA_Width)-1])) -// }; -// endfunction -// function CapMem untrimCap(CapTrim ct); -// // Encode an invalid address as the bit above the last valid bit being different. -// Bit#(1) addressMsb = ct.address[valueOf(VA_Width)-1]; -// if (!ct.validAddress) addressMsb = ^addressMsb; -// return pack(CapabilityInMemory{ -// isCapability: True, -// perms: ct.perms, -// reserved: 0, -// flags: ct.flags, -// otype: otype_unsealed, -// delta: ct.delta, -// bounds: ct.bounds, -// address: signExtend({addressMsb,ct.address}) -// }); -// endfunction +function CapTrim trimCap(CapMem cm); + CapabilityInMemory cap = unpack(cm); + Bit#(TSub#(CapAddrW,VA_Width)) addr_upper = truncateLSB(cap.address); + return CapTrim{perms: cap.perms, + flags: cap.flags, + bounds: cap.bounds, + address: truncate(cap.address), + validAddress: (addr_upper==signExtend(cap.address[valueOf(VA_Width)-1])) + }; +endfunction +function CapMem untrimCap(CapTrim ct); + // Encode an invalid address as the bit above the last valid bit being different. + Bit#(1) addressMsb = ct.address[valueOf(VA_Width)-1]; + if (!ct.validAddress) addressMsb = ^addressMsb; + return pack(CapabilityInMemory{ + isCapability: True, + perms: ct.perms, + reserved: 0, + flags: ct.flags, + otype: otype_unsealed, + bounds: ct.bounds, + address: signExtend({addressMsb,ct.address}) + }); +endfunction endpackage diff --git a/CHERICap.bsv b/CHERICap.bsv index 9a79968..b7a203a 100644 --- a/CHERICap.bsv +++ b/CHERICap.bsv @@ -119,7 +119,7 @@ endfunction // XXX TODO augment with all architectural bounds/ repbounds ? function Fmt showCHERICap (capT cap) - provisos (CHERICap #(capT , otypeW, flgW, addrW, inMemW, maskableW, delta)); + provisos (CHERICap #(capT , otypeW, flgW, addrW, inMemW, maskableW)); return $format( "Valid: 0x%0x", isValidCap(cap)) + $format(" Perms: 0x%0x", getPerms(cap)) + $format(" Kind: ", fshow(getKind(cap))) + @@ -153,7 +153,6 @@ typeclass CHERICap #( type capT // type of the CHERICap capability , numeric type addrW // width of the address , numeric type inMemW // width of the capability in mem , numeric type maskableW // width of maskable bits - , numeric type delta // size of delta (tlb bypass) ) dependencies (capT determines (otypeW, flgW, addrW, inMemW, maskableW));