Skip to content

Commit

Permalink
sysdeps/managarm: Implement sys_tcb_set() on RISC-V
Browse files Browse the repository at this point in the history
  • Loading branch information
avdgrinten committed Nov 27, 2024
1 parent 3033fb7 commit 2ae7477
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sysdeps/managarm/rtld-generic/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,17 @@ HelHandleResult *parseHandle(void *&element) {
namespace mlibc {

int sys_tcb_set(void *pointer) {
#if defined(__aarch64__)
#if defined(__x86_64__)
HEL_CHECK(helWriteFsBase(pointer));
#elif defined(__aarch64__)
uintptr_t addr = reinterpret_cast<uintptr_t>(pointer);
addr += sizeof(Tcb) - 0x10;
asm volatile ("msr tpidr_el0, %0" :: "r"(addr));
#elif defined(__riscv) && __riscv_xlen == 64
uintptr_t tp = reinterpret_cast<uintptr_t>(pointer) + sizeof(Tcb);
asm volatile ("mv tp, %0" : : "r"(tp) : "memory");
#else
HEL_CHECK(helWriteFsBase(pointer));
#error Unknown architecture
#endif
return 0;
}
Expand Down

0 comments on commit 2ae7477

Please sign in to comment.