From 0eb7886e750b6146e0e8a0b32e7d7564b54d624c Mon Sep 17 00:00:00 2001 From: Qiao Pengcheng Date: Mon, 6 May 2024 12:22:41 +0800 Subject: [PATCH] [LoongArch64] Fix nonvolatile context restoration referenced 101709. --- src/coreclr/pal/src/arch/loongarch64/asmconstants.h | 4 ++-- src/coreclr/pal/src/arch/loongarch64/context2.S | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/coreclr/pal/src/arch/loongarch64/asmconstants.h b/src/coreclr/pal/src/arch/loongarch64/asmconstants.h index 57cf8b585ca38..3676b16fcc67e 100644 --- a/src/coreclr/pal/src/arch/loongarch64/asmconstants.h +++ b/src/coreclr/pal/src/arch/loongarch64/asmconstants.h @@ -45,8 +45,8 @@ #define CONTEXT_T6 CONTEXT_T5+SIZEOF_LOONGARCH_GPR #define CONTEXT_T7 CONTEXT_T6+SIZEOF_LOONGARCH_GPR #define CONTEXT_T8 CONTEXT_T7+SIZEOF_LOONGARCH_GPR -#define CONTEXT_X0 CONTEXT_T8+SIZEOF_LOONGARCH_GPR -#define CONTEXT_Fp CONTEXT_X0+SIZEOF_LOONGARCH_GPR +#define CONTEXT_R21 CONTEXT_T8+SIZEOF_LOONGARCH_GPR +#define CONTEXT_Fp CONTEXT_R21+SIZEOF_LOONGARCH_GPR #define CONTEXT_S0 CONTEXT_Fp+SIZEOF_LOONGARCH_GPR #define CONTEXT_S1 CONTEXT_S0+SIZEOF_LOONGARCH_GPR #define CONTEXT_S2 CONTEXT_S1+SIZEOF_LOONGARCH_GPR diff --git a/src/coreclr/pal/src/arch/loongarch64/context2.S b/src/coreclr/pal/src/arch/loongarch64/context2.S index b337edb250e2d..dda4f1922feb6 100644 --- a/src/coreclr/pal/src/arch/loongarch64/context2.S +++ b/src/coreclr/pal/src/arch/loongarch64/context2.S @@ -132,13 +132,14 @@ LOCAL_LABEL(No_Restore_CONTEXT_INTEGER): ld.d $ra, $t4, CONTEXT_Ra ld.d $fp, $t4, CONTEXT_Fp - ld.d $sp, $t4, CONTEXT_Sp ld.d $r21, $t4, CONTEXT_Pc - ld.d $t4, $t4, CONTEXT_T4 + ld.d $sp, $t4, CONTEXT_Sp + // NOTE: the r21 and t4 had been trashed. jirl $r0, $r21, 0 LOCAL_LABEL(No_Restore_CONTEXT_CONTROL): + ld.d $r21, $t4, CONTEXT_R21 ld.d $t4, $t4, CONTEXT_T4 jirl $r0, $ra, 0 LEAF_END RtlRestoreContext, _TEXT @@ -202,7 +203,7 @@ LOCAL_LABEL(Done_CONTEXT_CONTROL): st.d $t6, $a0, CONTEXT_T6 st.d $t7, $a0, CONTEXT_T7 st.d $t8, $a0, CONTEXT_T8 - st.d $r21,$a0, CONTEXT_X0 + st.d $r21,$a0, CONTEXT_R21 st.d $s0, $a0, CONTEXT_S0 st.d $s1, $a0, CONTEXT_S1 st.d $s2, $a0, CONTEXT_S2