Skip to content

Commit

Permalink
Merge pull request #3489 from Sonicadvance1/linux_v6.8
Browse files Browse the repository at this point in the history
Linux: Expose support for v6.8
  • Loading branch information
Sonicadvance1 authored Mar 11, 2024
2 parents c37a12e + d820233 commit e33a76a
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 5 deletions.
10 changes: 9 additions & 1 deletion Source/Tools/LinuxEmulation/LinuxSyscalls/Arm64/SyscallsEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ enum Syscalls_Arm64 {
SYSCALL_Arm64_set_mempolicy_home_node = 450,
SYSCALL_Arm64_cachestat = 451,
SYSCALL_Arm64_fchmodat2 = 452,
SYSCALL_Arm64_map_shadow_stack = 453,
SYSCALL_Arm64_futex_wake = 454,
SYSCALL_Arm64_futex_wait = 455,
SYSCALL_Arm64_futex_requeue = 456,
SYSCALL_Arm64_statmount = 457,
SYSCALL_Arm64_listmount = 458,
SYSCALL_Arm64_lsm_get_self_attr = 459,
SYSCALL_Arm64_lsm_set_self_attr = 460,
SYSCALL_Arm64_lsm_list_modules = 461,
SYSCALL_Arm64_MAX = 512,

// Unsupported syscalls on this host
Expand Down Expand Up @@ -466,6 +475,5 @@ enum Syscalls_Arm64 {
SYSCALL_Arm64_epoll_ctl_old = ~0,
SYSCALL_Arm64_epoll_wait_old = ~0,
SYSCALL_Arm64_newfstatat = ~0,
SYSCALL_Arm64_map_shadow_stack = ~0,
};
}
4 changes: 2 additions & 2 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,8 @@ uint32_t SyscallHandler::CalculateHostKernelVersion() {
}

uint32_t SyscallHandler::CalculateGuestKernelVersion() {
// We currently only emulate a kernel between the ranges of Kernel 5.0.0 and 6.6.0
return std::max(KernelVersion(5, 0), std::min(KernelVersion(6, 6), GetHostKernelVersion()));
// We currently only emulate a kernel between the ranges of Kernel 5.0.0 and 6.8.0
return std::max(KernelVersion(5, 0), std::min(KernelVersion(6, 8), GetHostKernelVersion()));
}

uint64_t SyscallHandler::HandleSyscall(FEXCore::Core::CpuStateFrame *Frame, FEXCore::HLE::SyscallArguments *Args) {
Expand Down
29 changes: 29 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,35 @@ uint64_t SyscallPassthrough7(FEXCore::Core::CpuStateFrame *Frame, uint64_t arg1,
else {
REGISTER_SYSCALL_IMPL(set_mempolicy_home_node, UnimplementedSyscallSafe);
}

if (Handler->IsHostKernelVersionAtLeast(6, 8, 0)) {
REGISTER_SYSCALL_IMPL_PASS_FLAGS(futex_wake, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough4<SYSCALL_DEF(futex_wake)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(futex_wait, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough6<SYSCALL_DEF(futex_wait)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(futex_requeue, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough4<SYSCALL_DEF(futex_requeue)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(statmount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough4<SYSCALL_DEF(statmount)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(listmount, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough4<SYSCALL_DEF(listmount)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(lsm_get_self_attr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough4<SYSCALL_DEF(lsm_get_self_attr)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(lsm_set_self_attr, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough4<SYSCALL_DEF(lsm_set_self_attr)>);
REGISTER_SYSCALL_IMPL_PASS_FLAGS(lsm_list_modules, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
SyscallPassthrough3<SYSCALL_DEF(lsm_list_modules)>);
}
else {
REGISTER_SYSCALL_IMPL(futex_wake, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(futex_wait, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(futex_requeue, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(statmount, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(listmount, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(lsm_get_self_attr, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(lsm_set_self_attr, UnimplementedSyscallSafe);
REGISTER_SYSCALL_IMPL(lsm_list_modules, UnimplementedSyscallSafe);
}
}

namespace x64 {
Expand Down
11 changes: 11 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,16 @@ namespace FEX::HLE::x32 {
*usage = usage64;
SYSCALL_ERRNO();
});

if (Handler->IsHostKernelVersionAtLeast(6, 8, 0)) {
REGISTER_SYSCALL_IMPL_X32(map_shadow_stack,
[](FEXCore::Core::CpuStateFrame *Frame, uint64_t addr, uint64_t size, uint32_t flags) -> uint64_t {
// Claim that shadow stack isn't supported.
return -EOPNOTSUPP;
});
}
else {
REGISTER_SYSCALL_IMPL_X32(map_shadow_stack, UnimplementedSyscallSafe);
}
}
}
5 changes: 4 additions & 1 deletion Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ extern "C" {
#include "fex-drm/radeon_drm.h"
#include "fex-drm/vc4_drm.h"
#include "fex-drm/v3d_drm.h"
#include "fex-drm/pvr_drm.h"
#include "fex-drm/virtgpu_drm.h"
#include "fex-drm/xe_drm.h"
}
#include <sys/ioctl.h>

Expand Down Expand Up @@ -1422,7 +1424,8 @@ fex_drm_v3d_submit_csd {
#include "LinuxSyscalls/x32/Ioctl/radeon_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/vc4_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/v3d_drm.inl"

#include "LinuxSyscalls/x32/Ioctl/pvr_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/xe_drm.inl"
}
#undef CPYT
#undef CPYF
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ _BASIC_META(DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL)

_CUSTOM_META(DRM_IOCTL_MODE_GETFB2, DRM_IOWR(0xCE, FEX::HLE::x32::DRM::fex_drm_mode_fb_cmd2))
_BASIC_META(DRM_IOCTL_SYNCOBJ_EVENTFD)
_BASIC_META(DRM_IOCTL_MODE_CLOSEFB)
14 changes: 14 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/pvr_drm.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_BASIC_META(DRM_IOCTL_PVR_DEV_QUERY)
_BASIC_META(DRM_IOCTL_PVR_CREATE_BO)
_BASIC_META(DRM_IOCTL_PVR_GET_BO_MMAP_OFFSET)
_BASIC_META(DRM_IOCTL_PVR_CREATE_VM_CONTEXT)
_BASIC_META(DRM_IOCTL_PVR_DESTROY_VM_CONTEXT)
_BASIC_META(DRM_IOCTL_PVR_VM_MAP)
_BASIC_META(DRM_IOCTL_PVR_VM_UNMAP)
_BASIC_META(DRM_IOCTL_PVR_CREATE_CONTEXT)
_BASIC_META(DRM_IOCTL_PVR_DESTROY_CONTEXT)
_BASIC_META(DRM_IOCTL_PVR_CREATE_FREE_LIST)
_BASIC_META(DRM_IOCTL_PVR_DESTROY_FREE_LIST)
_BASIC_META(DRM_IOCTL_PVR_CREATE_HWRT_DATASET)
_BASIC_META(DRM_IOCTL_PVR_DESTROY_HWRT_DATASET)
_BASIC_META(DRM_IOCTL_PVR_SUBMIT_JOBS)
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ _CUSTOM_META(DRM_IOCTL_V3D_SUBMIT_CSD, DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT
_BASIC_META(DRM_IOCTL_V3D_PERFMON_CREATE)
_BASIC_META(DRM_IOCTL_V3D_PERFMON_DESTROY)
_BASIC_META(DRM_IOCTL_V3D_PERFMON_GET_VALUES)
_BASIC_META(DRM_IOCTL_V3D_SUBMIT_CPU)
11 changes: 11 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/xe_drm.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_BASIC_META(DRM_IOCTL_XE_DEVICE_QUERY)
_BASIC_META(DRM_IOCTL_XE_GEM_CREATE)
_BASIC_META(DRM_IOCTL_XE_GEM_MMAP_OFFSET)
_BASIC_META(DRM_IOCTL_XE_VM_CREATE)
_BASIC_META(DRM_IOCTL_XE_VM_DESTROY)
_BASIC_META(DRM_IOCTL_XE_VM_BIND)
_BASIC_META(DRM_IOCTL_XE_EXEC_QUEUE_CREATE)
_BASIC_META(DRM_IOCTL_XE_EXEC_QUEUE_DESTROY)
_BASIC_META(DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY)
_BASIC_META(DRM_IOCTL_XE_EXEC)
_BASIC_META(DRM_IOCTL_XE_WAIT_USER_FENCE)
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ namespace FEX::HLE::x32 {
#include "LinuxSyscalls/x32/Ioctl/vc4_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/v3d_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/virtio_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/pvr_drm.inl"
#include "LinuxSyscalls/x32/Ioctl/xe_drm.inl"

#undef _BASIC_META
#undef _BASIC_META_VAR
Expand Down
10 changes: 10 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/x32/SyscallsEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ enum Syscalls_x86 {
SYSCALL_x86_io_cancel = 249,
SYSCALL_x86_fadvise64 = 250,
SYSCALL_x86_exit_group = 252,
// No entrypoint. -ENOSYS
SYSCALL_x86_lookup_dcookie = 253,
SYSCALL_x86_epoll_create = 254,
SYSCALL_x86_epoll_ctl = 255,
Expand Down Expand Up @@ -468,6 +469,15 @@ enum Syscalls_x86 {
SYSCALL_x86_set_mempolicy_home_node = 450,
SYSCALL_x86_cachestat = 451,
SYSCALL_x86_fchmodat2 = 452,
SYSCALL_x86_map_shadow_stack = 453,
SYSCALL_x86_futex_wake = 454,
SYSCALL_x86_futex_wait = 455,
SYSCALL_x86_futex_requeue = 456,
SYSCALL_x86_statmount = 457,
SYSCALL_x86_listmount = 458,
SYSCALL_x86_lsm_get_self_attr = 459,
SYSCALL_x86_lsm_set_self_attr = 460,
SYSCALL_x86_lsm_list_modules = 461,
SYSCALL_x86_MAX = 512,
};

9 changes: 9 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/x64/SyscallsEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ enum Syscalls_x64 {
SYSCALL_x64_io_cancel = 210,
// No entrypoint. -ENOSYS
SYSCALL_x64_get_thread_area = 211,
// No entrypoint. -ENOSYS
SYSCALL_x64_lookup_dcookie = 212,
SYSCALL_x64_epoll_create = 213,
// No entrypoint. -ENOSYS
Expand Down Expand Up @@ -389,6 +390,14 @@ enum Syscalls_x64 {
SYSCALL_x64_cachestat = 451,
SYSCALL_x64_fchmodat2 = 452,
SYSCALL_x64_map_shadow_stack = 453,
SYSCALL_x64_futex_wake = 454,
SYSCALL_x64_futex_wait = 455,
SYSCALL_x64_futex_requeue = 456,
SYSCALL_x64_statmount = 457,
SYSCALL_x64_listmount = 458,
SYSCALL_x64_lsm_get_self_attr = 459,
SYSCALL_x64_lsm_set_self_attr = 460,
SYSCALL_x64_lsm_list_modules = 461,
SYSCALL_x64_MAX = 512,

// Unsupported syscalls on this host
Expand Down

0 comments on commit e33a76a

Please sign in to comment.