From 93ada89708f43c478e2eaee0738ecf8b0c68047c Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 27 Feb 2024 02:36:41 -0800 Subject: [PATCH 1/2] Linux: Move unimplement ustat and sysfs AArch64 doesn't implement these and will return ENOSYS. Moving them to NotImplemented so we can get a log if an application tries to use these. --- .../LinuxSyscalls/Syscalls/FS.cpp | 19 ------------------- .../LinuxSyscalls/Syscalls/NotImplemented.cpp | 2 ++ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp index dba921aa28..b460848a94 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp @@ -103,25 +103,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(ustat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, dev_t dev, struct ustat *ubuf) -> uint64_t { - // Doesn't exist on AArch64, will return -ENOSYS - // Since version 2.28 of GLIBC it has stopped providing a wrapper for this syscall - uint64_t Result = syscall(SYSCALL_DEF(ustat), dev, ubuf); - SYSCALL_ERRNO(); - }); - - /* - arg1 is one of: void, unsigned int fs_index, const char *fsname - arg2 is one of: void, char *buf - */ - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sysfs, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int option, uint64_t arg1, uint64_t arg2) -> uint64_t { - // Doesn't exist on AArch64, will return -ENOSYS - uint64_t Result = syscall(SYSCALL_DEF(sysfs), option, arg1, arg2); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(truncate, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, off_t length) -> uint64_t { uint64_t Result = ::truncate(path, length); diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/NotImplemented.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/NotImplemented.cpp index 311403ce6c..a808ed4e78 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/NotImplemented.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/NotImplemented.cpp @@ -30,6 +30,8 @@ namespace FEX::HLE { // these are removed/not implemented in the linux kernel we present void RegisterNotImplemented(FEX::HLE::SyscallHandler *Handler) { + REGISTER_SYSCALL_NOT_IMPL(ustat); + REGISTER_SYSCALL_NOT_IMPL(sysfs); REGISTER_SYSCALL_NOT_IMPL(uselib); REGISTER_SYSCALL_NOT_IMPL(create_module); REGISTER_SYSCALL_NOT_IMPL(get_kernel_syms); From 151e2279af5e2a0ae0f824043378a15529d345c9 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 24 Feb 2024 02:55:02 -0800 Subject: [PATCH 2/2] Linux: Converts passthrough syscalls to direct passthrough handlers Reimagining of #3355 without any json generators or new concepts. Fixes some mislabeling of system calls. Some getting inlined when they shouldn't be, a lot not getting inlined when they can be. This really cleans up the syscall implementation, all syscalls that can be passthrough implementations require a very small two line declaration. Additionally cleans up a bit of implementation cruft where some passthrough syscalls were using the glibc syscall handler, and some were using the glibc implementation. We have had multiple issues in the past where the glibc implementation does something subtly different than the raw syscall and breaks things. Now all passthrough handlers do a system call directly, removing at least one indirection and some ambiguity. This makes it significantly easier to add new passthrough syscalls as well. Only need to do a version check and add the three lines per syscall. Which there are new syscalls incoming that we will want to add. Tangible improvements: - Syscalls are lower overhead than ever. - When I'm adding more syscalls I have less chance of mucking it up. --- Source/Tools/LinuxEmulation/CMakeLists.txt | 15 +- .../LinuxEmulation/LinuxSyscalls/Syscalls.h | 12 - .../LinuxSyscalls/Syscalls/EPoll.cpp | 8 +- .../LinuxSyscalls/Syscalls/FD.cpp | 288 +----- .../LinuxSyscalls/Syscalls/FS.cpp | 147 +-- .../LinuxSyscalls/Syscalls/IO.cpp | 40 +- .../LinuxSyscalls/Syscalls/IOUring.cpp | 53 -- .../LinuxSyscalls/Syscalls/Info.cpp | 38 - .../LinuxSyscalls/Syscalls/Key.cpp | 62 -- .../LinuxSyscalls/Syscalls/Memory.cpp | 84 -- .../LinuxSyscalls/Syscalls/Msg.cpp | 58 -- .../LinuxSyscalls/Syscalls/Namespace.cpp | 85 -- .../LinuxSyscalls/Syscalls/Passthrough.cpp | 889 ++++++++++++++++++ .../LinuxSyscalls/Syscalls/SHM.cpp | 35 - .../LinuxSyscalls/Syscalls/Sched.cpp | 105 --- .../LinuxSyscalls/Syscalls/Semaphore.cpp | 27 - .../LinuxSyscalls/Syscalls/Socket.cpp | 88 -- .../LinuxSyscalls/Syscalls/Thread.cpp | 205 +--- .../LinuxSyscalls/Syscalls/Time.cpp | 26 - .../LinuxSyscalls/Syscalls/Timer.cpp | 14 +- .../LinuxEmulation/LinuxSyscalls/x32/FD.cpp | 40 +- .../LinuxEmulation/LinuxSyscalls/x32/IO.cpp | 12 - .../LinuxEmulation/LinuxSyscalls/x32/Msg.cpp | 10 - .../LinuxSyscalls/x32/Sched.cpp | 5 - .../LinuxSyscalls/x32/Semaphore.cpp | 5 - .../LinuxSyscalls/x32/Signals.cpp | 4 +- .../LinuxSyscalls/x32/Syscalls.cpp | 11 +- .../LinuxSyscalls/x32/Thread.cpp | 91 -- .../LinuxEmulation/LinuxSyscalls/x32/Time.cpp | 30 - .../LinuxSyscalls/x32/Timer.cpp | 10 - .../LinuxEmulation/LinuxSyscalls/x64/FD.cpp | 151 +-- .../LinuxEmulation/LinuxSyscalls/x64/IO.cpp | 32 - .../LinuxEmulation/LinuxSyscalls/x64/Info.cpp | 22 +- .../LinuxSyscalls/x64/Ioctl.cpp | 25 - .../LinuxSyscalls/x64/Memory.cpp | 23 - .../LinuxEmulation/LinuxSyscalls/x64/Msg.cpp | 48 - .../LinuxSyscalls/x64/Sched.cpp | 26 - .../LinuxSyscalls/x64/Semaphore.cpp | 10 - .../LinuxSyscalls/x64/Signals.cpp | 20 - .../LinuxSyscalls/x64/Socket.cpp | 55 -- .../LinuxSyscalls/x64/Syscalls.cpp | 21 +- .../LinuxSyscalls/x64/Thread.cpp | 46 - .../LinuxEmulation/LinuxSyscalls/x64/Time.cpp | 82 +- 43 files changed, 936 insertions(+), 2122 deletions(-) delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IOUring.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Key.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Msg.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Namespace.cpp create mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/SHM.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Sched.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Semaphore.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Socket.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Time.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/x64/IO.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Msg.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Sched.cpp delete mode 100644 Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Socket.cpp diff --git a/Source/Tools/LinuxEmulation/CMakeLists.txt b/Source/Tools/LinuxEmulation/CMakeLists.txt index c087e1dd3f..9ff006d6a1 100644 --- a/Source/Tools/LinuxEmulation/CMakeLists.txt +++ b/Source/Tools/LinuxEmulation/CMakeLists.txt @@ -34,36 +34,23 @@ set (SRCS LinuxSyscalls/x32/IoctlEmulation.cpp LinuxSyscalls/x64/EPoll.cpp LinuxSyscalls/x64/FD.cpp - LinuxSyscalls/x64/IO.cpp - LinuxSyscalls/x64/Ioctl.cpp LinuxSyscalls/x64/Info.cpp LinuxSyscalls/x64/Memory.cpp - LinuxSyscalls/x64/Msg.cpp LinuxSyscalls/x64/NotImplemented.cpp LinuxSyscalls/x64/Semaphore.cpp - LinuxSyscalls/x64/Sched.cpp LinuxSyscalls/x64/Signals.cpp - LinuxSyscalls/x64/Socket.cpp LinuxSyscalls/x64/Thread.cpp LinuxSyscalls/x64/Syscalls.cpp LinuxSyscalls/x64/Time.cpp LinuxSyscalls/Syscalls/EPoll.cpp LinuxSyscalls/Syscalls/FD.cpp LinuxSyscalls/Syscalls/FS.cpp + LinuxSyscalls/Syscalls/Passthrough.cpp LinuxSyscalls/Syscalls/Info.cpp LinuxSyscalls/Syscalls/IO.cpp - LinuxSyscalls/Syscalls/IOUring.cpp - LinuxSyscalls/Syscalls/Key.cpp LinuxSyscalls/Syscalls/Memory.cpp - LinuxSyscalls/Syscalls/Msg.cpp - LinuxSyscalls/Syscalls/Namespace.cpp - LinuxSyscalls/Syscalls/Sched.cpp - LinuxSyscalls/Syscalls/Semaphore.cpp - LinuxSyscalls/Syscalls/SHM.cpp LinuxSyscalls/Syscalls/Signals.cpp - LinuxSyscalls/Syscalls/Socket.cpp LinuxSyscalls/Syscalls/Thread.cpp - LinuxSyscalls/Syscalls/Time.cpp LinuxSyscalls/Syscalls/Timer.cpp LinuxSyscalls/Syscalls/NotImplemented.cpp LinuxSyscalls/Syscalls/Stubs.cpp) diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.h index 59f9083586..17f684433e 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.h +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.h @@ -65,19 +65,10 @@ class SignalDelegator; void RegisterFS(FEX::HLE::SyscallHandler *Handler); void RegisterInfo(FEX::HLE::SyscallHandler *Handler); void RegisterIO(FEX::HLE::SyscallHandler *Handler); - void RegisterIOUring(FEX::HLE::SyscallHandler *Handler); - void RegisterKey(FEX::HLE::SyscallHandler *Handler); void RegisterMemory(FEX::HLE::SyscallHandler *Handler); - void RegisterMsg(FEX::HLE::SyscallHandler *Handler); - void RegisterNamespace(FEX::HLE::SyscallHandler *Handler); void RegisterNuma(FEX::HLE::SyscallHandler *Handler); - void RegisterSched(FEX::HLE::SyscallHandler *Handler); - void RegisterSemaphore(FEX::HLE::SyscallHandler *Handler); - void RegisterSHM(FEX::HLE::SyscallHandler *Handler); void RegisterSignals(FEX::HLE::SyscallHandler *Handler); - void RegisterSocket(FEX::HLE::SyscallHandler *Handler); void RegisterThread(FEX::HLE::SyscallHandler *Handler); - void RegisterTime(FEX::HLE::SyscallHandler *Handler); void RegisterTimer(FEX::HLE::SyscallHandler *Handler); void RegisterNotImplemented(FEX::HLE::SyscallHandler *Handler); void RegisterStubs(FEX::HLE::SyscallHandler *Handler); @@ -636,9 +627,6 @@ bool IsFaultLocation(uint64_t PC); #define REGISTER_SYSCALL_IMPL(name, lambda) \ REGISTER_SYSCALL_IMPL_INTERNAL(name, ~0, FEXCore::IR::SyscallFlags::DEFAULT, lambda) -#define REGISTER_SYSCALL_IMPL_PASS(name, lambda) \ - REGISTER_SYSCALL_IMPL_INTERNAL(name, SYSCALL_DEF(name), FEXCore::IR::SyscallFlags::DEFAULT, lambda) - #define REGISTER_SYSCALL_IMPL_FLAGS(name, flags, lambda) \ REGISTER_SYSCALL_IMPL_INTERNAL(name, ~0, flags, lambda) diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/EPoll.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/EPoll.cpp index e214bfb0fa..8c473357f4 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/EPoll.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/EPoll.cpp @@ -19,16 +19,10 @@ namespace FEX::HLE { void RegisterEpoll(FEX::HLE::SyscallHandler *Handler) { using namespace FEXCore::IR; - REGISTER_SYSCALL_IMPL_PASS_FLAGS(epoll_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(epoll_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int size) -> uint64_t { uint64_t Result = epoll_create(size); SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(epoll_create1, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int flags) -> uint64_t { - uint64_t Result = epoll_create1(flags); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FD.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FD.cpp index fb3806d5ba..c7a4de5382 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FD.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FD.cpp @@ -32,18 +32,6 @@ namespace FEX::HLE { void RegisterFD(FEX::HLE::SyscallHandler *Handler) { using namespace FEXCore::IR; - REGISTER_SYSCALL_IMPL_PASS_FLAGS(read, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count) -> uint64_t { - uint64_t Result = ::read(fd, buf, count); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(write, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count) -> uint64_t { - uint64_t Result = ::write(fd, buf, count); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(open, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, int flags, uint32_t mode) -> uint64_t { flags = FEX::HLE::RemapFromX86Flags(flags); @@ -57,37 +45,25 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(chown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(chown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, uid_t owner, gid_t group) -> uint64_t { uint64_t Result = ::chown(pathname, owner, group); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, uid_t owner, gid_t group) -> uint64_t { - uint64_t Result = ::fchown(fd, owner, group); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(lchown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(lchown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, uid_t owner, gid_t group) -> uint64_t { uint64_t Result = ::lchown(pathname, owner, group); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(lseek, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, uint64_t offset, int whence) -> uint64_t { - uint64_t Result = ::lseek(fd, offset, whence); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(access, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, int mode) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Access(pathname, mode); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pipe, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(pipe, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int pipefd[2]) -> uint64_t { uint64_t Result = ::pipe(pipefd); SYSCALL_ERRNO(); @@ -100,60 +76,12 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(flock, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, int operation) -> uint64_t { - uint64_t Result = ::flock(fd, operation); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd) -> uint64_t { - uint64_t Result = ::fsync(fd); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fdatasync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd) -> uint64_t { - uint64_t Result = ::fdatasync(fd); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(ftruncate, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, off_t length) -> uint64_t { - uint64_t Result = ::ftruncate(fd, length); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchmod, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, int mode) -> uint64_t { - uint64_t Result = ::fchmod(fd, mode); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fadvise64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, off_t offset, off_t len, int advice) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fadvise64), fd, offset, len, advice); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_init, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(inotify_init, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { uint64_t Result = ::inotify_init(); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_add_watch, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, const char *pathname, uint32_t mask) -> uint64_t { - uint64_t Result = ::inotify_add_watch(fd, pathname, mask); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_rm_watch, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, int wd) -> uint64_t { - uint64_t Result = ::inotify_rm_watch(fd, wd); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(openat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int dirfs, const char *pathname, int flags, uint32_t mode) -> uint64_t { flags = FEX::HLE::RemapFromX86Flags(flags); @@ -161,63 +89,12 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mkdirat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, mode_t mode) -> uint64_t { - uint64_t Result = ::mkdirat(dirfd, pathname, mode); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mknodat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, mode_t mode, dev_t dev) -> uint64_t { - uint64_t Result = ::mknodat(dirfd, pathname, mode, dev); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchownat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, uid_t owner, gid_t group, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::fchownat(dirfd, pathname, owner, group, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(unlinkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::unlinkat(dirfd, pathname, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(renameat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int olddirfd, const char *oldpath, int newdirfd, const char *newpath) -> uint64_t { - uint64_t Result = ::renameat(olddirfd, oldpath, newdirfd, newpath); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(linkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::linkat(olddirfd, oldpath, newdirfd, newpath, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(symlinkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *target, int newdirfd, const char *linkpath) -> uint64_t { - uint64_t Result = ::symlinkat(target, newdirfd, linkpath); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(readlinkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, char *buf, size_t bufsiz) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Readlinkat(dirfd, pathname, buf, bufsiz); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchmodat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, mode_t mode) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(fchmodat), dirfd, pathname, mode); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(faccessat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, int mode) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.FAccessat(dirfd, pathname, mode); @@ -232,12 +109,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pidfd_getfd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pidfd, int fd, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pidfd_getfd), pidfd, fd, flags); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(openat2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int dirfs, const char *pathname, struct open_how *how, size_t usize) -> uint64_t { open_how HostHow{}; @@ -251,32 +122,10 @@ namespace FEX::HLE { } else { REGISTER_SYSCALL_IMPL(faccessat2, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(pidfd_getfd, UnimplementedSyscallSafe); REGISTER_SYSCALL_IMPL(openat2, UnimplementedSyscallSafe); } - REGISTER_SYSCALL_IMPL_PASS_FLAGS(splice, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::splice(fd_in, off_in, fd_out, off_out, len, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(tee, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd_in, int fd_out, size_t len, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::tee(fd_in, fd_out, len, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(timerfd_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int32_t clockid, int32_t flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::timerfd_create(clockid, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(eventfd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(eventfd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, uint32_t count) -> uint64_t { uint64_t Result = ::syscall(SYSCALL_DEF(eventfd2), count, 0); SYSCALL_ERRNO(); @@ -289,27 +138,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_init1, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::inotify_init1(flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(renameat2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = FHU::Syscalls::renameat2(olddirfd, oldpath, newdirfd, newpath, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(memfd_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *name, uint32_t flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::syscall(SYSCALL_DEF(memfd_create), name, flags); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(statx, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, int flags, uint32_t mask, struct statx *statxbuf) -> uint64_t { // Flags don't need remapped @@ -317,45 +145,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(name_to_handle_at, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, struct file_handle *handle, int *mount_id, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::syscall(SYSCALL_DEF(name_to_handle_at), dirfd, pathname, handle, mount_id, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(open_by_handle_at, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int mount_fd, struct file_handle *handle, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::syscall(SYSCALL_DEF(open_by_handle_at), mount_fd, handle, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(eventfd2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned int count, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::syscall(SYSCALL_DEF(eventfd2), count, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(copy_file_range, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::syscall(SYSCALL_DEF(copy_file_range), fd_in, off_in, fd_out, off_out, len, flags); - SYSCALL_ERRNO(); - }); - - if (Handler->IsHostKernelVersionAtLeast(5, 3, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pidfd_open, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pidfd_open), pid, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(pidfd_open, UnimplementedSyscallSafe); - } - if (Handler->IsHostKernelVersionAtLeast(5, 9, 0)) { REGISTER_SYSCALL_IMPL_FLAGS(close_range, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int first, unsigned int last, unsigned int flags) -> uint64_t { @@ -366,72 +155,5 @@ namespace FEX::HLE { else { REGISTER_SYSCALL_IMPL(close_range, UnimplementedSyscallSafe); } - - if (Handler->IsHostKernelVersionAtLeast(5, 13, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(landlock_create_ruleset, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *const rule_attr, size_t size, uint32_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(landlock_create_ruleset), rule_attr, size, flags); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(landlock_add_rule, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint32_t ruleset_fd, uint64_t rule_type, void *const rule_attr, uint32_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(landlock_add_rule), ruleset_fd, rule_type, rule_attr, flags); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(landlock_restrict_self, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint32_t ruleset_fd, uint32_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(landlock_restrict_self), ruleset_fd, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(landlock_create_ruleset, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(landlock_add_rule, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(landlock_restrict_self, UnimplementedSyscallSafe); - } - - if (Handler->IsHostKernelVersionAtLeast(5, 14, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(memfd_secret, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint32_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(memfd_secret), flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(memfd_secret, UnimplementedSyscallSafe); - } - - if (Handler->IsHostKernelVersionAtLeast(5, 15, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(process_mrelease, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pidfd, uint32_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(process_mrelease), pidfd, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(process_mrelease, UnimplementedSyscallSafe); - } - - if (Handler->IsHostKernelVersionAtLeast(6, 5, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(cachestat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, void* cstat_range, void* cstat, uint32_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(cachestat), fd, cstat_range, cstat, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(cachestat, UnimplementedSyscallSafe); - } - - if (Handler->IsHostKernelVersionAtLeast(6, 6, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchmodat2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, mode_t mode, uint32_t flags) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(fchmodat2), dirfd, pathname, mode, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(fchmodat2, UnimplementedSyscallSafe); - } } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp index b460848a94..52683a287f 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/FS.cpp @@ -25,55 +25,37 @@ namespace FEX::HLE { void RegisterFS(FEX::HLE::SyscallHandler *Handler) { using namespace FEXCore::IR; - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getcwd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, char *buf, size_t size) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(getcwd), buf, size); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(chdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *path) -> uint64_t { - uint64_t Result = ::chdir(path); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd) -> uint64_t { - uint64_t Result = ::fchdir(fd); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(rename, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(rename, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *oldpath, const char *newpath) -> uint64_t { uint64_t Result = ::rename(oldpath, newpath); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mkdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(mkdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, mode_t mode) -> uint64_t { uint64_t Result = ::mkdir(pathname, mode); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(rmdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(rmdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname) -> uint64_t { uint64_t Result = ::rmdir(pathname); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(link, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(link, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *oldpath, const char *newpath) -> uint64_t { uint64_t Result = ::link(oldpath, newpath); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(unlink, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(unlink, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname) -> uint64_t { uint64_t Result = ::unlink(pathname); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(symlink, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(symlink, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *target, const char *linkpath) -> uint64_t { uint64_t Result = ::symlink(target, linkpath); SYSCALL_ERRNO(); @@ -85,84 +67,24 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(chmod, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(chmod, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, mode_t mode) -> uint64_t { uint64_t Result = ::chmod(pathname, mode); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(umask, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, mode_t mask) -> uint64_t { - uint64_t Result = ::umask(mask); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(mknod, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, mode_t mode, dev_t dev) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Mknod(pathname, mode, dev); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(truncate, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *path, off_t length) -> uint64_t { - uint64_t Result = ::truncate(path, length); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(creat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(creat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, mode_t mode) -> uint64_t { uint64_t Result = ::creat(pathname, mode); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(chroot, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *path) -> uint64_t { - uint64_t Result = ::chroot(path); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - sync(); - return 0; // always successful - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(acct, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *filename) -> uint64_t { - uint64_t Result = ::acct(filename); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data) -> uint64_t { - uint64_t Result = ::mount(source, target, filesystemtype, mountflags, data); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(umount2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *target, int flags) -> uint64_t { - uint64_t Result = ::umount2(target, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(swapon, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *path, int swapflags) -> uint64_t { - uint64_t Result = ::swapon(path, swapflags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(swapoff, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *path) -> uint64_t { - uint64_t Result = ::swapoff(path); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(syncfs, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(syncfs), fd); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL(setxattr, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, const char *name, const void *value, size_t size, int flags) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Setxattr(path, name, value, size, flags); @@ -175,12 +97,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsetxattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, const char *name, const void *value, size_t size, int flags) -> uint64_t { - uint64_t Result = ::fsetxattr(fd, name, value, size, flags); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL(getxattr, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, const char *name, void *value, size_t size) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Getxattr(path, name, value, size); @@ -193,12 +109,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fgetxattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, const char *name, void *value, size_t size) -> uint64_t { - uint64_t Result = ::fgetxattr(fd, name, value, size); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL(listxattr, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, char *list, size_t size) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Listxattr(path, list, size); @@ -211,12 +121,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(flistxattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, char *list, size_t size) -> uint64_t { - uint64_t Result = ::flistxattr(fd, list, size); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL(removexattr, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, const char *name) -> uint64_t { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Removexattr(path, name); @@ -228,40 +132,5 @@ namespace FEX::HLE { uint64_t Result = FEX::HLE::_SyscallHandler->FM.LRemovexattr(path, name); SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fremovexattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, const char *name) -> uint64_t { - uint64_t Result = ::fremovexattr(fd, name); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fanotify_init, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned int flags, unsigned int event_f_flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fanotify_init), flags, event_f_flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fanotify_mark, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fanotify_fd, unsigned int flags, uint64_t mask, int dirfd, const char *pathname) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fanotify_mark), fanotify_fd, flags, mask, dirfd, pathname); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pivot_root, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *new_root, const char *put_old) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pivot_root), new_root, put_old); - SYSCALL_ERRNO(); - }); - - if (Handler->IsHostKernelVersionAtLeast(5, 14, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(quotactl_fd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint32_t fd, uint32_t cmd, uint32_t id, void* addr) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(quotactl_fd), fd, cmd, id, addr); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(quotactl_fd, UnimplementedSyscallSafe); - } } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IO.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IO.cpp index 7e4c57c8ab..3a304f1af4 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IO.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IO.cpp @@ -19,52 +19,16 @@ namespace FEX::HLE { void RegisterIO(FEX::HLE::SyscallHandler *Handler) { using namespace FEXCore::IR; - REGISTER_SYSCALL_IMPL_PASS_FLAGS(iopl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(iopl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int level) -> uint64_t { // Just claim we don't have permission return -EPERM; }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(ioperm, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(ioperm, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, unsigned long from, unsigned long num, int turn_on) -> uint64_t { // ioperm not available on our architecture return -EPERM; }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_setup, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned nr_events, aio_context_t *ctx_idp) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_setup), nr_events, ctx_idp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_destroy, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, aio_context_t ctx_id) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_destroy), ctx_id); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_submit, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, aio_context_t ctx_id, long nr, struct iocb **iocbpp) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_submit), ctx_id, nr, iocbpp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_cancel, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, aio_context_t ctx_id, struct iocb *iocb, struct io_event *result) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_cancel), ctx_id, iocb, result); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(ioprio_set, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int which, int who) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(ioprio_set), which, who); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(ioprio_get, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int which, int who, int ioprio) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(ioprio_get), which, who, ioprio); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IOUring.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IOUring.cpp deleted file mode 100644 index 302d107fda..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/IOUring.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/Syscalls/Thread.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include -#include -#include - -namespace SignalDelegator { - struct GuestSigAction; -} - - -namespace FEX::HLE { - void RegisterIOUring(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - if (Handler->IsHostKernelVersionAtLeast(5, 1, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_uring_setup, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint32_t entries, void* params) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_uring_setup), entries, params); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_uring_enter, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned int fd, uint32_t to_submit, uint32_t min_complete, uint32_t flags, void *argp, size_t argsz) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_uring_enter), fd, to_submit, min_complete, flags, argp, argsz); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_uring_register, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned int fd, unsigned int opcode, void *arg, uint32_t nr_args) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_uring_register), fd, opcode, arg, nr_args); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(io_uring_setup, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(io_uring_enter, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(io_uring_register, UnimplementedSyscallSafe); - } - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Info.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Info.cpp index 84b3501f7a..e91ea6bf09 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Info.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Info.cpp @@ -63,44 +63,6 @@ namespace FEX::HLE { return 0; }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(syslog, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int type, char *bufp, int len) -> uint64_t { - uint64_t Result = ::klogctl(type, bufp, len); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getrandom, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *buf, size_t buflen, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(getrandom), buf, buflen, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(capget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, cap_user_header_t hdrp, cap_user_data_t datap) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(capget), hdrp, datap); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(capset, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, cap_user_header_t hdrp, const cap_user_data_t datap) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(capset), hdrp, datap); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_FLAGS(getcpu, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) -> uint64_t { - // tcache is ignored - uint64_t Result = ::syscall(SYSCALL_DEF(getcpu), cpu, node, nullptr); - SYSCALL_ERRNO(); - }); - - //compare two processes to determine if they share a kernel resource - REGISTER_SYSCALL_IMPL_PASS_FLAGS(kcmp, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(kcmp), pid1, pid2, type, idx1, idx2); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(seccomp, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int operation, unsigned int flags, void *args) -> uint64_t { // FEX doesn't support seccomp diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Key.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Key.cpp deleted file mode 100644 index 32bd64c701..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Key.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/Types.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include -#include -#include - -namespace FEX::HLE { - void RegisterKey(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(add_key, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *type, const char *description, const void *payload, size_t plen, key_serial_t keyring) -> uint64_t { - uint64_t Result = syscall(SYS_add_key, type, description, payload, plen, keyring); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(request_key, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *type, const char *description, const char *callout_info, key_serial_t dest_keyring) -> uint64_t { - uint64_t Result = syscall(SYS_request_key, type, description, callout_info, dest_keyring); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(keyctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int operation, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) -> uint64_t { - uint64_t Result = syscall(SYS_keyctl, operation, arg2, arg3, arg4, arg5); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pkey_mprotect, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t len, int prot, int pkey) -> uint64_t { - // Added in Linux 4.9 - uint64_t Result = ::syscall(SYSCALL_DEF(pkey_mprotect), addr, len, prot, pkey); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pkey_alloc, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, unsigned int flags, unsigned int access_rights) -> uint64_t { - // Added in Linux 4.9 - uint64_t Result = ::syscall(SYSCALL_DEF(pkey_alloc), flags, access_rights); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pkey_free, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pkey) -> uint64_t { - // Added in Linux 4.9 - uint64_t Result = ::syscall(SYSCALL_DEF(pkey_free), pkey); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Memory.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Memory.cpp index 245adf317d..35e868ffa3 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Memory.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Memory.cpp @@ -28,18 +28,6 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(msync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t length, int32_t flags) -> uint64_t { - uint64_t Result = ::msync(addr, length, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mincore, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t length, uint8_t *vec) -> uint64_t { - uint64_t Result = ::mincore(addr, length, vec); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(madvise, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t length, int32_t advice) -> uint64_t { uint64_t Result = ::madvise(addr, length, advice); @@ -49,77 +37,5 @@ namespace FEX::HLE { } SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mlock, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const void *addr, size_t len) -> uint64_t { - uint64_t Result = ::mlock(addr, len); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(munlock, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const void *addr, size_t len) -> uint64_t { - uint64_t Result = ::munlock(addr, len); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mlock2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const void *addr, size_t len, int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mlock2), addr, len, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(remap_file_pages, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t size, int prot, size_t pgoff, int flags) -> uint64_t { - // This syscall is deprecated, not sure when it will end up being removed - uint64_t Result = ::syscall(SYSCALL_DEF(remap_file_pages), addr, size, prot, pgoff, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mbind, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mbind), addr, len, mode, nodemask, maxnode, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(get_mempolicy, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int *mode, unsigned long *nodemask, unsigned long maxnode, void *addr, unsigned long flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(get_mempolicy), mode, nodemask, maxnode, addr, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(set_mempolicy, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int mode, const unsigned long *nodemask, unsigned long maxnode) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(set_mempolicy), mode, nodemask, maxnode); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(migrate_pages, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pid, unsigned long maxnode, const unsigned long *old_nodes, const unsigned long *new_nodes) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(migrate_pages), pid, maxnode, old_nodes, new_nodes); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(move_pages, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(move_pages), pid, count, pages, nodes, status, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(membarrier, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int cmd, int flags) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(membarrier), cmd, flags); - SYSCALL_ERRNO(); - }); - - if (Handler->IsHostKernelVersionAtLeast(5, 17, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(set_mempolicy_home_node, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint64_t start, uint64_t len, uint64_t home_node, uint64_t flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(set_mempolicy_home_node), start, len, home_node, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(set_mempolicy_home_node, UnimplementedSyscallSafe); - } } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Msg.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Msg.cpp deleted file mode 100644 index f6dfdc9795..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Msg.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include -#include -#include -#include - -namespace FEX::HLE { - void RegisterMsg(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, key_t key, int msgflg) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(msgget), key, msgflg); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgsnd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int msqid, const void *msgp, size_t msgsz, int msgflg) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(msgsnd), msqid, msgp, msgsz, msgflg); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgrcv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(msgrcv), msqid, msgp, msgsz, msgtyp, msgflg); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int msqid, int cmd, struct msqid_ds *buf) -> uint64_t { - // A quirk of this syscall - // On 32-bit this syscall ONLY supports IPC_64 msqid_ds encoding - // If an application want to use the old style encoding then it needs to use the ipc syscall with MSGCTL command - // ipc syscall supports both IPC_64 and old encoding - uint64_t Result = ::syscall(SYSCALL_DEF(msgctl), msqid, cmd, buf); - SYSCALL_ERRNO(); - }); - - // last two parameters are optional - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mq_unlink, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, const char *name) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_unlink), name); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Namespace.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Namespace.cpp deleted file mode 100644 index 48196b67de..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Namespace.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/Syscalls/Thread.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include -#include -#include - -namespace SignalDelegator { - struct GuestSigAction; -} - - -namespace FEX::HLE { - void RegisterNamespace(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - if (Handler->GetHostKernelVersion() >= FEX::HLE::SyscallHandler::KernelVersion(5, 1, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(open_tree, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dfd, const char *filename, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(open_tree), dfd, filename, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(move_mount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(move_mount), from_dfd, from_pathname, to_dfd, to_pathname, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsopen, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dfd, const char *path, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fsopen), dfd, path, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsconfig, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, unsigned int cmd, const char *key, const void *value, int aux) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fsconfig), fd, cmd, key, value, aux); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsmount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fs_fd, uint32_t flags, uint32_t attr_flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fsmount), fs_fd, flags, attr_flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(fspick, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dfd, const char *path, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(fspick), dfd, path, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(open_tree, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(move_mount, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(fsopen, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(fsconfig, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(fsmount, UnimplementedSyscallSafe); - REGISTER_SYSCALL_IMPL(fspick, UnimplementedSyscallSafe); - } - - if (Handler->GetHostKernelVersion() >= FEX::HLE::SyscallHandler::KernelVersion(5, 12, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(mount_setattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int dfd, const char *path, unsigned int flags, void *uattr, size_t usize) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mount_setattr), dfd, path, flags, uattr, usize); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(mount_setattr, UnimplementedSyscallSafe); - } - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp new file mode 100644 index 0000000000..3136437745 --- /dev/null +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp @@ -0,0 +1,889 @@ +// SPDX-License-Identifier: MIT +/* +$info$ +meta: LinuxSyscalls|syscalls-shared ~ Syscall implementations shared between x86 and x86-64 +tags: LinuxSyscalls|syscalls-shared +$end_info$ +*/ + +#include "LinuxSyscalls/Syscalls.h" +#include "LinuxSyscalls/x64/Syscalls.h" +#include "LinuxSyscalls/x32/Syscalls.h" + +#include + +#include +#include + +namespace FEX::HLE { +#ifdef _M_ARM_64 +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough0(FEXCore::Core::CpuStateFrame *Frame) { + register uint64_t x0 asm ("x0"); + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough1(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1) { + register uint64_t x0 asm ("x0") = arg1; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough2(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2) { + register uint64_t x0 asm ("x0") = arg1; + register uint64_t x1 asm ("x1") = arg2; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + , "r" (x1) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough3(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3) { + register uint64_t x0 asm ("x0") = arg1; + register uint64_t x1 asm ("x1") = arg2; + register uint64_t x2 asm ("x2") = arg3; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + , "r" (x1) + , "r" (x2) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough4(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { + register uint64_t x0 asm ("x0") = arg1; + register uint64_t x1 asm ("x1") = arg2; + register uint64_t x2 asm ("x2") = arg3; + register uint64_t x3 asm ("x3") = arg4; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + , "r" (x1) + , "r" (x2) + , "r" (x3) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough5(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { + register uint64_t x0 asm ("x0") = arg1; + register uint64_t x1 asm ("x1") = arg2; + register uint64_t x2 asm ("x2") = arg3; + register uint64_t x3 asm ("x3") = arg4; + register uint64_t x4 asm ("x4") = arg5; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + , "r" (x1) + , "r" (x2) + , "r" (x3) + , "r" (x4) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough6(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6) { + register uint64_t x0 asm ("x0") = arg1; + register uint64_t x1 asm ("x1") = arg2; + register uint64_t x2 asm ("x2") = arg3; + register uint64_t x3 asm ("x3") = arg4; + register uint64_t x4 asm ("x4") = arg5; + register uint64_t x5 asm ("x5") = arg6; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + , "r" (x1) + , "r" (x2) + , "r" (x3) + , "r" (x4) + , "r" (x5) + : "memory"); + return x0; +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough7(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7) { + register uint64_t x0 asm ("x0") = arg1; + register uint64_t x1 asm ("x1") = arg2; + register uint64_t x2 asm ("x2") = arg3; + register uint64_t x3 asm ("x3") = arg4; + register uint64_t x4 asm ("x4") = arg5; + register uint64_t x5 asm ("x5") = arg6; + register uint64_t x6 asm ("x6") = arg7; + register int x8 asm ("x8") = syscall_num; + __asm volatile(R"( + svc #0; + )" + : "=r" (x0) + : "r" (x8) + , "r" (x0) + , "r" (x1) + , "r" (x2) + , "r" (x3) + , "r" (x4) + , "r" (x5) + , "r" (x6) + : "memory"); + return x0; +} +#else +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough0(FEXCore::Core::CpuStateFrame *Frame) { + uint64_t Result = ::syscall(syscall_num); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough1(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1) { + uint64_t Result = ::syscall(syscall_num, arg1); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough2(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2) { + uint64_t Result = ::syscall(syscall_num, arg1, arg2); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough3(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3) { + uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough4(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { + uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3, arg4); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough5(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { + uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3, arg4, arg5); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough6(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6) { + uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3, arg4, arg5, arg6); + SYSCALL_ERRNO(); +} + +template +requires (syscall_num != -1) +uint64_t SyscallPassthrough7(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7) { + uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + SYSCALL_ERRNO(); +} +#endif + + void RegisterCommon(FEX::HLE::SyscallHandler *Handler) { + using namespace FEXCore::IR; + REGISTER_SYSCALL_IMPL_PASS_FLAGS(read, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(write, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(lseek, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_yield, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(msync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mincore, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(_shmget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(_shmctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(socket, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(connect, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sendto, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(recvfrom, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(shutdown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(bind, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(listen, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getsockname, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpeername, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(socketpair, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(kill, SyscallFlags::DEFAULT, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(semget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgsnd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgrcv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(msgctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(flock, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fdatasync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(truncate, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(ftruncate, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getcwd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(chdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchdir, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchmod, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(umask, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(syslog, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(geteuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getegid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setpgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getppid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setsid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setreuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setregid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getgroups, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setgroups, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setresuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getresuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setresgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getresgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setfsuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setfsgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getsid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(capget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(capset, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(personality, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpriority, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setpriority, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setparam, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getparam, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setscheduler, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getscheduler, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_get_priority_max, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_get_priority_min, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mlock, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(munlock, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(pivot_root, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(chroot, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sync, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(acct, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(umount2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(swapon, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(swapoff, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(gettid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsetxattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fgetxattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(flistxattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fremovexattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(tkill, SyscallFlags::DEFAULT, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setaffinity, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getaffinity, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_setup, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_destroy, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_submit, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_cancel, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(remap_file_pages, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fadvise64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(timer_getoverrun, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(timer_delete, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(tgkill, SyscallFlags::DEFAULT, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mbind, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(set_mempolicy, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(get_mempolicy, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mq_unlink, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(add_key, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(request_key, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(keyctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(ioprio_set, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(ioprio_get, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_add_watch, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_rm_watch, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(migrate_pages, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mkdirat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mknodat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchownat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(unlinkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(renameat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(linkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(symlinkat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fchmodat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(unshare, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(splice, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(tee, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(move_pages, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(timerfd_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(accept4, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(eventfd2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(epoll_create1, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(inotify_init1, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fanotify_init, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fanotify_mark, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(prlimit_64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(name_to_handle_at, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(open_by_handle_at, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(syncfs, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(setns, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getcpu, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(kcmp, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(renameat2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(getrandom, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(memfd_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(membarrier, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mlock2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(copy_file_range, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(pkey_mprotect, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(pkey_alloc, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(pkey_free, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + if (Handler->IsHostKernelVersionAtLeast(5, 1, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_uring_setup, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_uring_enter, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(io_uring_register, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(open_tree, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(move_mount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsopen, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsconfig, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fsmount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_PASS_FLAGS(fspick, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + } + else { + REGISTER_SYSCALL_IMPL(io_uring_setup, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(io_uring_enter, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(io_uring_register, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(open_tree, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(move_mount, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(fsopen, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(fsconfig, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(fsmount, UnimplementedSyscallSafe); + REGISTER_SYSCALL_IMPL(fspick, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 3, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(pidfd_open, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + } + else { + REGISTER_SYSCALL_IMPL(pidfd_open, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 8, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(pidfd_getfd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + } + else { + REGISTER_SYSCALL_IMPL(pidfd_getfd, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 12, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(mount_setattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + } + else { + REGISTER_SYSCALL_IMPL(mount_setattr, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 14, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(quotactl_fd, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + } + else { + REGISTER_SYSCALL_IMPL(quotactl_fd, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 13, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(landlock_create_ruleset, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + } + else { + REGISTER_SYSCALL_IMPL(landlock_create_ruleset, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 13, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(landlock_add_rule, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + } + else { + REGISTER_SYSCALL_IMPL(landlock_add_rule, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 13, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(landlock_restrict_self, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + } + else { + REGISTER_SYSCALL_IMPL(landlock_restrict_self, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 14, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(memfd_secret, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + } + else { + REGISTER_SYSCALL_IMPL(memfd_secret, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 15, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(process_mrelease, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + } + else { + REGISTER_SYSCALL_IMPL(process_mrelease, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 16, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(futex_waitv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + } + else { + REGISTER_SYSCALL_IMPL(futex_waitv, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 17, 0)) { + REGISTER_SYSCALL_IMPL_PASS_FLAGS(set_mempolicy_home_node, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + } + else { + REGISTER_SYSCALL_IMPL(set_mempolicy_home_node, UnimplementedSyscallSafe); + } + } + + namespace x64 { + void RegisterPassthrough(FEX::HLE::SyscallHandler *Handler) { + using namespace FEXCore::IR; + RegisterCommon(Handler); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(ioctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(pread_64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(pwrite_64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(readv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(writev, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(dup, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(nanosleep, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(getitimer, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(setitimer, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(sendfile, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(accept, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(sendmsg, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(recvmsg, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(setsockopt, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(getsockopt, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(wait4, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(semop, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(gettimeofday, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(getrlimit, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(getrusage, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(sysinfo, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(times, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(rt_sigqueueinfo, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(fstatfs, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(sched_rr_get_interval, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mlockall, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(munlockall, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(adjtimex, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(setrlimit, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(settimeofday, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(readahead, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(futex, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(io_getevents, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(getdents64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(semtimedop, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(timer_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(timer_settime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(timer_gettime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(clock_settime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(clock_gettime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(clock_getres, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(clock_nanosleep, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mq_open, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mq_timedsend, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mq_timedreceive, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mq_notify, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mq_getsetattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(waitid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(pselect6, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(ppoll, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(set_robust_list, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(get_robust_list, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(sync_file_range, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(vmsplice, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(utimensat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(fallocate, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(timerfd_settime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(timerfd_gettime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(preadv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(pwritev, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(rt_tgsigqueueinfo, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(recvmmsg, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(clock_adjtime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(sendmmsg, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(process_vm_readv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(process_vm_writev, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(preadv2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(pwritev2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(io_pgetevents, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + if (Handler->IsHostKernelVersionAtLeast(5, 1, 0)) { + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(pidfd_send_signal, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + } + else { + REGISTER_SYSCALL_IMPL_X64(pidfd_send_signal, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(5, 10, 0)) { + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(process_madvise, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + } + else { + REGISTER_SYSCALL_IMPL_X64(process_madvise, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(6, 5, 0)) { + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(cachestat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + } + else { + REGISTER_SYSCALL_IMPL_X64(cachestat, UnimplementedSyscallSafe); + } + if (Handler->IsHostKernelVersionAtLeast(6, 6, 0)) { + REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(fchmodat2, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + } + else { + REGISTER_SYSCALL_IMPL_X64(fchmodat2, UnimplementedSyscallSafe); + } + } + } + + namespace x32 { + void RegisterPassthrough(FEX::HLE::SyscallHandler *Handler) { + using namespace FEXCore::IR; + RegisterCommon(Handler); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(getuid32, getuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(getgid32, getgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(geteuid32, geteuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(getegid32, getegid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough0); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setreuid32, setreuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setregid32, setregid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(getgroups32, getgroups, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setgroups32, setgroups, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(fchown32, fchown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setresuid32, setresuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(getresuid32, getresuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setresgid32, setresgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(getresgid32, getresgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough3); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setuid32, setuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setgid32, setgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setfsuid32, setfsuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(setfsgid32, setfsgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough1); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(sendfile64, sendfile, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(clock_gettime64, clock_gettime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(clock_settime64, clock_settime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(clock_adjtime64, clock_adjtime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(clock_getres_time64, clock_getres, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(clock_nanosleep_time64, clock_nanosleep, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(timer_gettime64, timer_gettime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(timer_settime64, timer_settime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(timerfd_gettime64, timerfd_gettime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(timerfd_settime64, timerfd_settime, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(utimensat_time64, utimensat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(ppoll_time64, ppoll, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(io_pgetevents_time64, io_pgetevents, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(mq_timedsend_time64, mq_timedsend, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(mq_timedreceive_time64, mq_timedreceive, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough5); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(semtimedop_time64, semtimedop, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough4); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(futex_time64, futex, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough6); + REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL_FLAGS(sched_rr_get_interval_time64, sched_rr_get_interval, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + SyscallPassthrough2); + } + } +} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/SHM.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/SHM.cpp deleted file mode 100644 index 54fcca1d79..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/SHM.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include -#include -#include - -namespace FEX::HLE { - void RegisterSHM(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(_shmget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, key_t key, size_t size, int shmflg) -> uint64_t { - uint64_t Result = shmget(key, size, shmflg); - SYSCALL_ERRNO(); - }); - - // XXX: shmid_ds is definitely not correct for 32-bit - REGISTER_SYSCALL_IMPL_PASS_FLAGS(_shmctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int shmid, int cmd, struct shmid_ds *buf) -> uint64_t { - uint64_t Result = ::shmctl(shmid, cmd, buf); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Sched.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Sched.cpp deleted file mode 100644 index 08c0100c49..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Sched.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace FEX::HLE { - void RegisterSched(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_yield, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::sched_yield(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpriority, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int which, int who) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(getpriority), which, who); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setpriority, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int which, int who, int prio) -> uint64_t { - uint64_t Result = ::setpriority(which, who, prio); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setparam, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, const struct sched_param *param) -> uint64_t { - uint64_t Result = ::sched_setparam(pid, param); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getparam, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, struct sched_param *param) -> uint64_t { - uint64_t Result = ::sched_getparam(pid, param); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setscheduler, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int policy, const struct sched_param *param) -> uint64_t { - uint64_t Result = ::sched_setscheduler(pid, policy, param); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getscheduler, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid) -> uint64_t { - uint64_t Result = ::sched_getscheduler(pid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_get_priority_max, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int policy) -> uint64_t { - uint64_t Result = ::sched_get_priority_max(policy); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_get_priority_min, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int policy) -> uint64_t { - uint64_t Result = ::sched_get_priority_min(policy); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_FLAGS(sched_setaffinity, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY | SyscallFlags::NOSIDEEFFECTS, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, size_t cpusetsize, const unsigned long *mask) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(sched_setaffinity), pid, cpusetsize, mask); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_FLAGS(sched_getaffinity, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, size_t cpusetsize, unsigned char *mask) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(sched_getaffinity), pid, cpusetsize, mask); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_setattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, struct sched_attr *attr, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(sched_setattr), pid, attr, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sched_getattr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, struct sched_attr *attr, unsigned int size, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(sched_getattr), pid, attr, size, flags); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Semaphore.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Semaphore.cpp deleted file mode 100644 index ea90b97e6c..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Semaphore.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include -#include - -#include - -namespace FEX::HLE { - void RegisterSemaphore(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(semget, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, key_t key, int nsems, int semflg) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(semget), key, nsems, semflg); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Socket.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Socket.cpp deleted file mode 100644 index 7c6f954994..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Socket.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include -#include -#include - -namespace FEX::HLE { - void RegisterSocket(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(socket, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int domain, int type, int protocol) -> uint64_t { - uint64_t Result = ::socket(domain, type, protocol); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(connect, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, const struct sockaddr *addr, socklen_t addrlen) -> uint64_t { - uint64_t Result = ::connect(sockfd, addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(accept4, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) -> uint64_t { - uint64_t Result = ::accept4(sockfd, addr, addrlen, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(sendto, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) -> uint64_t { - uint64_t Result = ::sendto(sockfd, buf, len, flags, dest_addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(recvfrom, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) -> uint64_t { - uint64_t Result = ::recvfrom(sockfd, buf, len, flags, src_addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(shutdown, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, int how) -> uint64_t { - uint64_t Result = ::shutdown(sockfd, how); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(bind, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, const struct sockaddr *addr, socklen_t addrlen) -> uint64_t { - uint64_t Result = ::bind(sockfd, addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(listen, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, int backlog) -> uint64_t { - uint64_t Result = ::listen(sockfd, backlog); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getsockname, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct sockaddr *addr, socklen_t *addrlen) -> uint64_t { - uint64_t Result = ::getsockname(sockfd, addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpeername, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct sockaddr *addr, socklen_t *addrlen) -> uint64_t { - uint64_t Result = ::getpeername(sockfd, addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(socketpair, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int domain, int type, int protocol, int sv[2]) -> uint64_t { - uint64_t Result = ::socketpair(domain, type, protocol, sv); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp index f0e67f8182..b4a0910615 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp @@ -363,12 +363,6 @@ namespace FEX::HLE { FEX_UNREACHABLE; }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getpid(); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(fork, SyscallFlags::DEFAULT, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { return ForkGuest(Frame->Thread, Frame, 0, 0, 0, 0, 0, 0); }); @@ -377,6 +371,12 @@ namespace FEX::HLE { return ForkGuest(Frame->Thread, Frame, CLONE_VFORK, 0, 0, 0, 0, 0); }); + REGISTER_SYSCALL_IMPL_FLAGS(getpgrp, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { + uint64_t Result = ::getpgrp(); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL_FLAGS(clone3, SyscallFlags::DEFAULT, ([](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::kernel_clone3_args *cl_args, size_t size) -> uint64_t { FEX::HLE::clone3_args args{}; args.Type = TypeOfClone::TYPE_CLONE3; @@ -410,130 +410,6 @@ namespace FEX::HLE { return 0; }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(kill, SyscallFlags::DEFAULT, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int sig) -> uint64_t { - uint64_t Result = ::kill(pid, sig); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(tkill, SyscallFlags::DEFAULT, [](FEXCore::Core::CpuStateFrame *Frame, int tid, int sig) -> uint64_t { - // Can't actually use tgkill here, kernel rejects tgkill of tgid == 0 - uint64_t Result = ::syscall(SYSCALL_DEF(tkill), tid, sig); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(tgkill, SyscallFlags::DEFAULT, [](FEXCore::Core::CpuStateFrame *Frame, int tgid, int tid, int sig) -> uint64_t { - uint64_t Result = FHU::Syscalls::tgkill(tgid, tid, sig); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getuid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getgid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uid_t uid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setuid), uid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, gid_t gid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setgid), gid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(geteuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::geteuid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getegid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getegid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getppid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getppid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpgrp, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getpgrp(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setsid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::setsid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setreuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uid_t ruid, uid_t euid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setreuid), ruid, euid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setregid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, gid_t rgid, gid_t egid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setregid), rgid, egid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getgroups, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int size, gid_t list[]) -> uint64_t { - uint64_t Result = ::getgroups(size, list); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setgroups, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, size_t size, const gid_t *list) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setgroups), size, list); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setresuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uid_t ruid, uid_t euid, uid_t suid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setresuid), ruid, euid, suid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getresuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uid_t *ruid, uid_t *euid, uid_t *suid) -> uint64_t { - uint64_t Result = ::getresuid(ruid, euid, suid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setresgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, gid_t rgid, gid_t egid, gid_t sgid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(setresgid), rgid, egid, sgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getresgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, gid_t *rgid, gid_t *egid, gid_t *sgid) -> uint64_t { - uint64_t Result = ::getresgid(rgid, egid, sgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(personality, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uint64_t persona) -> uint64_t { - uint64_t Result = ::personality(persona); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_FLAGS(prctl, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) -> uint64_t { uint64_t Result{}; @@ -617,20 +493,14 @@ namespace FEX::HLE { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(gettid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = FHU::Syscalls::gettid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(set_tid_address, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(set_tid_address, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int *tidptr) -> uint64_t { auto Thread = Frame->Thread; Thread->ThreadManager.clear_child_tid = tidptr; return Thread->ThreadManager.GetTID(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(exit_group, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY | SyscallFlags::NORETURN, + REGISTER_SYSCALL_IMPL_FLAGS(exit_group, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY | SyscallFlags::NORETURN, [](FEXCore::Core::CpuStateFrame *Frame, int status) -> uint64_t { // Save telemetry if we're exiting. @@ -640,64 +510,5 @@ namespace FEX::HLE { // This will never be reached std::terminate(); }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(prlimit_64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(prlimit_64), pid, resource, new_limit, old_limit); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setpgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, pid_t pgid) -> uint64_t { - uint64_t Result = ::setpgid(pid, pgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getpgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid) -> uint64_t { - uint64_t Result = ::getpgid(pid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setfsuid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uid_t fsuid) -> uint64_t { - uint64_t Result = ::setfsuid(fsuid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setfsgid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, uid_t fsgid) -> uint64_t { - uint64_t Result = ::setfsgid(fsgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(getsid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid) -> uint64_t { - uint64_t Result = ::getsid(pid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(unshare, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int flags) -> uint64_t { - uint64_t Result = ::unshare(flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(setns, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int fd, int nstype) -> uint64_t { - uint64_t Result = ::setns(fd, nstype); - SYSCALL_ERRNO(); - }); - - if (Handler->IsHostKernelVersionAtLeast(5, 16, 0)) { - REGISTER_SYSCALL_IMPL_PASS_FLAGS(futex_waitv, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, void *waiters, uint32_t nr_futexes, uint32_t flags, struct timespec *timeout, clockid_t clockid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(futex_waitv), waiters, nr_futexes, flags, timeout, clockid); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL(futex_waitv, UnimplementedSyscallSafe); - } } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Time.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Time.cpp deleted file mode 100644 index 3a465bfe6f..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Time.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-shared -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" -#include "LinuxSyscalls/x32/Syscalls.h" - -#include - -#include - -namespace FEX::HLE { - void RegisterTime(FEX::HLE::SyscallHandler *Handler) { - using namespace FEXCore::IR; - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(pause, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::pause(); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Timer.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Timer.cpp index 6953a95778..47e32a1eed 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Timer.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Timer.cpp @@ -24,21 +24,15 @@ namespace FEX::HLE { void RegisterTimer(FEX::HLE::SyscallHandler *Handler) { using namespace FEXCore::IR; - REGISTER_SYSCALL_IMPL_PASS_FLAGS(alarm, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_FLAGS(alarm, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int seconds) -> uint64_t { uint64_t Result = ::alarm(seconds); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_PASS_FLAGS(timer_getoverrun, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, kernel_timer_t timerid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_getoverrun), timerid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_PASS_FLAGS(timer_delete, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, kernel_timer_t timerid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_delete), timerid); + REGISTER_SYSCALL_IMPL_FLAGS(pause, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { + uint64_t Result = ::pause(); SYSCALL_ERRNO(); }); } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp index 640e6aa788..6e5c2ac316 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp @@ -253,7 +253,7 @@ namespace FEX::HLE::x32 { }; void RegisterFD(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X32_PASS(poll, [](FEXCore::Core::CpuStateFrame *Frame, struct pollfd *fds, nfds_t nfds, int timeout) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(poll, [](FEXCore::Core::CpuStateFrame *Frame, struct pollfd *fds, nfds_t nfds, int timeout) -> uint64_t { uint64_t Result = ::poll(fds, nfds, timeout); SYSCALL_ERRNO(); }); @@ -292,17 +292,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(ppoll_time64, ppoll, [](FEXCore::Core::CpuStateFrame *Frame, struct pollfd *fds, nfds_t nfds, struct timespec *timeout_ts, const uint64_t *sigmask, size_t sigsetsize) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(ppoll), - fds, - nfds, - timeout_ts, - sigmask, - sigsetsize); - - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(_llseek, [](FEXCore::Core::CpuStateFrame *Frame, uint32_t fd, uint32_t offset_high, uint32_t offset_low, loff_t *result, uint32_t whence) -> uint64_t { uint64_t Offset = offset_high; Offset <<= 32; @@ -326,17 +315,12 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(chown32, chown, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, uid_t owner, gid_t group) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(chown32, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, uid_t owner, gid_t group) -> uint64_t { uint64_t Result = ::chown(pathname, owner, group); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(fchown32, fchown, [](FEXCore::Core::CpuStateFrame *Frame, int fd, uid_t owner, gid_t group) -> uint64_t { - uint64_t Result = ::fchown(fd, owner, group); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(lchown32, lchown, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, uid_t owner, gid_t group) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(lchown32, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, uid_t owner, gid_t group) -> uint64_t { uint64_t Result = ::lchown(pathname, owner, group); SYSCALL_ERRNO(); }); @@ -740,16 +724,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(timerfd_settime64, timerfd_settime, [](FEXCore::Core::CpuStateFrame *Frame, int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) -> uint64_t { - uint64_t Result = ::timerfd_settime(fd, flags, new_value, old_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(timerfd_gettime64, timerfd_gettime, [](FEXCore::Core::CpuStateFrame *Frame, int fd, struct itimerspec *curr_value) -> uint64_t { - uint64_t Result = ::timerfd_gettime(fd, curr_value); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(timerfd_settime, [](FEXCore::Core::CpuStateFrame *Frame, int fd, int flags, @@ -896,14 +870,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(sendfile64, sendfile, [](FEXCore::Core::CpuStateFrame *Frame, int out_fd, int in_fd, off_t *offset, compat_size_t count) -> uint64_t { - // Linux definition for this is a bit confusing - // Defines offset as compat_loff_t* but loads loff_t worth of data - // count is defined as compat_size_t still - uint64_t Result = ::sendfile(out_fd, in_fd, offset, count); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(pread_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, uint32_t count, uint32_t offset_low, uint32_t offset_high) -> uint64_t { uint64_t Offset = offset_high; Offset <<= 32; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/IO.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/IO.cpp index df9d936334..000a9d2cbe 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/IO.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/IO.cpp @@ -40,17 +40,5 @@ namespace FEX::HLE::x32 { uint64_t Result = ::syscall(SYSCALL_DEF(io_pgetevents), ctx_id, min_nr, nr, events, timeout_ptr, usig); SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_X32_PASS(io_pgetevents_time64, - [](FEXCore::Core::CpuStateFrame *Frame, - aio_context_t ctx_id, - long min_nr, - long nr, - struct io_event *events, - struct timespec *timeout, - const struct io_sigset *usig) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_pgetevents), ctx_id, min_nr, nr, events, timeout, usig); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Msg.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Msg.cpp index 3ba511a7b5..13c4d994b3 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Msg.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Msg.cpp @@ -45,16 +45,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(mq_timedsend_time64, mq_timedsend, [](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_timedsend), mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(mq_timedreceive_time64, mq_timedreceive, [](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_timedreceive), mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(mq_open, [](FEXCore::Core::CpuStateFrame *Frame, const char *name, int oflag, mode_t mode, compat_ptr attr) -> uint64_t { mq_attr HostAttr{}; mq_attr *HostAttr_p{}; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Sched.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Sched.cpp index 359c69f4fd..9a990b5d39 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Sched.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Sched.cpp @@ -29,10 +29,5 @@ namespace FEX::HLE::x32 { } SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_X32_PASS(sched_rr_get_interval_time64, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, struct timespec *tp) -> uint64_t { - uint64_t Result = ::sched_rr_get_interval(pid, tp); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Semaphore.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Semaphore.cpp index 579fe305cf..feccb3f971 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Semaphore.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Semaphore.cpp @@ -385,11 +385,6 @@ namespace FEX::HLE::x32 { void RegisterSemaphore(FEX::HLE::SyscallHandler *Handler) { REGISTER_SYSCALL_IMPL_X32(ipc, _ipc); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(semtimedop_time64, semtimedop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(semtimedop), semid, sops, nsops, timeout); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(semctl, [](FEXCore::Core::CpuStateFrame *Frame, int semid, int semnum, int cmd, semun_32 *semun) -> uint64_t { uint64_t Result{}; bool IPC64 = cmd & 0x100; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Signals.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Signals.cpp index 99443f6a1b..d16b094340 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Signals.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Signals.cpp @@ -213,7 +213,7 @@ namespace FEX::HLE::x32 { REGISTER_SYSCALL_IMPL_X32(pidfd_send_signal, UnimplementedSyscallSafe); } - REGISTER_SYSCALL_IMPL_X32_PASS(rt_sigqueueinfo, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int sig, compat_ptr info) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(rt_sigqueueinfo, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int sig, compat_ptr info) -> uint64_t { siginfo_t info64{}; siginfo_t *info64_p{}; @@ -225,7 +225,7 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS(rt_tgsigqueueinfo, [](FEXCore::Core::CpuStateFrame *Frame, pid_t tgid, pid_t tid, int sig, compat_ptr info) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(rt_tgsigqueueinfo, [](FEXCore::Core::CpuStateFrame *Frame, pid_t tgid, pid_t tid, int sig, compat_ptr info) -> uint64_t { siginfo_t info64{}; siginfo_t *info64_p{}; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Syscalls.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Syscalls.cpp index 73aa821403..5f6eaa1a47 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Syscalls.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Syscalls.cpp @@ -40,6 +40,7 @@ namespace FEX::HLE::x32 { void RegisterThread(FEX::HLE::SyscallHandler *Handler); void RegisterTime(FEX::HLE::SyscallHandler *Handler); void RegisterTimer(FEX::HLE::SyscallHandler *Handler); + void RegisterPassthrough(FEX::HLE::SyscallHandler *Handler); x32SyscallHandler::x32SyscallHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, fextl::unique_ptr Allocator) : SyscallHandler{ctx, _SignalDelegation}, AllocHandler{std::move(Allocator)} { @@ -67,18 +68,9 @@ namespace FEX::HLE::x32 { FEX::HLE::RegisterFS(this); FEX::HLE::RegisterInfo(this); FEX::HLE::RegisterIO(this); - FEX::HLE::RegisterIOUring(this); - FEX::HLE::RegisterKey(this); FEX::HLE::RegisterMemory(this); - FEX::HLE::RegisterMsg(this); - FEX::HLE::RegisterNamespace(this); - FEX::HLE::RegisterSched(this); - FEX::HLE::RegisterSemaphore(this); - FEX::HLE::RegisterSHM(this); FEX::HLE::RegisterSignals(this); - FEX::HLE::RegisterSocket(this); FEX::HLE::RegisterThread(this); - FEX::HLE::RegisterTime(this); FEX::HLE::RegisterTimer(this); FEX::HLE::RegisterNotImplemented(this); FEX::HLE::RegisterStubs(this); @@ -100,6 +92,7 @@ namespace FEX::HLE::x32 { FEX::HLE::x32::RegisterThread(this); FEX::HLE::x32::RegisterTime(this); FEX::HLE::x32::RegisterTimer(this); + FEX::HLE::x32::RegisterPassthrough(this); FEX::HLE::x32::InitializeStaticIoctlHandlers(); diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Thread.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Thread.cpp index 9bbfbdfefa..e41fbbe0d1 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Thread.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Thread.cpp @@ -214,86 +214,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(getgroups32, getgroups, [](FEXCore::Core::CpuStateFrame *Frame, int size, gid_t list[]) -> uint64_t { - uint64_t Result = ::getgroups(size, list); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setgroups32, setgroups, [](FEXCore::Core::CpuStateFrame *Frame, size_t size, const gid_t *list) -> uint64_t { - uint64_t Result = ::setgroups(size, list); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(getuid32, getuid, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getuid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(getgid32, getgid, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getgid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setuid32, setuid, [](FEXCore::Core::CpuStateFrame *Frame, uid_t uid) -> uint64_t { - uint64_t Result = ::setuid(uid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setgid32, setgid, [](FEXCore::Core::CpuStateFrame *Frame, gid_t gid) -> uint64_t { - uint64_t Result = ::setgid(gid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(geteuid32, geteuid, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::geteuid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(getegid32, getegid, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::getegid(); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setfsuid32, setfsuid, [](FEXCore::Core::CpuStateFrame *Frame, uid_t fsuid) -> uint64_t { - uint64_t Result = ::setfsuid(fsuid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setfsgid32, setfsgid, [](FEXCore::Core::CpuStateFrame *Frame, uid_t fsgid) -> uint64_t { - uint64_t Result = ::setfsgid(fsgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setreuid32, setreuid, [](FEXCore::Core::CpuStateFrame *Frame, uid_t ruid, uid_t euid) -> uint64_t { - uint64_t Result = ::setreuid(ruid, euid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setresuid32, setresuid, [](FEXCore::Core::CpuStateFrame *Frame, uid_t ruid, uid_t euid, uid_t suid) -> uint64_t { - uint64_t Result = ::setresuid(ruid, euid, suid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(getresuid32, getresuid, [](FEXCore::Core::CpuStateFrame *Frame, uid_t *ruid, uid_t *euid, uid_t *suid) -> uint64_t { - uint64_t Result = ::getresuid(ruid, euid, suid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setresgid32, setresgid, [](FEXCore::Core::CpuStateFrame *Frame, gid_t rgid, gid_t egid, gid_t sgid) -> uint64_t { - uint64_t Result = ::setresgid(rgid, egid, sgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(getresgid32, getresgid, [](FEXCore::Core::CpuStateFrame *Frame, gid_t *rgid, gid_t *egid, gid_t *sgid) -> uint64_t { - uint64_t Result = ::getresgid(rgid, egid, sgid); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(setregid32, setregid, [](FEXCore::Core::CpuStateFrame *Frame, gid_t rgid, gid_t egid) -> uint64_t { - uint64_t Result = ::setregid(rgid, egid); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(sigaltstack, [](FEXCore::Core::CpuStateFrame *Frame, const compat_ptr ss, compat_ptr old_ss) -> uint64_t { stack_t ss64{}; stack_t old64{}; @@ -421,16 +341,5 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(futex_time64, futex, [](FEXCore::Core::CpuStateFrame *Frame, int *uaddr, int futex_op, int val, const struct timespec *timeout, int *uaddr2, uint32_t val3) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(futex), - uaddr, - futex_op, - val, - timeout, - uaddr2, - val3); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Time.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Time.cpp index 1f6b4c2667..aac4983083 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Time.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Time.cpp @@ -197,36 +197,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(clock_gettime64, clock_gettime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, timespec *tp) -> uint64_t { - uint64_t Result = ::clock_gettime(clk_id, tp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(clock_adjtime64, clock_adjtime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, struct timex *buf) -> uint64_t { - uint64_t Result = ::clock_adjtime(clk_id, buf); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(clock_settime64, clock_settime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clockid, const struct timespec *tp) -> uint64_t { - uint64_t Result = ::clock_settime(clockid, tp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(clock_getres_time64, clock_getres, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, timespec *tp) -> uint64_t { - uint64_t Result = ::clock_getres(clk_id, tp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(clock_nanosleep_time64, clock_nanosleep, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clockid, int flags, const struct timespec *request, struct timespec *remain) -> uint64_t { - uint64_t Result = ::clock_nanosleep(clockid, flags, request, remain); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(utimensat_time64, utimensat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timespec times[2], int flags) -> uint64_t { - uint64_t Result = ::utimensat(dirfd, pathname, times, flags); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(utimes, [](FEXCore::Core::CpuStateFrame *Frame, const char *filename, const timeval32 times[2]) -> uint64_t { uint64_t Result = 0; if (times) { diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Timer.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Timer.cpp index 9acac543c6..642ae43aa2 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Timer.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Timer.cpp @@ -54,16 +54,6 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(timer_settime64, timer_settime, [](FEXCore::Core::CpuStateFrame *Frame, kernel_timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_settime), timerid, flags, new_value, old_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(timer_gettime64, timer_gettime, [](FEXCore::Core::CpuStateFrame *Frame, kernel_timer_t timerid, struct itimerspec *curr_value) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_gettime), timerid, curr_value); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X32(getitimer, [](FEXCore::Core::CpuStateFrame *Frame, int which, FEX::HLE::x32::itimerval32 *curr_value) -> uint64_t { itimerval val{}; itimerval *val_p{}; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp index 8c3d64af50..df7ca38038 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp @@ -29,12 +29,12 @@ tags: LinuxSyscalls|syscalls-x86-64 namespace FEX::HLE::x64 { void RegisterFD(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(poll, [](FEXCore::Core::CpuStateFrame *Frame, struct pollfd *fds, nfds_t nfds, int timeout) -> uint64_t { + REGISTER_SYSCALL_IMPL_X64(poll, [](FEXCore::Core::CpuStateFrame *Frame, struct pollfd *fds, nfds_t nfds, int timeout) -> uint64_t { uint64_t Result = ::poll(fds, nfds, timeout); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(select, [](FEXCore::Core::CpuStateFrame *Frame, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) -> uint64_t { + REGISTER_SYSCALL_IMPL_X64(select, [](FEXCore::Core::CpuStateFrame *Frame, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) -> uint64_t { uint64_t Result = ::select(nfds, readfds, writefds, exceptfds, timeout); SYSCALL_ERRNO(); }); @@ -58,21 +58,11 @@ namespace FEX::HLE::x64 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(futimesat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timeval times[2]) -> uint64_t { + REGISTER_SYSCALL_IMPL_X64(futimesat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timeval times[2]) -> uint64_t { uint64_t Result = ::syscall(SYSCALL_DEF(futimesat), dirfd, pathname, times); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(utimensat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timespec times[2], int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(utimensat), dirfd, pathname, times, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(pselect6, [](FEXCore::Core::CpuStateFrame *Frame, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const void *sigmaskpack) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pselect6), nfds, readfds, writefds, exceptfds, timeout, sigmaskpack); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X64(stat, [](FEXCore::Core::CpuStateFrame *Frame, const char *pathname, FEX::HLE::x64::guest_stat *buf) -> uint64_t { struct stat host_stat; uint64_t Result = FEX::HLE::_SyscallHandler->FM.Stat(pathname, &host_stat); @@ -100,21 +90,6 @@ namespace FEX::HLE::x64 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(readv, [](FEXCore::Core::CpuStateFrame *Frame, int fd, const struct iovec *iov, int iovcnt) -> uint64_t { - uint64_t Result = ::readv(fd, iov, iovcnt); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(writev, [](FEXCore::Core::CpuStateFrame *Frame, int fd, const struct iovec *iov, int iovcnt) -> uint64_t { - uint64_t Result = ::writev(fd, iov, iovcnt); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(readahead, [](FEXCore::Core::CpuStateFrame *Frame, int fd, off64_t offset, size_t count) -> uint64_t { - uint64_t Result = ::readahead(fd, offset, count); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X64(newfstatat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, FEX::HLE::x64::guest_stat *buf, int flag) -> uint64_t { struct stat host_stat; uint64_t Result = FEX::HLE::_SyscallHandler->FM.NewFSStatAt(dirfd, pathname, &host_stat, flag); @@ -124,102 +99,11 @@ namespace FEX::HLE::x64 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(vmsplice, [](FEXCore::Core::CpuStateFrame *Frame, int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) -> uint64_t { - uint64_t Result = ::vmsplice(fd, iov, nr_segs, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(preadv, [](FEXCore::Core::CpuStateFrame *Frame, - int fd, - const struct iovec *iov, - uint64_t vlen, - uint64_t pos_l, - uint64_t pos_h) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(preadv), fd, iov, vlen, pos_l, pos_h); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(pwritev, [](FEXCore::Core::CpuStateFrame *Frame, - int fd, - const struct iovec *iov, - uint64_t vlen, - uint64_t pos_l, - uint64_t pos_h) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pwritev), fd, iov, vlen, pos_l, pos_h); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(preadv2, [](FEXCore::Core::CpuStateFrame *Frame, - int fd, - const struct iovec *iov, - uint64_t vlen, - uint64_t pos_l, - uint64_t pos_h, - int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(preadv2), fd, iov, vlen, pos_l, pos_h, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(pwritev2, [](FEXCore::Core::CpuStateFrame *Frame, - int fd, - const struct iovec *iov, - uint64_t vlen, - uint64_t pos_l, - uint64_t pos_h, - int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pwritev2), fd, iov, vlen, pos_l, pos_h, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(pread_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count, off_t offset) -> uint64_t { - uint64_t Result = ::pread64(fd, buf, count, offset); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(pwrite_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count, off_t offset) -> uint64_t { - uint64_t Result = ::pwrite64(fd, buf, count, offset); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(process_vm_readv, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, const struct iovec *local_iov, unsigned long liovcnt, const struct iovec *remote_iov, unsigned long riovcnt, unsigned long flags) -> uint64_t { - uint64_t Result = ::process_vm_readv(pid, local_iov, liovcnt, remote_iov, riovcnt, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(process_vm_writev, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, const struct iovec *local_iov, unsigned long liovcnt, const struct iovec *remote_iov, unsigned long riovcnt, unsigned long flags) -> uint64_t { - uint64_t Result = ::process_vm_writev(pid, local_iov, liovcnt, remote_iov, riovcnt, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(ppoll, [](FEXCore::Core::CpuStateFrame *Frame, struct pollfd *fds, nfds_t nfds, struct timespec *timeout_ts, const uint64_t *sigmask, size_t sigsetsize) -> uint64_t { - // glibc wrapper doesn't allow timeout_ts to be modified like the kernel does - int Result = ::syscall(SYSCALL_DEF(ppoll), fds, nfds, timeout_ts, sigmask, sigsetsize); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X64(getdents, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *dirp, uint32_t count) -> uint64_t { return GetDentsEmulation(fd, reinterpret_cast(dirp), count); }); - REGISTER_SYSCALL_IMPL_X64_PASS(getdents64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *dirp, uint32_t count) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(getdents64), - static_cast(fd), - reinterpret_cast(dirp), - static_cast(count)); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(sendfile, [](FEXCore::Core::CpuStateFrame *Frame, int out_fd, int in_fd, off_t *offset, size_t count) -> uint64_t { - uint64_t Result = ::sendfile(out_fd, in_fd, offset, count); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(dup, [](FEXCore::Core::CpuStateFrame *Frame, int oldfd) -> uint64_t { - uint64_t Result = ::dup(oldfd); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(dup2, [](FEXCore::Core::CpuStateFrame *Frame, int oldfd, int newfd) -> uint64_t { + REGISTER_SYSCALL_IMPL_X64(dup2, [](FEXCore::Core::CpuStateFrame *Frame, int oldfd, int newfd) -> uint64_t { uint64_t Result = ::dup2(oldfd, newfd); SYSCALL_ERRNO(); }); @@ -228,32 +112,5 @@ namespace FEX::HLE::x64 { uint64_t Result = FEX::HLE::_SyscallHandler->FM.Statfs(path, buf); SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_X64_PASS(fstatfs, [](FEXCore::Core::CpuStateFrame *Frame, int fd, struct statfs *buf) -> uint64_t { - uint64_t Result = ::fstatfs(fd, buf); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(sync_file_range, [](FEXCore::Core::CpuStateFrame *Frame, int fd, off64_t offset, off64_t nbytes, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::syscall(SYSCALL_DEF(sync_file_range), fd, offset, nbytes, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(fallocate, [](FEXCore::Core::CpuStateFrame *Frame, int fd, int mode, off_t offset, off_t len) -> uint64_t { - uint64_t Result = ::fallocate(fd, mode, offset, len); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(timerfd_settime, [](FEXCore::Core::CpuStateFrame *Frame, int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::timerfd_settime(fd, flags, new_value, old_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(timerfd_gettime, [](FEXCore::Core::CpuStateFrame *Frame, int fd, struct itimerspec *curr_value) -> uint64_t { - uint64_t Result = ::timerfd_gettime(fd, curr_value); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/IO.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/IO.cpp deleted file mode 100644 index 5859310aa1..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/IO.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-x86-64 -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" - -#include -#include -#include -#include - -namespace FEXCore::Core { - struct CpuStateFrame; -} - -namespace FEX::HLE::x64 { - void RegisterIO(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(io_getevents, [](FEXCore::Core::CpuStateFrame *Frame, aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_getevents), ctx_id, min_nr, nr, events, timeout); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(io_pgetevents, [](FEXCore::Core::CpuStateFrame *Frame, aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout, const struct io_sigset *usig) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(io_pgetevents), ctx_id, min_nr, nr, events, timeout, usig); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Info.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Info.cpp index c746044870..9af8b2534d 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Info.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Info.cpp @@ -18,28 +18,8 @@ namespace FEX::HLE::x64 { void RegisterInfo(FEX::HLE::SyscallHandler *Handler) { using namespace FEXCore::IR; - REGISTER_SYSCALL_IMPL_X64_PASS(sysinfo, [](FEXCore::Core::CpuStateFrame *Frame, struct sysinfo *info) -> uint64_t { - uint64_t Result = ::sysinfo(info); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(getrusage, [](FEXCore::Core::CpuStateFrame *Frame, int who, struct rusage *usage) -> uint64_t { - uint64_t Result = ::getrusage(who, usage); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(getrlimit, [](FEXCore::Core::CpuStateFrame *Frame, int resource, struct rlimit *rlim) -> uint64_t { - uint64_t Result = ::getrlimit(resource, rlim); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(setrlimit, [](FEXCore::Core::CpuStateFrame *Frame, int resource, const struct rlimit *rlim) -> uint64_t { - uint64_t Result = ::setrlimit(resource, rlim); - SYSCALL_ERRNO(); - }); - if (Handler->IsHostKernelVersionAtLeast(6, 6, 0)) { - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(map_shadow_stack, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, + REGISTER_SYSCALL_IMPL_X64_FLAGS(map_shadow_stack, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, uint64_t addr, uint64_t size, uint32_t flags) -> uint64_t { // Claim that shadow stack isn't supported. return -EOPNOTSUPP; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl.cpp deleted file mode 100644 index d2dc68bda5..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-x86-64 -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" - -#include -#include - -namespace FEXCore::Core { - struct CpuStateFrame; -} - -namespace FEX::HLE::x64 { - void RegisterIoctl(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(ioctl, [](FEXCore::Core::CpuStateFrame *Frame, int fd, uint64_t request, void *args) -> uint64_t { - uint64_t Result = ::ioctl(fd, request, args); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp index 99ac8dfa9e..b61a9a0f87 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Memory.cpp @@ -103,18 +103,6 @@ namespace FEX::HLE::x64 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(mlockall, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int flags) -> uint64_t { - uint64_t Result = ::mlockall(flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(munlockall, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::munlockall(); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X64_FLAGS(_shmat, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, int shmid, const void *shmaddr, int shmflg) -> uint64_t { uint64_t Result = reinterpret_cast(shmat(shmid, shmaddr, shmflg)); @@ -134,16 +122,5 @@ namespace FEX::HLE::x64 { } SYSCALL_ERRNO(); }); - - if (Handler->IsHostKernelVersionAtLeast(5, 10, 0)) { - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(process_madvise, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pidfd, const struct iovec *iovec, size_t vlen, int advice, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(process_madvise), pidfd, iovec, vlen, advice, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL_X64(process_madvise, UnimplementedSyscallSafe); - } } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Msg.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Msg.cpp deleted file mode 100644 index dd17eb70b9..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Msg.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-x86-64 -$end_info$ -*/ - -#include "LinuxSyscalls/Types.h" -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" - -#include -#include -#include -#include - -namespace FEXCore::Core { - struct CpuStateFrame; -} - -namespace FEX::HLE::x64 { - void RegisterMsg(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(mq_timedsend, [](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_timedsend), mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(mq_timedreceive, [](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_timedreceive), mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(mq_open, [](FEXCore::Core::CpuStateFrame *Frame, const char *name, int oflag, mode_t mode, struct mq_attr *attr) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_open), name, oflag, mode, attr); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(mq_notify, [](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::mqd_t mqdes, const struct sigevent *sevp) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_notify), mqdes, sevp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(mq_getsetattr, [](FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::mqd_t mqdes, struct mq_attr *newattr, struct mq_attr *oldattr) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mq_getsetattr), mqdes, newattr, oldattr); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Sched.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Sched.cpp deleted file mode 100644 index d1ef574fe1..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Sched.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-x86-64 -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" - -#include -#include -#include - -namespace FEXCore::Core { - struct CpuStateFrame; -} - -namespace FEX::HLE::x64 { - void RegisterSched(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(sched_rr_get_interval, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, struct timespec *tp) -> uint64_t { - uint64_t Result = ::sched_rr_get_interval(pid, tp); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Semaphore.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Semaphore.cpp index 415391d9fc..3acacb4a59 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Semaphore.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Semaphore.cpp @@ -23,16 +23,6 @@ ARG_TO_STR(FEX::HLE::x64::semun, "%lx") namespace FEX::HLE::x64 { void RegisterSemaphore(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(semop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(semop), semid, sops, nsops); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(semtimedop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(semtimedop), semid, sops, nsops, timeout); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X64(semctl, [](FEXCore::Core::CpuStateFrame *Frame, int semid, int semnum, int cmd, FEX::HLE::x64::semun semun) -> uint64_t { uint64_t Result{}; switch (cmd) { diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Signals.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Signals.cpp index 4c68ffb50f..85400a7000 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Signals.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Signals.cpp @@ -31,26 +31,6 @@ namespace FEX::HLE::x64 { REGISTER_SYSCALL_IMPL_X64(rt_sigtimedwait, [](FEXCore::Core::CpuStateFrame *Frame, uint64_t *set, siginfo_t *info, const struct timespec* timeout, size_t sigsetsize) -> uint64_t { return FEX::HLE::_SyscallHandler->GetSignalDelegator()->GuestSigTimedWait(set, info, timeout, sigsetsize); }); - - if (Handler->IsHostKernelVersionAtLeast(5, 1, 0)) { - REGISTER_SYSCALL_IMPL_X64_PASS(pidfd_send_signal, [](FEXCore::Core::CpuStateFrame *Frame, int pidfd, int sig, siginfo_t *info, unsigned int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pidfd_send_signal), pidfd, sig, info, flags); - SYSCALL_ERRNO(); - }); - } - else { - REGISTER_SYSCALL_IMPL_X64(pidfd_send_signal, UnimplementedSyscallSafe); - } - - REGISTER_SYSCALL_IMPL_X64_PASS(rt_sigqueueinfo, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int sig, siginfo_t *info) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(rt_sigqueueinfo), pid, sig, info); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(rt_tgsigqueueinfo, [](FEXCore::Core::CpuStateFrame *Frame, pid_t tgid, pid_t tid, int sig, siginfo_t *info) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(rt_tgsigqueueinfo), tgid, tid, sig, info); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Socket.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Socket.cpp deleted file mode 100644 index 7de85cae1b..0000000000 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Socket.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: MIT -/* -$info$ -tags: LinuxSyscalls|syscalls-x86-64 -$end_info$ -*/ - -#include "LinuxSyscalls/Syscalls.h" -#include "LinuxSyscalls/x64/Syscalls.h" - -#include -#include - -namespace FEXCore::Core { - struct CpuStateFrame; -} - -namespace FEX::HLE::x64 { - void RegisterSocket(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(accept, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct sockaddr *addr, socklen_t *addrlen) -> uint64_t { - uint64_t Result = ::accept(sockfd, addr, addrlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(recvmmsg, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct mmsghdr *msgvec, unsigned int vlen, int flags, struct timespec *timeout) -> uint64_t { - uint64_t Result = ::recvmmsg(sockfd, msgvec, vlen, flags, timeout); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(sendmmsg, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct mmsghdr *msgvec, uint32_t vlen, int flags) -> uint64_t { - uint64_t Result = ::sendmmsg(sockfd, msgvec, vlen, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(sendmsg, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, const struct msghdr *msg, int flags) -> uint64_t { - uint64_t Result = ::sendmsg(sockfd, msg, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(recvmsg, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, struct msghdr *msg, int flags) -> uint64_t { - uint64_t Result = ::recvmsg(sockfd, msg, flags); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(setsockopt, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, int level, int optname, const void *optval, socklen_t optlen) -> uint64_t { - uint64_t Result = ::setsockopt(sockfd, level, optname, optval, optlen); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(getsockopt, [](FEXCore::Core::CpuStateFrame *Frame, int sockfd, int level, int optname, void *optval, socklen_t *optlen) -> uint64_t { - uint64_t Result = ::getsockopt(sockfd, level, optname, optval, optlen); - SYSCALL_ERRNO(); - }); - } -} diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Syscalls.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Syscalls.cpp index 1b24c4ff5d..64f58588c3 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Syscalls.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Syscalls.cpp @@ -15,17 +15,13 @@ namespace FEX::HLE::x64 { void RegisterEpoll(FEX::HLE::SyscallHandler *Handler); void RegisterFD(FEX::HLE::SyscallHandler *Handler); void RegisterInfo(FEX::HLE::SyscallHandler *Handler); - void RegisterIO(FEX::HLE::SyscallHandler *Handler); - void RegisterIoctl(FEX::HLE::SyscallHandler *Handler); void RegisterMemory(FEX::HLE::SyscallHandler *Handler); - void RegisterMsg(FEX::HLE::SyscallHandler *Handler); - void RegisterSched(FEX::HLE::SyscallHandler *Handler); - void RegisterSocket(FEX::HLE::SyscallHandler *Handler); void RegisterSemaphore(FEX::HLE::SyscallHandler *Handler); void RegisterSignals(FEX::HLE::SyscallHandler *Handler); void RegisterThread(FEX::HLE::SyscallHandler *Handler); void RegisterTime(FEX::HLE::SyscallHandler *Handler); void RegisterNotImplemented(FEX::HLE::SyscallHandler *Handler); + void RegisterPassthrough(FEX::HLE::SyscallHandler *Handler); x64SyscallHandler::x64SyscallHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation) : SyscallHandler {ctx, _SignalDelegation} { @@ -54,18 +50,9 @@ namespace FEX::HLE::x64 { FEX::HLE::RegisterFS(this); FEX::HLE::RegisterInfo(this); FEX::HLE::RegisterIO(this); - FEX::HLE::RegisterIOUring(this); - FEX::HLE::RegisterKey(this); FEX::HLE::RegisterMemory(this); - FEX::HLE::RegisterMsg(this); - FEX::HLE::RegisterNamespace(this); - FEX::HLE::RegisterSched(this); - FEX::HLE::RegisterSemaphore(this); - FEX::HLE::RegisterSHM(this); FEX::HLE::RegisterSignals(this); - FEX::HLE::RegisterSocket(this); FEX::HLE::RegisterThread(this); - FEX::HLE::RegisterTime(this); FEX::HLE::RegisterTimer(this); FEX::HLE::RegisterNotImplemented(this); FEX::HLE::RegisterStubs(this); @@ -74,17 +61,13 @@ namespace FEX::HLE::x64 { FEX::HLE::x64::RegisterEpoll(this); FEX::HLE::x64::RegisterFD(this); FEX::HLE::x64::RegisterInfo(this); - FEX::HLE::x64::RegisterIO(this); - FEX::HLE::x64::RegisterIoctl(this); FEX::HLE::x64::RegisterMemory(this); - FEX::HLE::x64::RegisterMsg(this); - FEX::HLE::x64::RegisterSched(this); - FEX::HLE::x64::RegisterSocket(this); FEX::HLE::x64::RegisterSemaphore(this); FEX::HLE::x64::RegisterSignals(this); FEX::HLE::x64::RegisterThread(this); FEX::HLE::x64::RegisterTime(this); FEX::HLE::x64::RegisterNotImplemented(this); + FEX::HLE::x64::RegisterPassthrough(this); // x86-64 has a gap of syscalls in the range of [335, 424) where there aren't any // These are defined that these must return -ENOSYS diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Thread.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Thread.cpp index 1947d2da34..a650a36cc8 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Thread.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Thread.cpp @@ -57,40 +57,6 @@ namespace FEX::HLE::x64 { return CloneHandler(Frame, &args); })); - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(futex, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int *uaddr, int futex_op, int val, const struct timespec *timeout, int *uaddr2, uint32_t val3) -> uint64_t { - uint64_t Result = syscall(SYSCALL_DEF(futex), - uaddr, - futex_op, - val, - timeout, - uaddr2, - val3); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_FLAGS(set_robust_list, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, struct robust_list_head *head, size_t len) -> uint64_t { - auto Thread = Frame->Thread; - Thread->ThreadManager.robust_list_head = reinterpret_cast(head); -#ifdef TERMUX_BUILD - // Termux/Android doesn't support `set_robust_list` syscall. - // The seccomp filter that the OS installs explicitly blocks this syscall from working - // glibc uses this syscall for tls and thread data so almost every application uses it - // Return success since we have stored the pointer ourselves. - return 0; -#else - uint64_t Result = ::syscall(SYSCALL_DEF(set_robust_list), head, len); - SYSCALL_ERRNO(); -#endif - }); - - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(get_robust_list, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int pid, struct robust_list_head **head, size_t *len_ptr) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(get_robust_list), pid, head, len_ptr); - SYSCALL_ERRNO(); - }); - REGISTER_SYSCALL_IMPL_X64(sigaltstack, [](FEXCore::Core::CpuStateFrame *Frame, const stack_t *ss, stack_t *old_ss) -> uint64_t { return FEX::HLE::_SyscallHandler->GetSignalDelegator()->RegisterGuestSigAltStack(ss, old_ss); }); @@ -156,17 +122,5 @@ namespace FEX::HLE::x64 { auto* const* EnvpPtr = envp ? const_cast(Envp.data()) : nullptr; return FEX::HLE::ExecveHandler(pathname, ArgsPtr, EnvpPtr, AtArgs); })); - - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(wait4, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int *wstatus, int options, struct rusage *rusage) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(wait4), pid, wstatus, options, rusage); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(waitid, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - [](FEXCore::Core::CpuStateFrame *Frame, int which, pid_t upid, siginfo_t *infop, int options, struct rusage *rusage) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(waitid), which, upid, infop, options, rusage); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Time.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Time.cpp index 4df537c678..0a76700dee 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Time.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Time.cpp @@ -21,95 +21,21 @@ tags: LinuxSyscalls|syscalls-x86-64 namespace FEX::HLE::x64 { void RegisterTime(FEX::HLE::SyscallHandler *Handler) { - REGISTER_SYSCALL_IMPL_X64_PASS(time, [](FEXCore::Core::CpuStateFrame *Frame, time_t *tloc) -> uint64_t { + using namespace FEXCore::IR; + REGISTER_SYSCALL_IMPL_X64_FLAGS(time, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, [](FEXCore::Core::CpuStateFrame *Frame, time_t *tloc) -> uint64_t { uint64_t Result = ::time(tloc); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(times, [](FEXCore::Core::CpuStateFrame *Frame, struct tms *buf) -> uint64_t { - uint64_t Result = ::times(buf); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(utime, [](FEXCore::Core::CpuStateFrame *Frame, char* filename, const struct utimbuf* times) -> uint64_t { + REGISTER_SYSCALL_IMPL_X64(utime, [](FEXCore::Core::CpuStateFrame *Frame, char* filename, const struct utimbuf* times) -> uint64_t { uint64_t Result = ::utime(filename, times); SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X64_PASS(gettimeofday, [](FEXCore::Core::CpuStateFrame *Frame, struct timeval *tv, struct timezone *tz) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(gettimeofday), tv, tz); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(nanosleep, [](FEXCore::Core::CpuStateFrame *Frame, const struct timespec *req, struct timespec *rem) -> uint64_t { - uint64_t Result = ::nanosleep(req, rem); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(clock_gettime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, struct timespec *tp) -> uint64_t { - uint64_t Result = ::clock_gettime(clk_id, tp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(clock_getres, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, struct timespec *tp) -> uint64_t { - uint64_t Result = ::clock_getres(clk_id, tp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(clock_nanosleep, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clockid, int flags, const struct timespec *request, struct timespec *remain) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(clock_nanosleep), clockid, flags, request, remain); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(clock_settime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clockid, const struct timespec *tp) -> uint64_t { - uint64_t Result = ::clock_settime(clockid, tp); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(settimeofday, [](FEXCore::Core::CpuStateFrame *Frame, const struct timeval *tv, const struct timezone *tz) -> uint64_t { - uint64_t Result = ::settimeofday(tv, tz); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(utimes, [](FEXCore::Core::CpuStateFrame *Frame, const char *filename, const struct timeval times[2]) -> uint64_t { + REGISTER_SYSCALL_IMPL_X64(utimes, [](FEXCore::Core::CpuStateFrame *Frame, const char *filename, const struct timeval times[2]) -> uint64_t { uint64_t Result = ::utimes(filename, times); SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL_X64_PASS(getitimer, [](FEXCore::Core::CpuStateFrame *Frame, int which, struct itimerval *curr_value) -> uint64_t { - uint64_t Result = ::getitimer(which, curr_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(setitimer, [](FEXCore::Core::CpuStateFrame *Frame, int which, const struct itimerval *new_value, struct itimerval *old_value) -> uint64_t { - uint64_t Result = ::setitimer(which, new_value, old_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(timer_settime, [](FEXCore::Core::CpuStateFrame *Frame, kernel_timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_settime), timerid, flags, new_value, old_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(timer_gettime, [](FEXCore::Core::CpuStateFrame *Frame, kernel_timer_t timerid, struct itimerspec *curr_value) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_gettime), timerid, curr_value); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(adjtimex, [](FEXCore::Core::CpuStateFrame *Frame, struct timex *buf) -> uint64_t { - uint64_t Result = ::adjtimex(buf); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(clock_adjtime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, struct timex *buf) -> uint64_t { - uint64_t Result = ::clock_adjtime(clk_id, buf); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL_X64_PASS(timer_create, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clockid, struct sigevent *sevp, kernel_timer_t *timerid) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(timer_create), clockid, sevp, timerid); - SYSCALL_ERRNO(); - }); } }