Skip to content

Commit

Permalink
s390x: Fix nonvolatile context restoration
Browse files Browse the repository at this point in the history
Fix s390x context restoration along the lines of
dotnet#101709
  • Loading branch information
uweigand committed May 3, 2024
1 parent 7ac5ef9 commit 40b6428
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/coreclr/pal/src/arch/s390x/context2.S
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ LEAF_END RtlCaptureContext, _TEXT

LEAF_ENTRY RtlRestoreContext, _TEXT

// Set %r1 and %r0 to hold the target return address and stack pointer.
// These will be installed only at the very end, to avoid potentially
// clobbering the context structure on the local stack.
lgr %r1, %r14
lgr %r0, %r15
tm CONTEXT_ContextFlags+3(%r2), CONTEXT_CONTROL
je LOCAL_LABEL(Done_Restore_CONTEXT_CONTROL)
// We do *not* attempt to restore the PSW mask here!
lg %r1, CONTEXT_PSWAddr(%r2)
lg %r0, CONTEXT_R15(%r2)
LOCAL_LABEL(Done_Restore_CONTEXT_CONTROL):

tm CONTEXT_ContextFlags+3(%r2), CONTEXT_FLOATING_POINT
je LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT)
Expand All @@ -83,19 +93,13 @@ LEAF_ENTRY RtlRestoreContext, _TEXT
ld %f15, CONTEXT_F15(%r2)
LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT):

tm CONTEXT_ContextFlags+3(%r2), CONTEXT_CONTROL
je LOCAL_LABEL(Done_Restore_CONTEXT_CONTROL)
// We do *not* attempt to restore the PSW mask here!
lg %r1, CONTEXT_PSWAddr(%r2)
lg %r15, CONTEXT_R15(%r2)
LOCAL_LABEL(Done_Restore_CONTEXT_CONTROL):

tm CONTEXT_ContextFlags+3(%r2), CONTEXT_INTEGER
je LOCAL_LABEL(Done_Restore_CONTEXT_INTEGER)
// We do *not* restore %r0 and %r1 here!
lmg %r2, %r14, CONTEXT_R2(%r2)
LOCAL_LABEL(Done_Restore_CONTEXT_INTEGER):

lgr %r15, %r0
br %r1
LEAF_END RtlRestoreContext, _TEXT

0 comments on commit 40b6428

Please sign in to comment.