mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
Replace direct usage of wrgsbase and rdgsbase with a more portable solution (#3464)
This commit is contained in:
@@ -18,6 +18,10 @@
|
|||||||
#elif !defined(ARCH_X86_64)
|
#elif !defined(ARCH_X86_64)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__linux__) && defined(ARCH_X86_64)
|
||||||
|
#include <asm/prctl.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
@@ -156,13 +160,15 @@ Tcb* GetTcbBase() {
|
|||||||
// Other POSIX x86_64
|
// Other POSIX x86_64
|
||||||
|
|
||||||
void SetTcbBase(void* image_address) {
|
void SetTcbBase(void* image_address) {
|
||||||
asm volatile("wrgsbase %0" ::"r"(image_address) : "memory");
|
const int ret = syscall(SYS_arch_prctl, ARCH_SET_GS, (unsigned long)image_address);
|
||||||
|
ASSERT_MSG(ret == 0, "Failed to set GS base: errno {}", errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tcb* GetTcbBase() {
|
Tcb* GetTcbBase() {
|
||||||
Tcb* tcb;
|
void* tcb = nullptr;
|
||||||
asm volatile("rdgsbase %0" : "=r"(tcb)::"memory");
|
const int ret = syscall(SYS_arch_prctl, ARCH_GET_GS, &tcb);
|
||||||
return tcb;
|
ASSERT_MSG(ret == 0, "Failed to get GS base: errno {}", errno);
|
||||||
|
return static_cast<Tcb*>(tcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user