[rpcsx-os] fork: implement vm and vfs fork

stub metadbg device
implement notification device
implement sys_pipe
This commit is contained in:
DH 2023-10-31 21:28:40 +03:00
parent 39092c7f16
commit 525ef02e8a
22 changed files with 379 additions and 76 deletions

View file

@ -1,13 +1,12 @@
#include "thread.hpp"
#include "backtrace.hpp"
#include "orbis/sys/sysentry.hpp"
#include "orbis/thread/Process.hpp"
#include "orbis/thread/Thread.hpp"
#include <asm/prctl.h>
#include <csignal>
#include <immintrin.h>
#include <link.h>
#include <linux/prctl.h>
#include <string>
#include <sys/prctl.h>
#include <ucontext.h>
#include <unistd.h>
@ -33,8 +32,6 @@ static auto setContext = [] {
return setContextStorage.getCode<void (*)(const mcontext_t &)>();
}();
void setupSigHandlers();
static __attribute__((no_stack_protector)) void
handleSigSys(int sig, siginfo_t *info, void *ucontext) {
if (auto hostFs = _readgsbase_u64()) {
@ -46,19 +43,7 @@ handleSigSys(int sig, siginfo_t *info, void *ucontext) {
auto thread = orbis::g_currentThread;
auto prevContext = std::exchange(thread->context, ucontext);
orbis::syscall_entry(thread);
if (thread != orbis::g_currentThread) {
thread = orbis::g_currentThread;
setupSigHandlers();
rx::thread::initialize();
if (prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_ON,
(void *)0x100'0000'0000, ~0ull - 0x100'0000'0000, nullptr)) {
perror("prctl failed\n");
exit(-1);
}
}
thread = orbis::g_currentThread;
thread->context = prevContext;
_writefsbase_u64(thread->fsBase);
}