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

[PAL/Linux-SGX] AEX-Notify 4/5: Do not clobber RBX reg in stage-1 signal handler #2036

Open
wants to merge 1 commit into
base: dimakuv/aex-notify-part3
Choose a base branch
from

Conversation

dimakuv
Copy link

@dimakuv dimakuv commented Oct 16, 2024

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

See also related PRs and discussions:

How to test this PR?

CI is enough.


This change is Reviewable

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]>
@dimakuv dimakuv force-pushed the dimakuv/aex-notify-part3 branch from 1f34f81 to ec264ec Compare October 22, 2024 07:30
@dimakuv dimakuv changed the title [PAL/Linux-SGX] Do not clobber RBX reg in stage-1 signal handler [PAL/Linux-SGX] AEX-Notify 4/5: Do not clobber RBX reg in stage-1 signal handler Oct 22, 2024
@dimakuv dimakuv force-pushed the dimakuv/aex-notify-part4 branch from 45f12b3 to 6b3950c Compare October 22, 2024 07:38
Copy link
Author

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

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.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Working on it
Development

Successfully merging this pull request may close these issues.

1 participant