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

Misaligned LC/SC is a fatal error #66

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

sorear
Copy link
Contributor

@sorear sorear commented Jan 26, 2024

Make it clear in the spec that this overrides Zicclsm and should not be emulated.

Resolves #59.

Copy link
Collaborator

@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.

Thanks, this looks good to me. Just two comments:

@@ -161,6 +161,15 @@ Capability load and store instructions also cause load or store/AMO address
misaligned exceptions if the address is not naturally aligned to a CLEN
boundary.

Misaligned capability loads and stores are fatal errors. Implementations must
Copy link
Collaborator

Choose a reason for hiding this comment

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

"fatal" might be a bit strong? To me that reads as "system is broken must reset CPU", maybe the second sentence is sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any preferences for how to describe this in a way that applies to both hardware implementations of the privileged architecture (where the second sentence is sufficient), and things more like qemu user where exceptions aren't meaningful and the environment generates SIGBUS instead?

The relevant terminology from the unprivileged specification §1.6 is "contained trap" (control transfer to a handler within the same conceptual scope, e.g. xtvec or an installed signal handler) or "fatal trap" (terminates execution), but there's a confusing amount of leakage from the privileged spec into that section.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it sufficient to say that implementations must "trap" for misaligned capability loads and stores etc? Trap is ideal because it is sufficiently high-level for the purposes of this section yet a definition is given in the RISC-V privileged spec.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fatal Trap
The trap represents a fatal failure and causes the execution environment to terminate execution.
Examples include failing a virtual-memory page-protection check or allowing a watchdog timer to
expire. Each EEI should define how execution is terminated and reported to an external
environment

This does seem appropriate but we haven't used the terms contained trap, fatal trap etc. anywhere in the doc. To start using those terms we'd need another section mapping the CHERI exceptions onto them.

src/riscv-integration.adoc Show resolved Hide resolved
@sorear sorear force-pushed the misaligned-lcsc-is-fatal branch from 845bb6d to 1ffbda1 Compare January 31, 2024 12:55
Copy link
Collaborator

@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.

Thanks for the clarifications. One typo and a suggested clarification otherwise ready to merge.

addresses are aligned.

NOTE: Since there is only one tag per CLEN bit block in memory, it is not
possible to represeent a capability value complete with its tag at an
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
possible to represeent a capability value complete with its tag at an
possible to represent a capability value complete with its tag at an


NOTE: Since there is only one tag per CLEN bit block in memory, it is not
possible to represeent a capability value complete with its tag at an
address not aligned to CLEN. To transfer CLEN bits without a tag, use
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
address not aligned to CLEN. To transfer CLEN bits without a tag, use
address not aligned to CLEN. To transfer unaligned CLEN bits without a tag, use

Maybe add this qualification here since capability loads without C permission can be used to transfer without the tag.

Make it clear in the spec that this overrides Zicclsm and should not
be emulated.

Resolves riscv#59.
@sorear sorear force-pushed the misaligned-lcsc-is-fatal branch from 1ffbda1 to ee6a5fb Compare January 31, 2024 21:29
Copy link
Collaborator

@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.

Will give others a day to comment on this and if there are no further comments I'll merge it tomorrow.

@andresag01 andresag01 merged commit 296c904 into riscv:main Feb 2, 2024
3 checks passed
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.

Exception policy for misaligned LC/SC is odd
4 participants