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

Weaken backwards-arc sentry pseudo-locality #79

Closed
nwf opened this issue Oct 25, 2024 · 6 comments
Closed

Weaken backwards-arc sentry pseudo-locality #79

nwf opened this issue Oct 25, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@nwf
Copy link
Member

nwf commented Oct 25, 2024

#64 added a "pseudo-locality" flavor of return sentry capabilities: storing these always requires SL authority, even if the sentry object itself is G-lobal (which it should be, so that after return, things derived from auipcc are global). (See also discussion on #63)

This is all well and good, but it means that we can't easily let compartments running under the RTOS pivot onto heap-allocated stacks. While such a pivoted thread couldn't make cross-compartment calls and would have to be careful about local parameters, it would be very convenient for adapting existing code that uses large on-stack buffers (e.g., TLS), and it wouldn't require us to allocate large stacks for threads that incidentally call into such code.

@davidchisnall's suggestion is to weaken the requirement on stores such that storing a backwards-arc sentry requires SL of its authority (whatever that authority might be) if the capability in csp is SL-bearing. I'll write this up in Sail for review and @kliuMsft can tell us how we're ruining timing of the pipeline. :)

@nwf nwf added the enhancement New feature or request label Oct 25, 2024
@kliuMsft
Copy link
Contributor

kliuMsft commented Oct 25, 2024

I think from microarchitecture point of view, using CSP makes it tougher compared to using a CSR. Reason being that there is only one way (via CSRRW) to change a "normal" CSR, and it is easier for it to take effect immediately after execution. Meanwhile, CSP can be updated in a number of different ways (R2R instructions, load from memory) so it is tricker to get it right. We might be able to simplify things a little w/ flush instructions, but I am not super sure how it works beyond just cheriot-ibex.

@nwf
Copy link
Member Author

nwf commented Oct 25, 2024

(Another argument in favor of having made SP architectural and not an ordinary GPR. Which, having not done in the base ISA, RISC-V then almost did with the compressed instruction encodings... grumble.)

@nwf
Copy link
Member Author

nwf commented Oct 25, 2024

@davidchisnall was asking in the meeting, I think (forgive me if I've gotten this wrong), if it's possible to avoid some of the pipeline forwarding complexity by making csc %0, k(%1) instructions for which register %0 is holding a backward-arc sentry and %1 is not 2 (csp) take another cycle to read from the register file.

That's the case that matters, since when %1 is 2, the check is tautological:

  • if csp bears SL, then we require SL when storing backward sentries, but oh look, the authority in csp has it, and
  • if csp does not, then we don't require it, and the fact that the authority lacks it is boring.

In practice, almost all spills of return addresses will use csp as their authority (and this is also likely true of the switcher already, and where it isn't we can make it).

@nwf
Copy link
Member Author

nwf commented Oct 25, 2024

I think, musing aloud, that it's fine if this effect of transitioning csp is potentially not guaranteed to be felt until the next mret or cjalr instruction. There is a mret as part of context switch, a cjalr as part of cross-compartment call, and surely a cjalr as part of the stack pivot dance.

nwf added a commit that referenced this issue Oct 25, 2024
This is one approach to fixing
#79
@kliuMsft
Copy link
Contributor

@nwf if we can indeed defer the effect till mret/cjalr it would help (since those instructions flush the pipeline anyway).

Another thought - is it possible to make an architecturally visible mode bits rather than referring to CSP? I guess it's similar to making a CSR..

@nwf
Copy link
Member Author

nwf commented Nov 14, 2024

For now, just rip pseudolocality out. See #82. We can revisit this later.

@nwf nwf closed this as completed Nov 14, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in ISA Version 1.0 release Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done (Sail)
Development

No branches or pull requests

2 participants