diff --git a/core/lib/instrument.c b/core/lib/instrument.c index 20bcd8680f4..3b15055ff18 100644 --- a/core/lib/instrument.c +++ b/core/lib/instrument.c @@ -6516,8 +6516,10 @@ dr_get_mcontext_priv(dcontext_t *dcontext, dr_mcontext_t *dmc, priv_mcontext_t * } else { set_stolen_reg_val(dr_mcontext_as_priv_mcontext(dmc), (reg_t)d_r_get_tls(os_tls_offset(TLS_REG_STOLEN_SLOT))); +# ifdef RISCV64 set_tp_reg_val(dr_mcontext_as_priv_mcontext(dmc), (reg_t)os_get_app_tls_base(dcontext, TLS_REG_LIB)); +# endif } } #endif @@ -6594,7 +6596,9 @@ dr_set_mcontext(void *drcontext, dr_mcontext_t *context) if (TEST(DR_MC_INTEGER, context->flags)) { /* restore the reg val on the stack clobbered by the copy above */ set_stolen_reg_val(state, stolen_reg_val); +# ifdef RISCV64 set_tp_reg_val(state, tp_reg_val); +# endif } #endif diff --git a/core/unix/os.c b/core/unix/os.c index 0f6eeac1484..9bab5ad74b1 100644 --- a/core/unix/os.c +++ b/core/unix/os.c @@ -1783,7 +1783,7 @@ os_timeout(int time_in_milliseconds) __asm__ __volatile__("ld %0, %1(tp) \n\t" \ "add %0, %0, %2 \n\t" \ "ld %0, 0(%0) \n\t" \ - : "+r"(var) \ + : "+r"(var) \ : "i"(DR_TLS_BASE_OFFSET), "r"(offs)); \ } while (0) #endif /* X86/ARM/RISCV64 */