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

Clarify CJALR operation order #10

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

Timmmm
Copy link
Contributor

@Timmmm Timmmm commented Jan 22, 2024

Clarify that length violations are checked on the address after it has undergone invalid address conversion.

Also fix a typo in the title.

Fixes #9

Comment on lines 35 to 36
length violation check is a stricter condition. The sealing check can also be
skipped because the capability will always have been unsealed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about the sealing part? We still want to raise an error if cs1 is a sentry and the offset is non-zero?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, we would like to keep the sealing check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant the sealing check in the invalid address conversion procedure. I'll reword it to make that clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reworded it. Hopefully clearer.

@Timmmm Timmmm force-pushed the user/timh/clarify_cjalr branch from ccc54a1 to 1ae67d2 Compare January 23, 2024 09:00
When performing invalid address conversion the tag never needs to be cleared because
the earlier length violation check is a stricter condition than the representability
check, and the capability is always unsealed before invalid address conversion.
====
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't fully agree with this note for a couple of reasons:

  1. The tag is never cleared because the instruction excepts in all cases instead of changing PCC when something goes wrong
  2. The capability is not always unsealed. As @arichardson pointed out, there is an exception when the immediate is not 0 because you may be jumping to an instruction that is not the entry point.

I would prefer to remove this note altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Yes.. that's what I said isn't it?
  2. I said "the capability is always unsealed before invalid address conversion" which I think is true, no?

I think there's enough confusion about this that a note is warranted. Maybe you could come up with better wording?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Timmmm: How about something like this?

If cs1 is sealed, then it is only unsealed when the jump target address equals cs1's address, i.e. imm must be 0, otherwise a CHERI exception is raised. Also, CJALR checks that the target address is within cs1's bounds, so a representability check is not needed when performing invalid address conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll just remove this so we can get the important bit landed.

====

The capability is then installed in <<pcc>>. The <<pcc>> of the next instruction
following the jump (<<pcc>> + 4) is sealed and written to `cd`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please note that that this test is wrapped under the Synopsis:: header, but it is not currently indented properly because it is after the note and it is also missing the + at the end of the previous paragraph.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I'll fix.

of the next instruction following the jump (<<pcc>> + 4) is sealed and written
to `cd`.
performed. The check for length violation is done next using the converted
address and the original bounds.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this text is better placed as a note in the Exceptions:: section where the actual failure cases are highlighted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I'll move it.

arichardson pushed a commit to arichardson/riscv-cheri that referenced this pull request Jan 30, 2024
Clarify that length violations are checked on the address after it has undergone invalid address conversion.

Also fix a typo in the title.

Fixes riscv#9
@Timmmm Timmmm force-pushed the user/timh/clarify_cjalr branch from 1ae67d2 to 9c862a6 Compare January 31, 2024 08:55
@andresag01 andresag01 merged commit e9f968f into riscv:main Jan 31, 2024
3 checks passed
@Timmmm Timmmm deleted the user/timh/clarify_cjalr branch January 31, 2024 18:03
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.

Order of checks for CJALR & invalid address handling not specified
4 participants