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

Changes continue_execution to not clobber stack that may be in use. #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions sdk/trts/linux/trts_pic.S
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ DECLARE_LOCAL_FUNC continue_execution
mov SE_WORDSIZE*1(%xcx), %xax
push %xax # push xcx
mov SE_WORDSIZE*4(%xcx), %xax
sub $(SE_WORDSIZE), %xax # xax: xsp

# restore registers except xax, xcx, xsp
mov SE_WORDSIZE*2(%xcx), %xdx
Expand Down Expand Up @@ -585,8 +584,14 @@ DECLARE_LOCAL_FUNC continue_execution

# do not setup the new stack until info is not needed any more
# otherwise, info will be overwritten
mov %xcx, (%xax) # save xip to the new stack
# Offset the stack to avoid the red zone, which interrupts are allowed to
# write into. Using the __attribute__((interrupt)) on internal_handle_exception
# is hostile to older compilers.
mov %xcx, -128(%xax) # save xip to the new stack
Copy link
Contributor

Choose a reason for hiding this comment

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

The patch doesn't really avoid the red zone, right? From this line, it saves the xip at the bottom of the red zone but it is still inside the red zone.

pop %xcx # restore xcx
pop %xsp # xsp: xax
xchg %xax, %xsp
ret

# The desired xip was stashed further up in the stack; retrieve it and jump
# there to resume execution.
jmp *-128(%xsp)