From ddecec12ec6af5975414199e9fdd9ef6a615af52 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 16 Sep 2020 09:50:42 -0700 Subject: [PATCH] Spam out a wackload more syscalls Almost all of these end up being simple passthrough. This covers most syscalls, the remaining ones are signal related, exec related, or rseq required. All of these syscalls exist prior to Linux 5.0. We are using these with the expectation still that the host Linux implementation is 5.0 or higher. Once we implement newer syscalls we will need to start checking for host Linux version. We don't really have a care about devices shipping older 4.x kernels atm. --- External/FEXCore/Source/CMakeLists.txt | 2 + .../Source/Interface/HLE/Syscalls/FD.cpp | 123 +++++- .../Source/Interface/HLE/Syscalls/FS.cpp | 66 +++ .../Source/Interface/HLE/Syscalls/IO.cpp | 53 ++- .../Source/Interface/HLE/Syscalls/Info.cpp | 48 ++- .../Source/Interface/HLE/Syscalls/Key.cpp | 47 +++ .../Source/Interface/HLE/Syscalls/Memory.cpp | 21 + .../Source/Interface/HLE/Syscalls/Msg.cpp | 68 +++ .../Interface/HLE/Syscalls/NotImplemented.cpp | 29 +- .../Source/Interface/HLE/Syscalls/Signals.cpp | 7 + .../Source/Interface/HLE/Syscalls/Socket.cpp | 8 +- .../Source/Interface/HLE/Syscalls/Stubs.cpp | 395 ------------------ .../Source/Interface/HLE/Syscalls/Thread.cpp | 34 +- .../Source/Interface/HLE/Syscalls/Time.cpp | 44 ++ .../Source/Interface/HLE/x64/Syscalls.cpp | 4 + unittests/POSIX/Known_Failures | 4 - 16 files changed, 540 insertions(+), 413 deletions(-) create mode 100644 External/FEXCore/Source/Interface/HLE/Syscalls/Key.cpp create mode 100644 External/FEXCore/Source/Interface/HLE/Syscalls/Msg.cpp diff --git a/External/FEXCore/Source/CMakeLists.txt b/External/FEXCore/Source/CMakeLists.txt index 40ab49b62..94aaabe73 100644 --- a/External/FEXCore/Source/CMakeLists.txt +++ b/External/FEXCore/Source/CMakeLists.txt @@ -153,7 +153,9 @@ set (SRCS Interface/HLE/Syscalls/Info.cpp Interface/HLE/Syscalls/IO.cpp Interface/HLE/Syscalls/Ioctl.cpp + Interface/HLE/Syscalls/Key.cpp Interface/HLE/Syscalls/Memory.cpp + Interface/HLE/Syscalls/Msg.cpp Interface/HLE/Syscalls/Sched.cpp Interface/HLE/Syscalls/Semaphore.cpp Interface/HLE/Syscalls/SHM.cpp diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/FD.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/FD.cpp index 9bc1ada77..7eee77110 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/FD.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/FD.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include namespace FEXCore::HLE { static void CopyStat(FEXCore::guest_stat *guest, struct stat *host) { @@ -185,6 +187,11 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(sendfile, [](FEXCore::Core::InternalThreadState *Thread, 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(dup3, [](FEXCore::Core::InternalThreadState* Thread, int oldfd, int newfd, int flags) -> uint64_t { flags = RemapFlags(flags); uint64_t Result = ::dup3(oldfd, newfd, flags); @@ -239,6 +246,11 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(readahead, [](FEXCore::Core::InternalThreadState *Thread, int fd, off64_t offset, size_t count) -> uint64_t { + uint64_t Result = ::readahead(fd, offset, count); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(getdents64, [](FEXCore::Core::InternalThreadState *Thread, int fd, void *dirp, uint32_t count) -> uint64_t { uint64_t Result = syscall(SYS_getdents64, static_cast(fd), @@ -273,6 +285,26 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(mkdirat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode) -> uint64_t { + uint64_t Result = ::mkdirat(dirfd, pathname, mode); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mknodat, [](FEXCore::Core::InternalThreadState *Thread, 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(fchownat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, uid_t owner, gid_t group, int flags) -> uint64_t { + uint64_t Result = ::fchownat(dirfd, pathname, owner, group, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(futimesat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, const struct timeval times[2]) -> uint64_t { + uint64_t Result = ::futimesat(dirfd, pathname, times); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(newfstatat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, FEXCore::guest_stat *buf, int flag) -> uint64_t { struct stat host_stat; uint64_t Result = ::fstatat(dirfd, pathname, &host_stat, flag); @@ -282,16 +314,66 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(unlinkat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, int flags) -> uint64_t { + uint64_t Result = ::unlinkat(dirfd, pathname, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(renameat, [](FEXCore::Core::InternalThreadState *Thread, 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(linkat, [](FEXCore::Core::InternalThreadState *Thread, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) -> uint64_t { + uint64_t Result = ::linkat(olddirfd, oldpath, newdirfd, newpath, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(symlinkat, [](FEXCore::Core::InternalThreadState *Thread, const char *target, int newdirfd, const char *linkpath) -> uint64_t { + uint64_t Result = ::symlinkat(target, newdirfd, linkpath); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(readlinkat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, char *buf, size_t bufsiz) -> uint64_t { uint64_t Result = Thread->CTX->SyscallHandler->FM.Readlinkat(dirfd, pathname, buf, bufsiz); SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(fchmodat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode, int flags) -> uint64_t { + uint64_t Result = fchmodat(dirfd, pathname, mode, flags); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(faccessat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, int mode, int flags) -> uint64_t { uint64_t Result = Thread->CTX->SyscallHandler->FM.FAccessat(dirfd, pathname, mode, flags); SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(splice, [](FEXCore::Core::InternalThreadState *Thread, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { + uint64_t Result = ::splice(fd_in, off_in, fd_out, off_out, len, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(tee, [](FEXCore::Core::InternalThreadState *Thread, int fd_in, int fd_out, size_t len, unsigned int flags) -> uint64_t { + uint64_t Result = ::tee(fd_in, fd_out, len, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(sync_file_range, [](FEXCore::Core::InternalThreadState *Thread, int fd, off64_t offset, off64_t nbytes, unsigned int flags) -> uint64_t { + uint64_t Result = ::sync_file_range(fd, offset, nbytes, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(vmsplice, [](FEXCore::Core::InternalThreadState *Thread, 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(utimensat, [](FEXCore::Core::InternalThreadState *Thread, 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(timerfd_create, [](FEXCore::Core::InternalThreadState *Thread, int32_t clockid, int32_t flags) -> uint64_t { uint64_t Result = ::timerfd_create(clockid, flags); SYSCALL_ERRNO(); @@ -324,6 +406,11 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(renameat2, [](FEXCore::Core::InternalThreadState *Thread, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags) -> uint64_t { + uint64_t Result = ::renameat2(olddirfd, oldpath, newdirfd, newpath, flags); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(memfd_create, [](FEXCore::Core::InternalThreadState *Thread, const char *name, uint32_t flags) -> uint64_t { uint64_t Result = ::memfd_create(name, flags); SYSCALL_ERRNO(); @@ -358,8 +445,42 @@ namespace FEXCore::HLE { }); REGISTER_SYSCALL_IMPL(eventfd2, [](FEXCore::Core::InternalThreadState *Thread, unsigned int initval, int flags) -> uint64_t { - uint64_t Result = eventfd(initval, flags); + uint64_t Result = ::eventfd(initval, flags); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(preadv, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset) -> uint64_t { + uint64_t Result = ::preadv(fd, iov, iovcnt, offset); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(pwritev, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset) -> uint64_t { + uint64_t Result = ::pwritev(fd, iov, iovcnt, offset); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(preadv2, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) -> uint64_t { + uint64_t Result = ::preadv2(fd, iov, iovcnt, offset, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(pwritev2, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) -> uint64_t { + uint64_t Result = ::pwritev2(fd, iov, iovcnt, offset, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(process_vm_readv, [](FEXCore::Core::InternalThreadState *Thread, 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(process_vm_writev, [](FEXCore::Core::InternalThreadState *Thread, 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(copy_file_range, [](FEXCore::Core::InternalThreadState *Thread, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { + uint64_t Result = ::copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); SYSCALL_ERRNO(); }); } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/FS.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/FS.cpp index 8cc94c1d9..2181c3dbd 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/FS.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/FS.cpp @@ -4,6 +4,9 @@ #include #include +#include +#include +#include #include #include #include @@ -83,6 +86,29 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(ustat, [](FEXCore::Core::InternalThreadState *Thread, dev_t dev, struct ustat *ubuf) -> uint64_t { + // Since version 2.28 of GLIBC it has stopped providing a wrapper for this syscall +#ifdef SYS_ustat + uint64_t Result = syscall(SYS_ustat, dev, ubuf); + SYSCALL_ERRNO(); +#else + return -ENOSYS; +#endif + }); + + /* + arg1 is one of: void, unsigned int fs_index, const char *fsname + arg2 is one of: void, char *buf + */ + REGISTER_SYSCALL_IMPL(sysfs, [](FEXCore::Core::InternalThreadState *Thread, int option, uint64_t arg1, uint64_t arg2) -> uint64_t { +#ifdef SYS_sysfs + uint64_t Result = syscall(SYS_sysfs, option, arg1, arg2); + SYSCALL_ERRNO(); +#else + return -ENOSYS; +#endif + }); + REGISTER_SYSCALL_IMPL(statfs, [](FEXCore::Core::InternalThreadState *Thread, const char *path, struct statfs *buf) -> uint64_t { uint64_t Result = Thread->CTX->SyscallHandler->FM.Statfs(path, buf); SYSCALL_ERRNO(); @@ -103,11 +129,42 @@ namespace FEXCore::HLE { });*/ REGISTER_SYSCALL_FORWARD_ERRNO(creat); + REGISTER_SYSCALL_IMPL(chroot, [](FEXCore::Core::InternalThreadState *Thread, const char *path) -> uint64_t { + uint64_t Result = ::chroot(path); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(sync, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { sync(); return 0; // always successful }); + REGISTER_SYSCALL_IMPL(acct, [](FEXCore::Core::InternalThreadState *Thread, const char *filename) -> uint64_t { + uint64_t Result = ::acct(filename); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mount, [](FEXCore::Core::InternalThreadState *Thread, 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(umount2, [](FEXCore::Core::InternalThreadState *Thread, const char *target, int flags) -> uint64_t { + uint64_t Result = ::umount2(target, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(swapon, [](FEXCore::Core::InternalThreadState *Thread, const char *path, int swapflags) -> uint64_t { + uint64_t Result = ::swapon(path, swapflags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(swapoff, [](FEXCore::Core::InternalThreadState *Thread, const char *path) -> uint64_t { + uint64_t Result = ::swapoff(path); + SYSCALL_ERRNO(); + }); + + /* REGISTER_SYSCALL_IMPL(syncfs, [](FEXCore::Core::InternalThreadState *Thread, int fd) -> uint64_t { SYSCALL_STUB(syncfs); @@ -186,5 +243,14 @@ namespace FEXCore::HLE { });*/ REGISTER_SYSCALL_FORWARD_ERRNO(fremovexattr); + REGISTER_SYSCALL_IMPL(fanotify_init, [](FEXCore::Core::InternalThreadState *Thread, unsigned int flags, unsigned int event_f_flags) -> uint64_t { + uint64_t Result = ::fanotify_init(flags, event_f_flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(fanotify_mark, [](FEXCore::Core::InternalThreadState *Thread, int fanotify_fd, unsigned int flags, uint64_t mask, int dirfd, const char *pathname) -> uint64_t { + uint64_t Result = ::fanotify_mark(fanotify_fd, flags, mask, dirfd, pathname); + SYSCALL_ERRNO(); + }); } } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/IO.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/IO.cpp index dc03ec85d..cb4096bca 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/IO.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/IO.cpp @@ -1,6 +1,10 @@ #include "Interface/HLE/Syscalls.h" #include "Interface/HLE/x64/Syscalls.h" +#include +#include +#include + namespace FEXCore::Core { struct InternalThreadState; } @@ -8,9 +12,54 @@ struct InternalThreadState; namespace FEXCore::HLE { void RegisterIO() { + REGISTER_SYSCALL_IMPL(iopl, [](FEXCore::Core::InternalThreadState *Thread, int level) -> uint64_t { + // Just claim we don't have permission + return -EPERM; + }); + REGISTER_SYSCALL_IMPL(ioperm, [](FEXCore::Core::InternalThreadState *Thread, unsigned long from, unsigned long num, int turn_on) -> uint64_t { - // ioperm not available on our architecture - return -EPERM; + // ioperm not available on our architecture + return -EPERM; + }); + + REGISTER_SYSCALL_IMPL(io_setup, [](FEXCore::Core::InternalThreadState *Thread, unsigned nr_events, aio_context_t *ctx_idp) -> uint64_t { + uint64_t Result = ::syscall(SYS_io_setup, nr_events, ctx_idp); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(io_destroy, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id) -> uint64_t { + uint64_t Result = ::syscall(SYS_io_destroy, ctx_id); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(io_getevents, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout) -> uint64_t { + uint64_t Result = ::syscall(SYS_io_getevents, ctx_id, min_nr, nr, events, timeout); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(io_submit, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, long nr, struct iocb **iocbpp) -> uint64_t { + uint64_t Result = ::syscall(SYS_io_submit, ctx_id, nr, iocbpp); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(io_cancel, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, struct iocb *iocb, struct io_event *result) -> uint64_t { + uint64_t Result = ::syscall(SYS_io_cancel, ctx_id, iocb, result); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(ioprio_set, [](FEXCore::Core::InternalThreadState *Thread, int which, int who) -> uint64_t { + uint64_t Result = ::syscall(SYS_ioprio_set, which, who); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(ioprio_get, [](FEXCore::Core::InternalThreadState *Thread, int which, int who, int ioprio) -> uint64_t { + uint64_t Result = ::syscall(SYS_ioprio_get, which, who, ioprio); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(io_pgetevents, [](FEXCore::Core::InternalThreadState *Thread, 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(SYS_io_pgetevents, ctx_id, min_nr, nr, events, timeout); + SYSCALL_ERRNO(); }); } } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Info.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Info.cpp index 29bbf1843..6b7eb479f 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Info.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Info.cpp @@ -1,7 +1,10 @@ +#include "Interface/Context/Context.h" #include "Interface/HLE/Syscalls.h" #include "Interface/HLE/x64/Syscalls.h" #include +#include +#include #include #include #include @@ -9,16 +12,15 @@ #include #include #include +#include #include #include #include +#include #ifndef FEXCORE_VERSION #define FEXCORE_VERSION "1" #endif -namespace FEXCore::Core { -struct InternalThreadState; -} namespace FEXCore::HLE { @@ -32,6 +34,16 @@ namespace FEXCore::HLE { return 0; }); + REGISTER_SYSCALL_IMPL(getrlimit, [](FEXCore::Core::InternalThreadState *Thread, int resource, struct rlimit *rlim) -> uint64_t { + uint64_t Result = ::getrlimit(resource, rlim); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(setrlimit, [](FEXCore::Core::InternalThreadState *Thread, int resource, const struct rlimit *rlim) -> uint64_t { + uint64_t Result = ::setrlimit(resource, rlim); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(getrusage, [](FEXCore::Core::InternalThreadState *Thread, int who, struct rusage *usage) -> uint64_t { uint64_t Result = ::getrusage(who, usage); SYSCALL_ERRNO(); @@ -61,5 +73,35 @@ namespace FEXCore::HLE { uint64_t Result = ::capset(hdrp, datap); SYSCALL_ERRNO(); }); + + REGISTER_SYSCALL_IMPL(getcpu, [](FEXCore::Core::InternalThreadState *Thread, unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) -> uint64_t { + uint32_t LocalCPU{}; + uint32_t LocalNode{}; + // tcache is ignored + uint64_t Result = ::syscall(SYS_getcpu, cpu ? &LocalCPU : nullptr, node ? &LocalNode : nullptr, nullptr); + if (Result == 0) { + if (cpu) { + // Ensure we don't return a number over our number of emulated cores + *cpu = LocalCPU % Thread->CTX->Config.EmulatedCPUCores; + } + + if (node) { + // Just claim we are part of node zero + *node = 0; + } + } + SYSCALL_ERRNO(); + }); + + //compare two processes to determine if they share a kernel resource + REGISTER_SYSCALL_IMPL(kcmp, [](FEXCore::Core::InternalThreadState *Thread, pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) -> uint64_t { + uint64_t Result = ::syscall(SYS_kcmp, pid1, pid2, type, idx1, idx2); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(seccomp, [](FEXCore::Core::InternalThreadState *Thread, unsigned int operation, unsigned int flags, void *args) -> uint64_t { + uint64_t Result = ::syscall(SYS_seccomp, operation, flags, args); + SYSCALL_ERRNO(); + }); } } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Key.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Key.cpp new file mode 100644 index 000000000..0abffd92f --- /dev/null +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Key.cpp @@ -0,0 +1,47 @@ +#include "Interface/HLE/Syscalls.h" +#include "Interface/HLE/x64/Syscalls.h" + +#include +#include +#include + +namespace FEXCore::Core { +struct InternalThreadState; +} + +namespace FEXCore::HLE { + void RegisterKey() { + REGISTER_SYSCALL_IMPL(add_key, [](FEXCore::Core::InternalThreadState *Thread, const char *type, const char *description, const void *payload, size_t plen, int32_t /*key_serial_t*/ keyring) -> uint64_t { + uint64_t Result = syscall(SYS_add_key, type, description, payload, plen, keyring); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(request_key, [](FEXCore::Core::InternalThreadState *Thread, const char *type, const char *description, const char *callout_info, int32_t /*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(keyctl, [](FEXCore::Core::InternalThreadState *Thread, 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(pkey_mprotect, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t len, int prot, int pkey) -> uint64_t { + // Added in Linux 4.9 + uint64_t Result = ::pkey_mprotect(addr, len, prot, pkey); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(pkey_alloc, [](FEXCore::Core::InternalThreadState *Thread, unsigned int flags, unsigned int access_rights) -> uint64_t { + // Added in Linux 4.9 + uint64_t Result = ::pkey_alloc(flags, access_rights); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(pkey_free, [](FEXCore::Core::InternalThreadState *Thread, int pkey) -> uint64_t { + // Added in Linux 4.9 + uint64_t Result = ::pkey_free(pkey); + SYSCALL_ERRNO(); + }); + } +} diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Memory.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Memory.cpp index 98a4c50bf..75bae8941 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Memory.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Memory.cpp @@ -87,6 +87,17 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(remap_file_pages, [](FEXCore::Core::InternalThreadState *Thread, 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 = ::remap_file_pages(addr, size, prot, pgoff, flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mbind, [](FEXCore::Core::InternalThreadState *Thread, void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags) -> uint64_t { + uint64_t Result = ::mbind(addr, len, mode, nodemask, maxnode, flags); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(get_mempolicy, [](FEXCore::Core::InternalThreadState *Thread, int *mode, unsigned long *nodemask, unsigned long maxnode, void *addr, unsigned long flags) -> uint64_t { uint64_t Result = ::get_mempolicy(mode, nodemask, maxnode, addr, flags); SYSCALL_ERRNO(); @@ -97,6 +108,16 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(migrate_pages, [](FEXCore::Core::InternalThreadState *Thread, int pid, unsigned long maxnode, const unsigned long *old_nodes, const unsigned long *new_nodes) -> uint64_t { + uint64_t Result = ::migrate_pages(pid, maxnode, old_nodes, new_nodes); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(move_pages, [](FEXCore::Core::InternalThreadState *Thread, int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags) -> uint64_t { + uint64_t Result = ::move_pages(pid, count, pages, nodes, status, flags); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(membarrier, [](FEXCore::Core::InternalThreadState *Thread, int cmd, int flags) -> uint64_t { uint64_t Result = syscall(SYS_membarrier, cmd, flags); SYSCALL_ERRNO(); diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Msg.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Msg.cpp new file mode 100644 index 000000000..abb385267 --- /dev/null +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Msg.cpp @@ -0,0 +1,68 @@ +#include "Interface/HLE/Syscalls.h" +#include "Interface/HLE/x64/Syscalls.h" + +#include +#include +#include +#include +#include +#include + +namespace FEXCore::Core { +struct InternalThreadState; +} + +namespace FEXCore::HLE { + void RegisterMsg() { + REGISTER_SYSCALL_IMPL(msgget, [](FEXCore::Core::InternalThreadState *Thread, key_t key, int msgflg) -> uint64_t { + uint64_t Result = ::msgget(key, msgflg); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(msgsnd, [](FEXCore::Core::InternalThreadState *Thread, int msqid, const void *msgp, size_t msgsz, int msgflg) -> uint64_t { + uint64_t Result = ::msgsnd(msqid, msgp, msgsz, msgflg); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(msgrcv, [](FEXCore::Core::InternalThreadState *Thread, int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) -> uint64_t { + uint64_t Result = ::msgrcv(msqid, msgp, msgsz, msgtyp, msgflg); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(msgctl, [](FEXCore::Core::InternalThreadState *Thread, int msqid, int cmd, struct msqid_ds *buf) -> uint64_t { + uint64_t Result = ::msgctl(msqid, cmd, buf); + SYSCALL_ERRNO(); + }); + + // last two parameters are optional + REGISTER_SYSCALL_IMPL(mq_open, [](FEXCore::Core::InternalThreadState *Thread, const char *name, int oflag, mode_t mode, struct mq_attr *attr) -> uint64_t { + uint64_t Result = ::mq_open(name, oflag, mode, attr); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mq_unlink, [](FEXCore::Core::InternalThreadState *Thread, const char *name) -> uint64_t { + uint64_t Result = ::mq_unlink(name); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mq_timedsend, [](FEXCore::Core::InternalThreadState *Thread, 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 = ::mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mq_timedreceive, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) -> uint64_t { + uint64_t Result = ::mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mq_notify, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, const struct sigevent *sevp) -> uint64_t { + uint64_t Result = ::mq_notify(mqdes, sevp); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(mq_getsetattr, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, struct mq_attr *newattr, struct mq_attr *oldattr) -> uint64_t { + uint64_t Result = ::syscall(SYS_mq_getsetattr, mqdes, newattr, oldattr); + SYSCALL_ERRNO(); + }); + } +} diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/NotImplemented.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/NotImplemented.cpp index 29efca796..5d7355b7d 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/NotImplemented.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/NotImplemented.cpp @@ -14,6 +14,14 @@ struct InternalThreadState; return -ENOSYS; \ }); +#define REGISTER_SYSCALL_NO_PERM(name) REGISTER_SYSCALL_IMPL(name, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { \ + return -EPERM; \ +}); + +#define REGISTER_SYSCALL_NO_ACCESS(name) REGISTER_SYSCALL_IMPL(name, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { \ + return -EACCES; \ +}); + namespace FEXCore::HLE { // these are removed/not implemented in the linux kernel we present @@ -23,7 +31,7 @@ namespace FEXCore::HLE { REGISTER_SYSCALL_NOT_IMPL(create_module); REGISTER_SYSCALL_NOT_IMPL(get_kernel_syms); REGISTER_SYSCALL_NOT_IMPL(query_module); - REGISTER_SYSCALL_NOT_IMPL(nfsservctl); + REGISTER_SYSCALL_NOT_IMPL(nfsservctl); // Was removed in Linux 3.1 REGISTER_SYSCALL_NOT_IMPL(getpmsg); REGISTER_SYSCALL_NOT_IMPL(putpmsg); REGISTER_SYSCALL_NOT_IMPL(afs_syscall); @@ -34,6 +42,21 @@ namespace FEXCore::HLE { REGISTER_SYSCALL_NOT_IMPL(epoll_ctl_old); REGISTER_SYSCALL_NOT_IMPL(epoll_wait_old); REGISTER_SYSCALL_NOT_IMPL(vserver); - REGISTER_SYSCALL_NOT_IMPL(_sysctl); + REGISTER_SYSCALL_NOT_IMPL(_sysctl); // Was removed in Linux 5.5 + + REGISTER_SYSCALL_NO_PERM(vhangup); + REGISTER_SYSCALL_NO_PERM(pivot_root); + REGISTER_SYSCALL_NO_PERM(reboot) + REGISTER_SYSCALL_NO_PERM(sethostname); + REGISTER_SYSCALL_NO_PERM(setdomainname); + REGISTER_SYSCALL_NO_PERM(kexec_load); + REGISTER_SYSCALL_NO_PERM(kexec_file_load); + REGISTER_SYSCALL_NO_PERM(finit_module); + REGISTER_SYSCALL_NO_PERM(bpf); + REGISTER_SYSCALL_NO_PERM(lookup_dcookie); + REGISTER_SYSCALL_NO_PERM(init_module) + REGISTER_SYSCALL_NO_PERM(delete_module); + REGISTER_SYSCALL_NO_PERM(quotactl); + REGISTER_SYSCALL_NO_ACCESS(perf_event_open); } -} \ No newline at end of file +} diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Signals.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Signals.cpp index 0ba819691..1c66f31b3 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Signals.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Signals.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include namespace FEXCore::HLE { @@ -29,5 +31,10 @@ namespace FEXCore::HLE { REGISTER_SYSCALL_IMPL(rt_sigsuspend, [](FEXCore::Core::InternalThreadState *Thread, uint64_t *unewset, size_t sigsetsize) -> uint64_t { return Thread->CTX->SignalDelegation.GuestSigSuspend(unewset, sigsetsize); }); + + REGISTER_SYSCALL_IMPL(userfaultfd, [](FEXCore::Core::InternalThreadState *Thread, int flags) -> uint64_t { + uint64_t Result = ::syscall(SYS_userfaultfd, flags); + SYSCALL_ERRNO(); + }); } } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Socket.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Socket.cpp index 5d5971c10..0891cd786 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Socket.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Socket.cpp @@ -12,7 +12,7 @@ struct InternalThreadState; namespace FEXCore::HLE { void RegisterSocket() { - + REGISTER_SYSCALL_IMPL(socket, [](FEXCore::Core::InternalThreadState *Thread, int domain, int type, int protocol) -> uint64_t { uint64_t Result = ::socket(domain, type, protocol); SYSCALL_ERRNO(); @@ -93,9 +93,15 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(recvmmsg, [](FEXCore::Core::InternalThreadState *Thread, 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(sendmmsg, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, struct mmsghdr *msgvec, uint32_t vlen, int flags) -> uint64_t { uint64_t Result = ::sendmmsg(sockfd, msgvec, vlen, flags); SYSCALL_ERRNO(); }); + } } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Stubs.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Stubs.cpp index 17b9b5968..925cace34 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Stubs.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Stubs.cpp @@ -34,52 +34,10 @@ namespace FEXCore::HLE { SYSCALL_STUB(rt_sigreturn); }); - REGISTER_SYSCALL_IMPL(pause, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { - SYSCALL_STUB(pause); - }); - - REGISTER_SYSCALL_IMPL(sendfile, [](FEXCore::Core::InternalThreadState *Thread, int out_fd, int in_fd, off_t *offset, size_t count) -> uint64_t { - SYSCALL_STUB(sendfile); - }); - - REGISTER_SYSCALL_IMPL(msgget, [](FEXCore::Core::InternalThreadState *Thread, key_t key, int msgflg) -> uint64_t { - SYSCALL_STUB(msgget); - }); - - REGISTER_SYSCALL_IMPL(msgsnd, [](FEXCore::Core::InternalThreadState *Thread, int msqid, const void *msgp, size_t msgsz, int msgflg) -> uint64_t { - SYSCALL_STUB(msgsnd); - }); - - REGISTER_SYSCALL_IMPL(msgrcv, [](FEXCore::Core::InternalThreadState *Thread, int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) -> uint64_t { - SYSCALL_STUB(msgrcv); - }); - - REGISTER_SYSCALL_IMPL(msgctl, [](FEXCore::Core::InternalThreadState *Thread, int msqid, int cmd, struct msqid_ds *buf) -> uint64_t { - SYSCALL_STUB(msgctl); - }); - - REGISTER_SYSCALL_IMPL(getrlimit, [](FEXCore::Core::InternalThreadState *Thread, int resource, struct rlimit *rlim) -> uint64_t { - SYSCALL_STUB(getrlimit); - }); - - REGISTER_SYSCALL_IMPL(times, [](FEXCore::Core::InternalThreadState *Thread, struct tms *buf) -> uint64_t { - SYSCALL_STUB(times); - }); - REGISTER_SYSCALL_IMPL(ptrace, [](FEXCore::Core::InternalThreadState *Thread, int /*enum __ptrace_request*/ request, pid_t pid, void *addr, void *data) -> uint64_t { SYSCALL_STUB(ptrace); }); - - - REGISTER_SYSCALL_IMPL(getgroups, [](FEXCore::Core::InternalThreadState *Thread, int size, gid_t list[]) -> uint64_t { - SYSCALL_STUB(getgroups); - }); - - REGISTER_SYSCALL_IMPL(setgroups, [](FEXCore::Core::InternalThreadState *Thread, size_t size, const gid_t *list) -> uint64_t { - SYSCALL_STUB(setgroups); - }); - REGISTER_SYSCALL_IMPL(rt_sigtimedwait, [](FEXCore::Core::InternalThreadState *Thread, sigset_t *set, const struct timespec*, size_t sigsetsize) -> uint64_t { SYSCALL_STUB(rt_sigtimedwait); }); @@ -87,267 +45,15 @@ namespace FEXCore::HLE { REGISTER_SYSCALL_IMPL(rt_sigqueueinfo, [](FEXCore::Core::InternalThreadState *Thread, pid_t pid, int sig, siginfo_t *uinfo) -> uint64_t { SYSCALL_STUB(rt_sigqueueinfo); }); - REGISTER_SYSCALL_IMPL(utime, [](FEXCore::Core::InternalThreadState *Thread, char* filename, const struct utimbuf* times) -> uint64_t { - SYSCALL_STUB(utime); - }); - - REGISTER_SYSCALL_IMPL(ustat, [](FEXCore::Core::InternalThreadState *Thread, dev_t dev, struct ustat *ubuf) -> uint64_t { - SYSCALL_STUB(ustat); - }); - - /* - arg1 is one of: void, unsigned int fs_index, const char *fsname - arg2 is one of: void, char *buf - */ - REGISTER_SYSCALL_IMPL(sysfs, [](FEXCore::Core::InternalThreadState *Thread, int option, uint64_t arg1, uint64_t arg2) -> uint64_t { - SYSCALL_STUB(sysfs); - }); - - REGISTER_SYSCALL_IMPL(vhangup, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { - SYSCALL_STUB(vhangup); - }); REGISTER_SYSCALL_IMPL(modify_ldt, [](FEXCore::Core::InternalThreadState *Thread, int func, void *ptr, unsigned long bytecount) -> uint64_t { SYSCALL_STUB(modify_ldt); }); - REGISTER_SYSCALL_IMPL(pivot_root, [](FEXCore::Core::InternalThreadState *Thread, const char *new_root, const char *put_old) -> uint64_t { - SYSCALL_STUB(pivot_root); - }); - - REGISTER_SYSCALL_IMPL(adjtimex, [](FEXCore::Core::InternalThreadState *Thread, struct timex *buf) -> uint64_t { - SYSCALL_STUB(adjtimex); - }); - - REGISTER_SYSCALL_IMPL(setrlimit, [](FEXCore::Core::InternalThreadState *Thread, int resource, const struct rlimit *rlim) -> uint64_t { - SYSCALL_STUB(setrlimit); - }); - - REGISTER_SYSCALL_IMPL(chroot, [](FEXCore::Core::InternalThreadState *Thread, const char *path) -> uint64_t { - SYSCALL_STUB(chroot); - }); - - REGISTER_SYSCALL_IMPL(acct, [](FEXCore::Core::InternalThreadState *Thread, const char *filename) -> uint64_t { - SYSCALL_STUB(acct); - }); - - REGISTER_SYSCALL_IMPL(settimeofday, [](FEXCore::Core::InternalThreadState *Thread, const struct timeval *tv, const struct timezone *tz) -> uint64_t { - SYSCALL_STUB(settimeofday); - }); - - REGISTER_SYSCALL_IMPL(mount, [](FEXCore::Core::InternalThreadState *Thread, const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data) -> uint64_t { - SYSCALL_STUB(mount); - }); - - REGISTER_SYSCALL_IMPL(umount2, [](FEXCore::Core::InternalThreadState *Thread, const char *target, int flags) -> uint64_t { - SYSCALL_STUB(umount2); - }); - - REGISTER_SYSCALL_IMPL(swapon, [](FEXCore::Core::InternalThreadState *Thread, const char *path, int swapflags) -> uint64_t { - SYSCALL_STUB(swapon); - }); - - REGISTER_SYSCALL_IMPL(swapoff, [](FEXCore::Core::InternalThreadState *Thread, const char *path) -> uint64_t { - SYSCALL_STUB(swapoff); - }); - - REGISTER_SYSCALL_IMPL(reboot, [](FEXCore::Core::InternalThreadState *Thread, int magic, int magic2, int cmd, void *arg) -> uint64_t { - SYSCALL_STUB(reboot); - }); - - REGISTER_SYSCALL_IMPL(sethostname, [](FEXCore::Core::InternalThreadState *Thread, const char *name, size_t len) -> uint64_t { - SYSCALL_STUB(sethostname); - }); - - REGISTER_SYSCALL_IMPL(setdomainname, [](FEXCore::Core::InternalThreadState *Thread, const char *name, size_t len) -> uint64_t { - SYSCALL_STUB(setdomainname); - }); - - REGISTER_SYSCALL_IMPL(iopl, [](FEXCore::Core::InternalThreadState *Thread, int level) -> uint64_t { - SYSCALL_STUB(iopl); - }); - - REGISTER_SYSCALL_IMPL(init_module, [](FEXCore::Core::InternalThreadState *Thread, void *module_image, unsigned long len, const char *param_values) -> uint64_t { - SYSCALL_STUB(init_module); - }); - - REGISTER_SYSCALL_IMPL(delete_module, [](FEXCore::Core::InternalThreadState *Thread, const char *name, int flags) -> uint64_t { - SYSCALL_STUB(delete_module); - }); - - REGISTER_SYSCALL_IMPL(quotactl, [](FEXCore::Core::InternalThreadState *Thread, int cmd, const char *special, int id, caddr_t addr) -> uint64_t { - SYSCALL_STUB(quotactl); - }); - - REGISTER_SYSCALL_IMPL(readahead, [](FEXCore::Core::InternalThreadState *Thread, int fd, off64_t offset, size_t count) -> uint64_t { - SYSCALL_STUB(readahead); - }); - - REGISTER_SYSCALL_IMPL(io_setup, [](FEXCore::Core::InternalThreadState *Thread, unsigned nr_events, aio_context_t *ctx_idp) -> uint64_t { - SYSCALL_STUB(io_setup); - }); - - REGISTER_SYSCALL_IMPL(io_destroy, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id) -> uint64_t { - SYSCALL_STUB(io_destroy); - }); - - REGISTER_SYSCALL_IMPL(io_getevents, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout) -> uint64_t { - SYSCALL_STUB(io_getevents); - }); - - REGISTER_SYSCALL_IMPL(io_submit, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, long nr, struct iocb **iocbpp) -> uint64_t { - SYSCALL_STUB(io_submit); - }); - - REGISTER_SYSCALL_IMPL(io_cancel, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, struct iocb *iocb, struct io_event *result) -> uint64_t { - SYSCALL_STUB(io_cancel); - }); - - REGISTER_SYSCALL_IMPL(lookup_dcookie, [](FEXCore::Core::InternalThreadState *Thread, uint64_t cookie, char *buffer, size_t len) -> uint64_t { - SYSCALL_STUB(lookup_dcookie); - }); - - REGISTER_SYSCALL_IMPL(remap_file_pages, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t size, int prot, size_t pgoff, int flags) -> uint64_t { - SYSCALL_STUB(remap_file_pages); - }); - REGISTER_SYSCALL_IMPL(restart_syscall, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { SYSCALL_STUB(restart_syscall); }); - REGISTER_SYSCALL_IMPL(clock_settime, [](FEXCore::Core::InternalThreadState *Thread, clockid_t clockid, const struct timespec *tp) -> uint64_t { - SYSCALL_STUB(clock_settime); - }); - - REGISTER_SYSCALL_IMPL(utimes, [](FEXCore::Core::InternalThreadState *Thread, const char *filename, const struct timeval times[2]) -> uint64_t { - SYSCALL_STUB(utimes); - }); - - REGISTER_SYSCALL_IMPL(mbind, [](FEXCore::Core::InternalThreadState *Thread, void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags) -> uint64_t { - SYSCALL_STUB(mbind); - }); - - // last two parameters are optional - REGISTER_SYSCALL_IMPL(mq_open, [](FEXCore::Core::InternalThreadState *Thread, const char *name, int oflag, mode_t mode, struct mq_attr *attr) -> uint64_t { - SYSCALL_STUB(mq_open); - }); - - REGISTER_SYSCALL_IMPL(mq_unlink, [](FEXCore::Core::InternalThreadState *Thread, const char *name) -> uint64_t { - SYSCALL_STUB(mq_unlink); - }); - - REGISTER_SYSCALL_IMPL(mq_timedsend, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) -> uint64_t { - SYSCALL_STUB(mq_timedsend); - }); - - REGISTER_SYSCALL_IMPL(mq_timedreceive, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) -> uint64_t { - SYSCALL_STUB(mq_timedreceive); - }); - - REGISTER_SYSCALL_IMPL(mq_notify, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, const struct sigevent *sevp) -> uint64_t { - SYSCALL_STUB(mq_notify); - }); - - REGISTER_SYSCALL_IMPL(mq_getsetattr, [](FEXCore::Core::InternalThreadState *Thread, mqd_t mqdes, struct mq_attr *newattr, struct mq_attr *oldattr) -> uint64_t { - SYSCALL_STUB(mq_getsetattr); - }); - - REGISTER_SYSCALL_IMPL(kexec_load, [](FEXCore::Core::InternalThreadState *Thread, unsigned long entry, unsigned long nr_segments, struct kexec_segment *segments, unsigned long flags) -> uint64_t { - SYSCALL_STUB(kexec_load); - }); - - REGISTER_SYSCALL_IMPL(waitid, [](FEXCore::Core::InternalThreadState *Thread, int /*idtype_t*/ idtype, id_t id, siginfo_t *infop, int options) -> uint64_t { - SYSCALL_STUB(waitid); - }); - - REGISTER_SYSCALL_IMPL(add_key, [](FEXCore::Core::InternalThreadState *Thread, const char *type, const char *description, const void *payload, size_t plen, int32_t /*key_serial_t*/ keyring) -> uint64_t { - SYSCALL_STUB(add_key); - }); - - REGISTER_SYSCALL_IMPL(request_key, [](FEXCore::Core::InternalThreadState *Thread, const char *type, const char *description, const char *callout_info, int32_t /*key_serial_t*/ dest_keyring) -> uint64_t { - SYSCALL_STUB(request_key); - }); - - REGISTER_SYSCALL_IMPL(keyctl, [](FEXCore::Core::InternalThreadState *Thread, int operation, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) -> uint64_t { - SYSCALL_STUB(keyctl); - }); - - REGISTER_SYSCALL_IMPL(ioprio_set, [](FEXCore::Core::InternalThreadState *Thread, int which, int who) -> uint64_t { - SYSCALL_STUB(ioprio_set); - }); - - REGISTER_SYSCALL_IMPL(ioprio_get, [](FEXCore::Core::InternalThreadState *Thread, int which, int who, int ioprio) -> uint64_t { - SYSCALL_STUB(ioprio_get); - }); - - REGISTER_SYSCALL_IMPL(migrate_pages, [](FEXCore::Core::InternalThreadState *Thread, int pid, unsigned long maxnode, const unsigned long *old_nodes, const unsigned long *new_nodes) -> uint64_t { - SYSCALL_STUB(migrate_pages); - }); - - REGISTER_SYSCALL_IMPL(mkdirat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode) -> uint64_t { - SYSCALL_STUB(mkdirat); - }); - - REGISTER_SYSCALL_IMPL(mknodat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode, dev_t dev) -> uint64_t { - SYSCALL_STUB(mknodat); - }); - - REGISTER_SYSCALL_IMPL(fchownat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, uid_t owner, gid_t group, int flags) -> uint64_t { - SYSCALL_STUB(fchownat); - }); - - REGISTER_SYSCALL_IMPL(futimesat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, const struct timeval times[2]) -> uint64_t { - SYSCALL_STUB(futimesat); - }); - - REGISTER_SYSCALL_IMPL(unlinkat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, int flags) -> uint64_t { - SYSCALL_STUB(unlinkat); - }); - - REGISTER_SYSCALL_IMPL(renameat, [](FEXCore::Core::InternalThreadState *Thread, int olddirfd, const char *oldpath, int newdirfd, const char *newpath) -> uint64_t { - SYSCALL_STUB(renameat); - }); - - REGISTER_SYSCALL_IMPL(linkat, [](FEXCore::Core::InternalThreadState *Thread, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) -> uint64_t { - SYSCALL_STUB(linkat); - }); - - REGISTER_SYSCALL_IMPL(symlinkat, [](FEXCore::Core::InternalThreadState *Thread, const char *target, int newdirfd, const char *linkpath) -> uint64_t { - SYSCALL_STUB(symlinkat); - }); - - REGISTER_SYSCALL_IMPL(fchmodat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode, int flags) -> uint64_t { - SYSCALL_STUB(fchmodat); - }); - - REGISTER_SYSCALL_IMPL(unshare, [](FEXCore::Core::InternalThreadState *Thread, int flags) -> uint64_t { - SYSCALL_STUB(unshare); - }); - - REGISTER_SYSCALL_IMPL(splice, [](FEXCore::Core::InternalThreadState *Thread, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { - SYSCALL_STUB(splice); - }); - - REGISTER_SYSCALL_IMPL(tee, [](FEXCore::Core::InternalThreadState *Thread, int fd_in, int fd_out, size_t len, unsigned int flags) -> uint64_t { - SYSCALL_STUB(tee); - }); - - REGISTER_SYSCALL_IMPL(sync_file_range, [](FEXCore::Core::InternalThreadState *Thread, int fd, off64_t offset, off64_t nbytes, unsigned int flags) -> uint64_t { - SYSCALL_STUB(sync_file_range); - }); - - REGISTER_SYSCALL_IMPL(vmsplice, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) -> uint64_t { - SYSCALL_STUB(vmsplice); - }); - - REGISTER_SYSCALL_IMPL(move_pages, [](FEXCore::Core::InternalThreadState *Thread, int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags) -> uint64_t { - SYSCALL_STUB(move_pages); - }); - - REGISTER_SYSCALL_IMPL(utimensat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, const struct timespec times[2], int flags) -> uint64_t { - SYSCALL_STUB(utimensat); - }); - REGISTER_SYSCALL_IMPL(signalfd, [](FEXCore::Core::InternalThreadState *Thread, int fd, const sigset_t *mask, size_t sizemask) -> uint64_t { SYSCALL_STUB(signalfd); }); @@ -356,116 +62,15 @@ namespace FEXCore::HLE { SYSCALL_STUB(signalfd4); }); - REGISTER_SYSCALL_IMPL(preadv, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset) -> uint64_t { - SYSCALL_STUB(preadv); - }); - - REGISTER_SYSCALL_IMPL(pwritev, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset) -> uint64_t { - SYSCALL_STUB(pwritev); - }); - REGISTER_SYSCALL_IMPL(rt_tgsigqueueinfo, [](FEXCore::Core::InternalThreadState *Thread, pid_t tgid, pid_t tid, int sig, siginfo_t *info) -> uint64_t { SYSCALL_STUB(rt_tgsigqueueinfo); }); - REGISTER_SYSCALL_IMPL(perf_event_open, [](FEXCore::Core::InternalThreadState *Thread, struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags) -> uint64_t { - SYSCALL_STUB(perf_event_open); - }); - - REGISTER_SYSCALL_IMPL(recvmmsg, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, struct mmsghdr *msgvec, unsigned int vlen, int flags, struct timespec *timeout) -> uint64_t { - SYSCALL_STUB(recvmmsg); - }); - - REGISTER_SYSCALL_IMPL(fanotify_init, [](FEXCore::Core::InternalThreadState *Thread, unsigned int flags, unsigned int event_f_flags) -> uint64_t { - SYSCALL_STUB(fanotify_init); - }); - - REGISTER_SYSCALL_IMPL(fanotify_mark, [](FEXCore::Core::InternalThreadState *Thread, int fanotify_fd, unsigned int flags, uint64_t mask, int dirfd, const char *pathname) -> uint64_t { - SYSCALL_STUB(fanotify_mark); - }); - - REGISTER_SYSCALL_IMPL(clock_adjtime, [](FEXCore::Core::InternalThreadState *Thread, clockid_t clk_id, struct timex *buf) -> uint64_t { - SYSCALL_STUB(clock_adjtime); - }); - - REGISTER_SYSCALL_IMPL(setns, [](FEXCore::Core::InternalThreadState *Thread, int fd, int nstype) -> uint64_t { - SYSCALL_STUB(setns); - }); - - REGISTER_SYSCALL_IMPL(getcpu, [](FEXCore::Core::InternalThreadState *Thread, unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) -> uint64_t { - SYSCALL_STUB(getcpu); - }); - - REGISTER_SYSCALL_IMPL(process_vm_readv, [](FEXCore::Core::InternalThreadState *Thread, pid_t pid, const struct iovec *local_iov, unsigned long liovcnt, const struct iovec *remote_iov, unsigned long riovcnt, unsigned long flags) -> uint64_t { - SYSCALL_STUB(process_vm_readv); - }); - - REGISTER_SYSCALL_IMPL(process_vm_writev, [](FEXCore::Core::InternalThreadState *Thread, pid_t pid, const struct iovec *local_iov, unsigned long liovcnt, const struct iovec *remote_iov, unsigned long riovcnt, unsigned long flags) -> uint64_t { - SYSCALL_STUB(process_vm_writev); - }); - - //compare two processes to determine if they share a kernel resource - REGISTER_SYSCALL_IMPL(kcmp, [](FEXCore::Core::InternalThreadState *Thread, pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) -> uint64_t { - SYSCALL_STUB(kcmp); - }); - - REGISTER_SYSCALL_IMPL(finit_module, [](FEXCore::Core::InternalThreadState *Thread, int fd, const char *param_values, int flags) -> uint64_t { - SYSCALL_STUB(finit_module); - }); - - REGISTER_SYSCALL_IMPL(renameat2, [](FEXCore::Core::InternalThreadState *Thread, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags) -> uint64_t { - SYSCALL_STUB(renameat2); - }); - - REGISTER_SYSCALL_IMPL(seccomp, [](FEXCore::Core::InternalThreadState *Thread, unsigned int operation, unsigned int flags, void *args) -> uint64_t { - SYSCALL_STUB(seccomp); - }); - - REGISTER_SYSCALL_IMPL(kexec_file_load, [](FEXCore::Core::InternalThreadState *Thread, int kernel_fd, int initrd_fd, unsigned long cmdline_len, const char *cmdline, unsigned long flags) -> uint64_t { - SYSCALL_STUB(kexec_file_load); - }); - - REGISTER_SYSCALL_IMPL(bpf, [](FEXCore::Core::InternalThreadState *Thread, int cmd, union bpf_attr *attr, unsigned int size) -> uint64_t { - SYSCALL_STUB(bpf); - }); - // execute program relative to a directory file descriptor REGISTER_SYSCALL_IMPL(execveat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, char *const argv[], char *const envp[], int flags) -> uint64_t { SYSCALL_STUB(execveat); }); - REGISTER_SYSCALL_IMPL(userfaultfd, [](FEXCore::Core::InternalThreadState *Thread, int flags) -> uint64_t { - SYSCALL_STUB(userfaultfd); - }); - - REGISTER_SYSCALL_IMPL(copy_file_range, [](FEXCore::Core::InternalThreadState *Thread, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { - SYSCALL_STUB(copy_file_range); - }); - - REGISTER_SYSCALL_IMPL(preadv2, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) -> uint64_t { - SYSCALL_STUB(preadv2); - }); - - REGISTER_SYSCALL_IMPL(pwritev2, [](FEXCore::Core::InternalThreadState *Thread, int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) -> uint64_t { - SYSCALL_STUB(pwritev2); - }); - - REGISTER_SYSCALL_IMPL(pkey_mprotect, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t len, int prot, int pkey) -> uint64_t { - SYSCALL_STUB(pkey_mprotect); - }); - - REGISTER_SYSCALL_IMPL(pkey_alloc, [](FEXCore::Core::InternalThreadState *Thread, unsigned int flags, unsigned int access_rights) -> uint64_t { - SYSCALL_STUB(pkey_alloc); - }); - - REGISTER_SYSCALL_IMPL(pkey_free, [](FEXCore::Core::InternalThreadState *Thread, int pkey) -> uint64_t { - SYSCALL_STUB(pkey_free); - }); - - REGISTER_SYSCALL_IMPL(io_pgetevents, [](FEXCore::Core::InternalThreadState *Thread, aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout, const struct io_sigset *usig) -> uint64_t { - SYSCALL_STUB(io_pgetevents); - }); - REGISTER_SYSCALL_IMPL(rseq, [](FEXCore::Core::InternalThreadState *Thread, struct rseq *rseq, uint32_t rseq_len, int flags, uint32_t sig) -> uint64_t { SYSCALL_STUB(rseq); }); diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Thread.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Thread.cpp index d8c0e798f..0059b698c 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Thread.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Thread.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -185,7 +186,7 @@ namespace FEXCore::HLE { } if (!(flags & CLONE_THREAD)) { - + if (flags & CLONE_VFORK) { flags &= ~CLONE_VFORK; flags &= ~CLONE_VM; @@ -252,7 +253,7 @@ namespace FEXCore::HLE { // currently does not propagate argv[0] correctly REGISTER_SYSCALL_IMPL(execve, [](FEXCore::Core::InternalThreadState *Thread, const char *pathname, char *const argv[], char *const envp[]) -> uint64_t { std::vector Args; - + Thread->CTX->GetCodeLoader()->GetExecveArguments(&Args); Args.push_back("--"); @@ -269,7 +270,7 @@ namespace FEXCore::HLE { Args.push_back(nullptr); uint64_t Result = execve("/proc/self/exe", const_cast(&Args[0]), envp); - + SYSCALL_ERRNO(); }); @@ -367,6 +368,16 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(getgroups, [](FEXCore::Core::InternalThreadState *Thread, int size, gid_t list[]) -> uint64_t { + uint64_t Result = ::getgroups(size, list); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(setgroups, [](FEXCore::Core::InternalThreadState *Thread, size_t size, const gid_t *list) -> uint64_t { + uint64_t Result = ::setgroups(size, list); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(setresuid, [](FEXCore::Core::InternalThreadState *Thread, uid_t ruid, uid_t euid, uid_t suid) -> uint64_t { uint64_t Result = ::setresuid(ruid, euid, suid); SYSCALL_ERRNO(); @@ -476,7 +487,7 @@ namespace FEXCore::HLE { SYSCALL_STUB(setpgid); });*/ REGISTER_SYSCALL_FORWARD_ERRNO(setpgid); - + /*REGISTER_SYSCALL_IMPL(getpgid, [](FEXCore::Core::InternalThreadState *Thread, pid_t pid) -> uint64_t { SYSCALL_STUB(getpgid); });*/ @@ -496,5 +507,20 @@ namespace FEXCore::HLE { SYSCALL_STUB(getsid); });*/ REGISTER_SYSCALL_FORWARD_ERRNO(getsid); + + REGISTER_SYSCALL_IMPL(waitid, [](FEXCore::Core::InternalThreadState *Thread, idtype_t idtype, id_t id, siginfo_t *infop, int options) -> uint64_t { + uint64_t Result = ::waitid(idtype, id, infop, options); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(unshare, [](FEXCore::Core::InternalThreadState *Thread, int flags) -> uint64_t { + uint64_t Result = ::unshare(flags); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(setns, [](FEXCore::Core::InternalThreadState *Thread, int fd, int nstype) -> uint64_t { + uint64_t Result = ::setns(fd, nstype); + SYSCALL_ERRNO(); + }); } } diff --git a/External/FEXCore/Source/Interface/HLE/Syscalls/Time.cpp b/External/FEXCore/Source/Interface/HLE/Syscalls/Time.cpp index 9c5971880..f444081f5 100644 --- a/External/FEXCore/Source/Interface/HLE/Syscalls/Time.cpp +++ b/External/FEXCore/Source/Interface/HLE/Syscalls/Time.cpp @@ -5,6 +5,10 @@ #include #include #include +#include +#include +#include +#include namespace FEXCore::Core { struct InternalThreadState; @@ -12,6 +16,11 @@ struct InternalThreadState; namespace FEXCore::HLE { void RegisterTime() { + REGISTER_SYSCALL_IMPL(pause, [](FEXCore::Core::InternalThreadState *Thread) -> uint64_t { + uint64_t Result = ::pause(); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(nanosleep, [](FEXCore::Core::InternalThreadState *Thread, const struct timespec *req, struct timespec *rem) -> uint64_t { uint64_t Result = ::nanosleep(req, rem); SYSCALL_ERRNO(); @@ -37,9 +46,44 @@ namespace FEXCore::HLE { SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL(times, [](FEXCore::Core::InternalThreadState *Thread, struct tms *buf) -> uint64_t { + uint64_t Result = ::times(buf); + SYSCALL_ERRNO(); + }); + REGISTER_SYSCALL_IMPL(clock_nanosleep, [](FEXCore::Core::InternalThreadState *Thread, 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(utime, [](FEXCore::Core::InternalThreadState *Thread, char* filename, const struct utimbuf* times) -> uint64_t { + uint64_t Result = ::utime(filename, times); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(adjtimex, [](FEXCore::Core::InternalThreadState *Thread, struct timex *buf) -> uint64_t { + uint64_t Result = ::adjtimex(buf); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(settimeofday, [](FEXCore::Core::InternalThreadState *Thread, const struct timeval *tv, const struct timezone *tz) -> uint64_t { + uint64_t Result = ::settimeofday(tv, tz); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(clock_settime, [](FEXCore::Core::InternalThreadState *Thread, clockid_t clockid, const struct timespec *tp) -> uint64_t { + uint64_t Result = ::clock_settime(clockid, tp); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(utimes, [](FEXCore::Core::InternalThreadState *Thread, const char *filename, const struct timeval times[2]) -> uint64_t { + uint64_t Result = ::utimes(filename, times); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL(clock_adjtime, [](FEXCore::Core::InternalThreadState *Thread, clockid_t clk_id, struct timex *buf) -> uint64_t { + uint64_t Result = ::clock_adjtime(clk_id, buf); + SYSCALL_ERRNO(); + }); } } diff --git a/External/FEXCore/Source/Interface/HLE/x64/Syscalls.cpp b/External/FEXCore/Source/Interface/HLE/x64/Syscalls.cpp index bf423c5b5..a87e3c2e7 100644 --- a/External/FEXCore/Source/Interface/HLE/x64/Syscalls.cpp +++ b/External/FEXCore/Source/Interface/HLE/x64/Syscalls.cpp @@ -12,7 +12,9 @@ namespace FEXCore::HLE { void RegisterInfo(); void RegisterIO(); void RegisterIoctl(); + void RegisterKey(); void RegisterMemory(); + void RegisterMsg(); void RegisterNuma(); void RegisterSched(); void RegisterSemaphore(); @@ -134,7 +136,9 @@ namespace FEXCore::HLE::x64 { RegisterInfo(); RegisterIO(); RegisterIoctl(); + RegisterKey(); RegisterMemory(); + RegisterMsg(); RegisterSched(); RegisterSemaphore(); RegisterSHM(); diff --git a/unittests/POSIX/Known_Failures b/unittests/POSIX/Known_Failures index 9f9cfd344..028fdb080 100644 --- a/unittests/POSIX/Known_Failures +++ b/unittests/POSIX/Known_Failures @@ -2,10 +2,6 @@ conformance-interfaces-clock-1-1.test conformance-interfaces-clock_getcpuclockid-2-1.test conformance-interfaces-clock_nanosleep-11-1.test conformance-interfaces-clock_nanosleep-13-1.test -conformance-interfaces-clock_settime-17-1.test -conformance-interfaces-clock_settime-17-2.test -conformance-interfaces-clock_settime-20-1.test -conformance-interfaces-clock_settime-6-1.test conformance-interfaces-mlockall-8-1.test conformance-interfaces-munmap-2-1.test conformance-interfaces-nanosleep-10000-1.test