Skip to content

Commit ead0d10

Browse files
authored
[RISC-V] Fix context restoration as #101709 describes (#101865)
* [RISCV-V] Fix context restoration as 101709 * Feedback
1 parent 98e7570 commit ead0d10

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/coreclr/pal/src/arch/riscv64/context2.S

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ LOCAL_LABEL(No_Restore_CONTEXT_INTEGER):
105105
beqz t1, LOCAL_LABEL(No_Restore_CONTEXT_CONTROL)
106106

107107
ld ra, (CONTEXT_Ra)(t4)
108+
ld t1, (CONTEXT_T4)(t4)
109+
ld fp, (CONTEXT_Sp)(t4)
110+
sd t1, -8(fp)
108111
ld fp, (CONTEXT_Fp)(t4)
109-
ld sp, (CONTEXT_Sp)(t4)
110112
ld t1, (CONTEXT_Pc)(t4) // Since we cannot control $pc directly, we're going to corrupt t1
111-
ld t4, (CONTEXT_T4)(t4)
113+
ld t4, (CONTEXT_Sp)(t4)
114+
addi sp, t4, -8
115+
ld t4, (sp)
116+
addi sp, sp, 8
112117
jr t1
113118

114119
LOCAL_LABEL(No_Restore_CONTEXT_CONTROL):

0 commit comments

Comments
 (0)