From 7f67fc959874d9866a8b67db0ed980978808a200 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 | 2 ++ Source/Tools/LinuxEmulation/VDSO_Emulation.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/FEXCore/Source/Interface/Core/Core.cpp b/FEXCore/Source/Interface/Core/Core.cpp index 9774cddfc7..d7f531f28e 100644 --- a/FEXCore/Source/Interface/Core/Core.cpp +++ b/FEXCore/Source/Interface/Core/Core.cpp @@ -950,6 +950,8 @@ 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 e82fd65c73..1e9d75060e 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();