From c740801ea5d85fec7dd8c935e9e2eab4b581a736 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 3 Oct 2024 20:55:23 -0700 Subject: [PATCH] VDSOEmulation: Support loading VDSO thunk as shared Just requires a thread pointer check to be fixed in FEXCore. This doesn't need unique pages to exist for the file mapping and can be shared since it's readonly mapped. --- FEXCore/Source/Interface/Core/Core.cpp | 4 ++++ Source/Tools/LinuxEmulation/VDSO_Emulation.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/FEXCore/Source/Interface/Core/Core.cpp b/FEXCore/Source/Interface/Core/Core.cpp index 9774cddfc..d6fcb77c8 100644 --- a/FEXCore/Source/Interface/Core/Core.cpp +++ b/FEXCore/Source/Interface/Core/Core.cpp @@ -950,6 +950,10 @@ void ContextImpl::InvalidateGuestCodeRange(FEXCore::Core::InternalThreadState* T } void ContextImpl::MarkMemoryShared(FEXCore::Core::InternalThreadState* Thread) { + if (!Thread) { + return; + } + if (!IsMemoryShared) { IsMemoryShared = true; UpdateAtomicTSOEmulationConfig(); diff --git a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp index e82fd65c7..1e9d75060 100644 --- a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp +++ b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp @@ -746,7 +746,7 @@ VDSOMapping LoadVDSOThunks(bool Is64Bit, FEX::HLE::SyscallHandler* const Handler Mapping.VDSOSize = FEXCore::AlignUp(Mapping.VDSOSize, 4096); // Map the VDSO file to memory - Mapping.VDSOBase = Handler->GuestMmap(nullptr, nullptr, Mapping.VDSOSize, PROT_READ, MAP_PRIVATE, VDSOFD, 0); + Mapping.VDSOBase = Handler->GuestMmap(nullptr, nullptr, Mapping.VDSOSize, PROT_READ, MAP_SHARED, VDSOFD, 0); // Since we found our VDSO thunk library, find our host VDSO function implementations. LoadHostVDSO();