From 38ad3f0e05874fe32f19e93af21c6748368f626d Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 17 Dec 2023 18:17:15 -0800 Subject: [PATCH] FEXCore: Pass thread object to HandleUnalignedAccess Currently no functional change but public API breaks should come early. The thread state object will be used for looking up thread specific codebuffers in the future when we support MDWE with code mirrors. --- FEXCore/Source/Utils/ArchHelpers/Arm64.cpp | 2 +- FEXCore/Source/Utils/ArchHelpers/Arm64_stubs.cpp | 2 +- FEXCore/include/FEXCore/Utils/ArchHelpers/Arm64.h | 6 +++++- .../Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp | 2 +- Source/Windows/WOW64/Module.cpp | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/FEXCore/Source/Utils/ArchHelpers/Arm64.cpp b/FEXCore/Source/Utils/ArchHelpers/Arm64.cpp index dc2cc9ef4..5de71fa0b 100644 --- a/FEXCore/Source/Utils/ArchHelpers/Arm64.cpp +++ b/FEXCore/Source/Utils/ArchHelpers/Arm64.cpp @@ -2025,7 +2025,7 @@ static uint64_t HandleAtomicLoadstoreExclusive(uintptr_t ProgramCounter, uint64_ return NumInstructionsToSkip * 4; } -[[nodiscard]] std::pair HandleUnalignedAccess(bool ParanoidTSO, uintptr_t ProgramCounter, uint64_t *GPRs) { +[[nodiscard]] std::pair HandleUnalignedAccess(FEXCore::Core::InternalThreadState *Thread, bool ParanoidTSO, uintptr_t ProgramCounter, uint64_t *GPRs) { #ifdef _M_ARM_64 constexpr bool is_arm64 = true; #else diff --git a/FEXCore/Source/Utils/ArchHelpers/Arm64_stubs.cpp b/FEXCore/Source/Utils/ArchHelpers/Arm64_stubs.cpp index d59bd4794..434d378fe 100644 --- a/FEXCore/Source/Utils/ArchHelpers/Arm64_stubs.cpp +++ b/FEXCore/Source/Utils/ArchHelpers/Arm64_stubs.cpp @@ -23,7 +23,7 @@ bool HandleAtomicMemOp(void *_ucontext, void *_info, uint32_t Instr) { ERROR_AND_DIE_FMT("HandleAtomicMemOp Not Implemented"); } -std::pair HandleUnalignedAccess(bool ParanoidTSO, uintptr_t ProgramCounter, uint64_t *GPRs) { +std::pair HandleUnalignedAccess(FEXCore::Core::InternalThreadState *Thread, bool ParanoidTSO, uintptr_t ProgramCounter, uint64_t *GPRs) { ERROR_AND_DIE_FMT("HandleAtomicMemOp Not Implemented"); } diff --git a/FEXCore/include/FEXCore/Utils/ArchHelpers/Arm64.h b/FEXCore/include/FEXCore/Utils/ArchHelpers/Arm64.h index 0db721667..d2e59fd77 100644 --- a/FEXCore/include/FEXCore/Utils/ArchHelpers/Arm64.h +++ b/FEXCore/include/FEXCore/Utils/ArchHelpers/Arm64.h @@ -6,6 +6,10 @@ #include #include +namespace FEXCore::Core { + struct InternalThreadState; +} + namespace FEXCore::ArchHelpers::Arm64 { constexpr uint32_t CASPAL_MASK = 0xBF'E0'FC'00; constexpr uint32_t CASPAL_INST = 0x08'60'FC'00; @@ -121,5 +125,5 @@ namespace FEXCore::ArchHelpers::Arm64 { */ [[nodiscard]] FEX_DEFAULT_VISIBILITY - std::pair HandleUnalignedAccess(bool ParanoidTSO, uintptr_t ProgramCounter, uint64_t *GPRs); + std::pair HandleUnalignedAccess(FEXCore::Core::InternalThreadState *Thread, bool ParanoidTSO, uintptr_t ProgramCounter, uint64_t *GPRs); } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp index 0ca6f5286..3a1b7eabf 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp @@ -1764,7 +1764,7 @@ namespace FEX::HLE { return false; } - const auto Result = FEXCore::ArchHelpers::Arm64::HandleUnalignedAccess(GlobalDelegator->ParanoidTSO(), PC, ArchHelpers::Context::GetArmGPRs(ucontext)); + const auto Result = FEXCore::ArchHelpers::Arm64::HandleUnalignedAccess(Thread, GlobalDelegator->ParanoidTSO(), PC, ArchHelpers::Context::GetArmGPRs(ucontext)); ArchHelpers::Context::SetPc(ucontext, PC + Result.second); return Result.first; }; diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index dc8a38376..07da374ff 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -269,7 +269,7 @@ namespace Context { } FEX_CONFIG_OPT(ParanoidTSO, PARANOIDTSO); - const auto Result = FEXCore::ArchHelpers::Arm64::HandleUnalignedAccess(ParanoidTSO(), Context->Pc, &Context->X0); + const auto Result = FEXCore::ArchHelpers::Arm64::HandleUnalignedAccess(GetTLS().ThreadState(), ParanoidTSO(), Context->Pc, &Context->X0); if (!Result.first) { return false; }