mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
Add option to build without (read/write)(fs/gs)base instructions (#111)
Some checks failed
Formatting check / formatting-check (push) Has been cancelled
Build RPCSX / build-linux (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.1-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.2-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.4-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.5-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv9-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv9.1-a) (push) Has been cancelled
Build RPCSX / build-android (x86_64, x86-64) (push) Has been cancelled
Some checks failed
Formatting check / formatting-check (push) Has been cancelled
Build RPCSX / build-linux (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.1-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.2-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.4-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv8.5-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv9-a) (push) Has been cancelled
Build RPCSX / build-android (arm64-v8a, armv9.1-a) (push) Has been cancelled
Build RPCSX / build-android (x86_64, x86-64) (push) Has been cancelled
This commit is contained in:
parent
e514fa02ff
commit
00c55e9688
|
|
@ -141,6 +141,11 @@ option(WITHOUT_OPENGL "Disable OpenGL" OFF)
|
|||
option(WITHOUT_OPENGLEW "Disable OpenGLEW" OFF)
|
||||
option(WITHOUT_OPENAL "Disable OpenAL" OFF)
|
||||
option(COMPILE_FFMPEG "Compile FFmpeg" ON)
|
||||
option(USE_FS_GS_SYSCALL "Use the arch_prctl syscall to interact with fsbase and gsbase instead of x86 instructions. Used for compatibility with some systems, but comes at a performance cost." OFF)
|
||||
|
||||
if(USE_FS_GS_SYSCALL)
|
||||
add_definitions(-DUSE_FS_GS_SYSCALL)
|
||||
endif()
|
||||
|
||||
# rpcs3 options
|
||||
option(USE_NATIVE_INSTRUCTIONS "USE_NATIVE_INSTRUCTIONS makes rpcs3 compile with -march=native, which is useful for local builds, but not good for packages." ON)
|
||||
|
|
|
|||
|
|
@ -39,9 +39,16 @@ static auto setContext = [] {
|
|||
|
||||
static __attribute__((no_stack_protector)) void
|
||||
handleSigSys(int sig, siginfo_t *info, void *ucontext) {
|
||||
#ifndef USE_FS_GS_SYSCALL
|
||||
if (auto hostFs = _readgsbase_u64()) {
|
||||
_writefsbase_u64(hostFs);
|
||||
}
|
||||
#else
|
||||
uint64_t hostFs = 0;
|
||||
if (syscall(SYS_arch_prctl, ARCH_GET_GS, &hostFs) == 0 && hostFs) {
|
||||
syscall(SYS_arch_prctl, ARCH_SET_FS, hostFs);
|
||||
}
|
||||
#endif
|
||||
|
||||
// rx::printStackTrace(reinterpret_cast<ucontext_t *>(ucontext),
|
||||
// rx::thread::g_current, 1);
|
||||
|
|
@ -58,7 +65,11 @@ handleSigSys(int sig, siginfo_t *info, void *ucontext) {
|
|||
|
||||
thread = orbis::g_currentThread;
|
||||
thread->context = prevContext;
|
||||
#ifndef USE_FS_GS_SYSCALL
|
||||
_writefsbase_u64(thread->fsBase);
|
||||
#else
|
||||
syscall(SYS_arch_prctl, ARCH_SET_FS, thread->fsBase);
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((no_stack_protector)) static void
|
||||
|
|
@ -149,7 +160,11 @@ handleSigUser(int sig, siginfo_t *info, void *ucontext) {
|
|||
}
|
||||
|
||||
if (inGuestCode) {
|
||||
#ifndef USE_FS_GS_SYSCALL
|
||||
_writefsbase_u64(thread->fsBase);
|
||||
#else
|
||||
syscall(SYS_arch_prctl, ARCH_SET_FS, thread->fsBase);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -389,6 +404,7 @@ void rx::thread::setupThisThread() {
|
|||
void rx::thread::invoke(orbis::Thread *thread) {
|
||||
orbis::g_currentThread = thread;
|
||||
|
||||
#ifndef USE_FS_GS_SYSCALL
|
||||
std::uint64_t hostFs = _readfsbase_u64();
|
||||
_writegsbase_u64(hostFs);
|
||||
|
||||
|
|
@ -397,4 +413,15 @@ void rx::thread::invoke(orbis::Thread *thread) {
|
|||
|
||||
::setContext(context->uc_mcontext);
|
||||
_writefsbase_u64(hostFs);
|
||||
#else
|
||||
std::uint64_t hostFs;
|
||||
syscall(SYS_arch_prctl, ARCH_GET_FS, &hostFs);
|
||||
syscall(SYS_arch_prctl, ARCH_SET_GS, hostFs);
|
||||
|
||||
syscall(SYS_arch_prctl, ARCH_SET_FS, thread->fsBase);
|
||||
auto context = reinterpret_cast<ucontext_t *>(thread->context);
|
||||
|
||||
::setContext(context->uc_mcontext);
|
||||
syscall(SYS_arch_prctl, ARCH_SET_FS, hostFs);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue