[PAL/Linux-SGX] AEX-Notify 4/5: Do not clobber RBX reg in stage-1 signal handler#2036
Open
dimakuv wants to merge 1 commit intodimakuv/aex-notify-part3from
Open
[PAL/Linux-SGX] AEX-Notify 4/5: Do not clobber RBX reg in stage-1 signal handler#2036dimakuv wants to merge 1 commit intodimakuv/aex-notify-part3from
dimakuv wants to merge 1 commit intodimakuv/aex-notify-part3from
Conversation
If the enclave is entered with CSSA=1, then the enclave starts executing the stage-1 signal handler asssembly code. This assembly code prepares the context for the stage-2 signal handler, which will be executed in regular context with CSSA=0 and using C code. This stage-1 signal handler uses the RBX register as a base pointer to the SSA[0].GPRSGX region. Closer to the end of the stage-1 handler flow, in particular before the `.Lcssa1_exception_eexit` label, this SSA[0] base pointer is not needed anymore, so the RBX register is used for other purposes. In particular, RBX is used to hold the stashed RDX value (where-to-exit address in untrusted runtime). However, a future commit that will introduce AEX-Notify flows inside the enclave needs to access the SSA[0].GPRSGX region at this stage (in the `.Lcssa1_exception_eexit` label). So the RBX register must not be overwritten. Thus, this preparatory commit does not clobber RBX, but instead stashes RDX into another unused register, R10. Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
1f34f81 to
ec264ec
Compare
45f12b3 to
6b3950c
Compare
dimakuv
commented
Oct 22, 2024
Author
dimakuv
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 18 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (1 more required), not enough approvals from different teams (1 more required, approved so far: Intel)
a discussion (no related file):
Must be applied on top of #2034. Blocking.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the changes
Part 4 in AEX-Notify series.
If the enclave is entered with CSSA=1, then the enclave starts executing the stage-1 signal handler asssembly code. This assembly code prepares the context for the stage-2 signal handler, which will be executed in regular context with CSSA=0 and using C code.
This stage-1 signal handler uses the RBX register as a base pointer to the SSA[0].GPRSGX region. Closer to the end of the stage-1 handler flow, in particular before the
.Lcssa1_exception_eexitlabel, this SSA[0] base pointer is not needed anymore, so the RBX register is used for other purposes. In particular, RBX is used to hold the stashed RDX value (where-to-exit address in untrusted runtime).However, a future commit that will introduce AEX-Notify flows inside the enclave needs to access the SSA[0].GPRSGX region at this stage (in the
.Lcssa1_exception_eexitlabel). So the RBX register must not be overwritten. Thus, this preparatory commit does not clobber RBX, but instead stashes RDX into another unused register, R10.See also related PRs and discussions:
How to test this PR?
CI is enough.
This change is