-
Notifications
You must be signed in to change notification settings - Fork 9
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
Proposed relaxing of cjalr sealing #86
Open
nwf
wants to merge
1
commit into
main
Choose a base branch
from
202411-relax_cjalr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -458,11 +458,11 @@ \subsection{Sealed capabilities} | |||||
The \cotype{} field uses the following values: | ||||||
\begin{description} | ||||||
\item[0] unsealed | ||||||
\item[1] sealed as sentry | ||||||
\item[2] sealed as interrupt disabling sentry | ||||||
\item[3] sealed as interrupt enabling sentry | ||||||
\item[4] sealed as backward interrupt disabling sentry | ||||||
\item[5] sealed as backward interrupt enabling sentry | ||||||
\item[1] sealed as interrupt inheriting forward sentry | ||||||
\item[2] sealed as interrupt disabling forward sentry | ||||||
\item[3] sealed as interrupt enabling forward sentry | ||||||
\item[4] sealed as interrupt disabling backward sentry | ||||||
\item[5] sealed as interrupt enabling backward sentry | ||||||
\item[6-7] executable capability sealed with given \cotype{} | ||||||
\item[8] reserved (due to encoding) | ||||||
\item[9-15] non-executable capability sealed with given \cotype{} | ||||||
|
@@ -477,16 +477,40 @@ \subsection{Sealed capabilities} | |||||
\footnotesize | ||||||
\begin{tabular}{|c|c|c|c|} | ||||||
\hline | ||||||
\asm{cs1} & \asm{cd} & Used for & Valid \cotype{}s \\ | ||||||
\asm{cs1} & \asm{cd} (out \cotype{}s) & Used for & Valid \asm{cs1} \cotype{}s \\ | ||||||
\hline | ||||||
\asm{\$cra} & \asm{\$cnull} & Function return & Return sentries $(4, 5)$\\ | ||||||
$\ne$ \asm{\$cra} & \asm{\$cnull} & Tail call & Unsealed or interrupt inheriting forward sentry $(0, 1)$\\ | ||||||
any & $\not\in \{ \text{\asm{\$cnull}}, \text{\asm{\$cra}} \}$ & Function call & Unsealed or interrupt inheriting forward sentry $(0, 1)$\\ | ||||||
any & \asm{\$cra} & Function call & Unsealed or forward sentries $(0, 1, 2, 3)$\\ | ||||||
\asm{\$cra} & \asm{\$cnull} (n/a) & Function return & Backward sentries $(4, 5)$\\ | ||||||
$\ne$ \asm{\$cra} & \asm{\$cnull} (n/a) & Tail call & Unsealed or IRQ inheriting forward sentry $(0, 1)$\\ | ||||||
any & $\not\in \{ \text{\asm{\$cnull}}, \text{\asm{\$cra}} \}$ (0) & Code outlining & Unsealed or IRQ inheriting forward sentry $(0, 1)$\\ | ||||||
any & \asm{\$cra} (4,5) & Function call & Unsealed or forward sentries $(0, 1, 2, 3)$\\ | ||||||
\hline | ||||||
\end{tabular} | ||||||
\end{center} | ||||||
|
||||||
Thus, ordinary function calls, for which the calling convention is to use \asm{\$cra} as the return register, | ||||||
can call any unsealed (executable) capability or forward sentry, | ||||||
and will always create backward sentries, suitable for the function return case. | ||||||
Tail calls, which must preserve \asm{\$cra} for their callee and do not generate return capabilities of their own, | ||||||
are also permitted. | ||||||
Last, code \emph{outlining}, the dual of code \emph{inlining}, is supported; | ||||||
outlined code may use a specialized calling convention, not using \asm{\$cra} to exit | ||||||
(so return from such outlined code looks like a ``tail call'' in the above table), | ||||||
especially in cases where the outlined code must preserve \asm{\$cra} for its caller. | ||||||
In this case, the \insnriscvref{CJALR} used to enter the outlined code | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
will have a \asm{cd} that is neither \asm{\$cnull} nor \asm{\$cra}, | ||||||
and so will create \emph{unsealed} return capabilities, | ||||||
so that all forward sentries in the system must have been built by the RTOS loader. | ||||||
(Outlined code that \emph{does} use \asm{\$cra} as its return address will also function correctly, | ||||||
as if it were an ordinary function call and return.) | ||||||
|
||||||
Given the overloading of the single \insnriscvref{CJALR} instruction, | ||||||
with register selector operands selecting between multiple semantics, | ||||||
compilers \emph{must} be careful to use matching entry and exit \insnriscvref{CJALR}s. | ||||||
For example, entering a function with a \asm{\$cra} link register, | ||||||
transfering the contents of \asm{\$cra} to another register, | ||||||
and then ``tail calling'' through that latter register will not work on CHERIoT, | ||||||
even though analogous code would have worked on base RISC-V. | ||||||
|
||||||
\subsection{Capability bounds} | ||||||
\label{sec:bounds} | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be clearer to have another column for the output otype or maybe even a separate (smaller) table? We should make clear that the same behaviour applies to
cjal
.