-
Notifications
You must be signed in to change notification settings - Fork 24
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
No GCMODE #302
Comments
it would be cheap to add it back in |
Reading the current mode can be done by executing something like |
but so y=1 for cap mode, y=0 for int mode Is that good enough? |
I think that's what @arichardson meant, but the point is there's no easy way to know what the mode bit is for a cap that isn't in PCC, i.e. what the mode will be when you jump to it. I guess there's a question about how common that would be? |
|
In debug mode though AUIPC may not be valid - as PC relative instructions may be illegal. |
GCMODE will also be needed for instruction emulation trap handlers. |
How exactly? Can you give more details @jrtc27 ? |
You need to know the mode for xEPCC to know how to decode the instruction and figure out what to do. |
I guess you can do that by reading But if |
@tariqkurd-repo I think you can't do that even with |
I'm not talking about debug mode at all. |
Good point, so it doesn't solve that problem.
…On Wed, 3 Jul 2024, 17:40 PRugg-Cap, ***@***.***> wrote:
@tariqkurd-repo <https://github.com/tariqkurd-repo> I think you can't do
that even *with* GCMODE, unless you mean for GCMODE to get the *current*
mode of PCC, rather than the mode of a capability in a register?
—
Reply to this email directly, view it on GitHub
<#302 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOCTJABDGPUDS4BJACDKSC3ZKQSORAVCNFSM6AAAAABKFSKBR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBWG43TAMRXGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
(I'm talking about firmware, hypervisors or kernels needing to know what mode the software running on top of it is in, whether because it affects the SBI interface, or because it needs to decode the instruction that xEPCC refers to) |
@jrtc27 : This is a good use-case. An instruction that simply gets the mode of an arbitrary capability in a register is helpful for this. However, please note that it will not tell you the effective CHERI execution mode because that is a combination of CSRs and the PCC M-bit that the process was using at the time. Given that we provide such an instruction, is it reasonable to still expect software (e.g. Hypervisors, firmware, kernels, etc) to also look at the CSR state and work out the effective mode? This will probably take quite a few instructions (haven't worked it out yet!) |
Yes, and there's no good way to avoid that given the effective encoding mode also requires knowing what privilege mode you came from, so that would need to be an input to a hypothetical all-powerful instruction. The alternative would be to make it illegal to have M=0 whilst CHERI is disabled (though not as an illegal instruction exception, since you'd still need to disambiguate the cause there :)). |
There could be an instruction that tells you the "effective" CHERI mode given the cap in xEPCC and other relevant CSRs for example although that sounds hard (and fiddly!) to implement in hardware... Do you know in which cases the hypervisor, kernel, etc needs to know the effective CHERI mode of the other process? It would be great to have a concrete example use-case; perhaps there is something else we can do to improve this (if needed!). |
The two that immediately come to mind are:
Whilst the uncompressed instructions likely don't need to know the encoding mode, the compressed ones do due to repurposing encoding space. |
Uncompressed instructions do need to know though don't they? If you're emulating misaligned you need to know if the auth cap is DDC or cs1 The handler can always read CRE for the lower privilege level which it is emulating can't it? And use that when deciding how to decode. |
and none of this solves this problem:
which is not true in debug mode, so I should remove this from the spec. |
Jamie is suggesting that |
I mean it wouldn’t be GCMODE rd, c0 because that would mean precisely that. What you’re proposing is to make GCMODE’s cs1 have a constraint that it’s not c0 and use that spare encoding as GCMODE rd, pcc. That would be quite the exception to the proposed extension. |
yes - |
I mean, there should be a way to read the mode without requiring a program buffer anyway, which may also solve that for you depending on how that’s done. |
an alternative for debug mode would be to use one of the lower 64-bits of the |
This can work as follows:
similarly for getting it from the PC, when I'll make a PR - and also note that the M-bit is not directly observable in |
@tariqkurd-repo @jrtc27 : Did this discussion reach a conclusion? Do we need a new get-tag instruction or something else? |
Only for performance, not for functionality
…On Mon, 8 Jul 2024, 13:55 Andres Amaya Garcia, ***@***.***> wrote:
@tariqkurd-repo <https://github.com/tariqkurd-repo> @jrtc27
<https://github.com/jrtc27> : Did this discussion reach a conclusion? Do
we need a new get-tag instruction or something else?
—
Reply to this email directly, view it on GitHub
<#302 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOCTJAH3ML3HEU6LMIWBSQLZLJ427AVCNFSM6AAAAABKFSKBR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJTHAYTAMJUGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
We can have the compiler lower __builtin_cheri_mode_get() to the appropriate checks+bitslicing, |
See #302 This does not add a new instruction to read the mode from arbitrary capabilities but does add a suggested sequence to observe the effective mode of the current PCC. Co-authored-by: Andrés Amaya Garcia <andres.amaya@codasip.com>
We have SCMODE but no way to extract it back out. For RV64 one could slice it out of the high bits, but this gets rather ugly on RV32.
The text was updated successfully, but these errors were encountered: