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

Add an implementation of the proposed CRelocate instruction #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jrtc27
Copy link
Member

@jrtc27 jrtc27 commented Nov 12, 2022

No description provided.

Whilst not used inside the model, sail-cheri-riscv-verif will make use
of this for properties relating to the upcoming CRelocate.
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

Commit message should probably reference CTSRD-CHERI/cheri-specification#3?

* **tag** field cleared, and its **base** and **address* replaced with
* *cs1*.**base** $+$ *rs2* and *cs1*.**address** $+$ *rs2* respectively,
* subject to representability. If the resulting capability is not
* representable, the value of *rs2* as used for both calculations is
Copy link
Member

Choose a reason for hiding this comment

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

I find this sentence rather hard to parse

function getRepresentableLength(len) : xlenbits -> xlenbits = {
let m = getRepresentableAlignmentMask(len);
(len + ~(m)) & m
}

function relocateCap(cap, offset) : (Capability, CapAddrBits) -> (bool, Capability) = {
let E = min(cap_max_E, unsigned(cap.E));
Copy link
Member

Choose a reason for hiding this comment

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

This is a rather large and complex piece of code that looks like a close duplicate of other decoding code. I think this could either do with comments and/or share more code with getCapBoundsBits.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, parts of it do, but it's not clear how you'd really factor it out into a common function, I guess the only thing you could do is have an (a, B, T) -> (correction_base, correction_top) helper, if that's what you mean?

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.

3 participants