From 2c592bd8a8823eb7bd2d995290c60cc7d29fe5b8 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 3 Apr 2021 17:03:19 -0700 Subject: [PATCH] Implements a minimal siginfo_t in the dispatcher's signal handler This lets Carrion get farther in game. Seems like one of its threads hits sigsegv and it just...lets it die after checking siginfo? --- .../Interface/Core/Dispatcher/Dispatcher.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp index 1750f9b61..011e81afb 100644 --- a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp +++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp @@ -121,7 +121,11 @@ bool Dispatcher::HandleGuestSignal(int Signal, void *info, void *ucontext, Guest NewGuestSP -= sizeof(FEXCore::x86_64::ucontext_t); uint64_t UContextLocation = NewGuestSP; + NewGuestSP -= sizeof(siginfo_t); + uint64_t SigInfoLocation = NewGuestSP; + FEXCore::x86_64::ucontext_t *guest_uctx = reinterpret_cast(UContextLocation); + siginfo_t *guest_siginfo = reinterpret_cast(SigInfoLocation); // We have extended float information guest_uctx->uc_flags |= FEXCore::x86_64::UC_FP_XSTATE; @@ -169,8 +173,21 @@ bool Dispatcher::HandleGuestSignal(int Signal, void *info, void *ucontext, Guest guest_uctx->uc_stack.ss_sp = GuestStack->ss_sp; guest_uctx->uc_stack.ss_size = GuestStack->ss_size; - // XXX: siginfo_t(RSI) - Frame->State.gregs[X86State::REG_RSI] = 0x4142434445460000; + // siginfo_t + siginfo_t *HostSigInfo = reinterpret_cast(info); + guest_siginfo->si_signo = Signal; + switch (Signal) { + case SIGSEGV: + case SIGBUS: + guest_siginfo->si_code = HostSigInfo->si_code; + guest_siginfo->si_errno = HostSigInfo->si_errno; + // Macro expansion to get the si_addr + guest_siginfo->si_addr = HostSigInfo->si_addr; + break; + default: LogMan::Msg::D("Unhandled siginfo_t signal: %d", Signal); break; + } + + Frame->State.gregs[X86State::REG_RSI] = SigInfoLocation; Frame->State.gregs[X86State::REG_RDX] = UContextLocation; } else {