diff --git a/tools/fex/patches/0031-diag-sud.patch b/tools/fex/patches/0031-diag-sud.patch new file mode 100644 index 0000000000..b9321c782b --- /dev/null +++ b/tools/fex/patches/0031-diag-sud.patch @@ -0,0 +1,35 @@ +diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp +index 1dc85de..be763fc 100644 +--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp ++++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp +@@ -6,6 +6,7 @@ $end_info$ + */ + + #include ++#include + #include + #include "LinuxSyscalls/Seccomp/BPFEmitter.h" + #include "LinuxSyscalls/Seccomp/SeccompEmulator.h" +@@ -365,7 +366,9 @@ SeccompEmulator::ExecuteSyscallUserDispatch(FEXCore::Core::CpuStateFrame* Frame, + + if (SUD.Selector) { + uint8_t State {}; +- if (FaultSafeUserMemAccess::CopyFromUser(&State, reinterpret_cast(SUD.Selector), sizeof(State))) { ++ const bool SelFault = FaultSafeUserMemAccess::CopyFromUser(&State, reinterpret_cast(SUD.Selector), sizeof(State)); ++ if (SelFault || State != 0) ::dprintf(2, "DDSUD %d/%ld nr=%lu rip=%#lx off=%#lx len=%#lx sel=%#lx fault=%d state=%u\n", ::getpid(), ::syscall(SYS_gettid), SyscallNumber, PostSyscallRIP, SUD.Offset, SUD.Length, SUD.Selector, SelFault, State); ++ if (SelFault) { + ForceExitSignal(Thread, SIGSEGV); + return {true, SyscallNumber}; + } +diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp +index a3cc742..d90d201 100644 +--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp ++++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp +@@ -1126,6 +1126,7 @@ void SignalDelegator::PrepareForcedGuestSignal(FEX::HLE::ThreadStateObject* Thre + GuestSigAction Action {}; + RegisterGuestSignalHandler(Signal, nullptr, &Action); + const bool Ignored = Action.sigaction_handler.handler == SIG_IGN; ++ ::dprintf(2, "DDFORCE %d/%ld sig=%d blocked=%d ignored=%d handler=%p mask=%#lx\n", ::getpid(), ::syscall(SYS_gettid), Signal, Blocked, Ignored, reinterpret_cast(Action.sigaction_handler.handler), static_cast(Thread->SignalInfo.CurrentSignalMask.Val)); + + if (!Blocked && !Ignored) { + return;