Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New algorithm for bounds calculation and changes to cap encoding #76

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vmurali
Copy link
Contributor

@vmurali vmurali commented Oct 10, 2024

The algorithm implements Issue #75 . I also changed the encoding to represent base (B) and difference (M) rather than base (B) and top (T). This also simplified the expressions overall.

@vmurali
Copy link
Contributor Author

vmurali commented Oct 10, 2024

Note that I use the same names $e, d, i$ in setCapBounds as in #75 , to correlate the code with the math.

src/cheri_cap_common.sail Outdated Show resolved Hide resolved
…ource of error in pdf (PDF is still inconsitent with sail spec)
Comment on lines 316 to 317
let E = if c.cE == zeros(cap_cE_width) then zeros(cap_E_width) else c.ME @ (c.cE - zero_extend(c.ME));
let M = if c.cE == zeros(cap_cE_width) then c.ME @ c.cM else 0b1 @ c.cM;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly this works as follows:

cE ME E M8
0 0 0 0
0 1 0 1
1..15 0 1..15 1
1..15 1 16 .. 30 1

That works but I think it would be simpler to use a 5 bit cE with a single special value for E=0, M8=0 as follows:

cE E M8
0..30 0..30 1
31 0 0

It just uses two values to encode E=0 depending on the value of M8.
These two lines would become:

let E = if c.E == ones(cap_cE_width) then zeros(cap_E_width) else c.E;
let M = (if c.E == ones(cap_cE_width) then 0b0 else 0b1) @ c.cM;

@vmurali
Copy link
Contributor Author

vmurali commented Oct 11, 2024

Yes and yes!

@vmurali
Copy link
Contributor Author

vmurali commented Oct 11, 2024

@rmn30 https://gist.github.com/vmurali/fc50a31be8a2cdd2b82e9a1e3d164e59 seems to be the changes that you suggested. I am not sure what the problem is. It fails for 05.sealing test. The symptom I am seeing is that an untagged 64-bit 0 is interpreted as an untagged 0x100 length capability because the mantissa's MSB is 1. Is this problematic for code?

I tried to invert the polarity (all zeros means mantissa MSB is 0, all ones means mantissa MSB is 1), but that didn't work at all.

…n't work - a null capability is interpreted with 0x100 length and hence fails), namely

E = if cE == 31 then 0 else cE
M8 = if cE == 0 then 0 else 1

cE = if E == 0 && M8 == 1 then 31 else E
@vmurali
Copy link
Contributor Author

vmurali commented Oct 11, 2024

It looks like the null cap with non zero length is an issue in the code (at least for 06.sealing).

Robert's suggestion with reversed polarity is implemented now:
E = if cE == 31 then 0 else cE
M8 = if cE == 0 then 0 else 1

cE = if E == 0 && M8 == 1 then 31 else E

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants