Index: lib/libc/riscv/gen/_set_tp.c =================================================================== --- lib/libc/riscv/gen/_set_tp.c +++ lib/libc/riscv/gen/_set_tp.c @@ -38,13 +38,14 @@ #include #include -#include - #include +/* NB: size of 'struct tcb'. */ +#define TP_OFFSET (sizeof(void *) * 2) + void _set_tp(void *tp) { - __asm __volatile("mv tp, %0" :: "r"((char*)tp + 0x10)); + __asm __volatile("addi tp, %0, %1" :: "r" (tp), "I" (TP_OFFSET)); }