Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VDSO: Fixes a pretty nasty bug where we were never using the host VDSO #4024

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions Source/Tools/LinuxEmulation/VDSO_Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,26 +608,9 @@ VDSOMapping LoadVDSOThunks(bool Is64Bit, FEX::HLE::SyscallHandler* const Handler
fextl::string ThunkGuestPath {};
if (Is64Bit) {
ThunkGuestPath = fextl::fmt::format("{}/libVDSO-guest.so", ThunkGuestLibs());

// Set the Thunk definition pointers for x86-64
VDSODefinitions[0].ThunkFunction = FEX::VDSO::x64::Handler_time;
VDSODefinitions[1].ThunkFunction = FEX::VDSO::x64::Handler_gettimeofday;
VDSODefinitions[2].ThunkFunction = FEX::VDSO::x64::Handler_clock_gettime;
VDSODefinitions[3].ThunkFunction = FEX::VDSO::x64::Handler_clock_gettime;
VDSODefinitions[4].ThunkFunction = FEX::VDSO::x64::Handler_clock_getres;
VDSODefinitions[5].ThunkFunction = FEX::VDSO::x64::Handler_getcpu;
} else {
ThunkGuestPath = fextl::fmt::format("{}/libVDSO-guest.so", ThunkGuestLibs32());

// Set the Thunk definition pointers for x86
VDSODefinitions[0].ThunkFunction = FEX::VDSO::x32::Handler_time;
VDSODefinitions[1].ThunkFunction = FEX::VDSO::x32::Handler_gettimeofday;
VDSODefinitions[2].ThunkFunction = FEX::VDSO::x32::Handler_clock_gettime;
VDSODefinitions[3].ThunkFunction = FEX::VDSO::x32::Handler_clock_gettime64;
VDSODefinitions[4].ThunkFunction = FEX::VDSO::x32::Handler_clock_getres;
VDSODefinitions[5].ThunkFunction = FEX::VDSO::x32::Handler_getcpu;
}

// Load VDSO if we can
int VDSOFD = ::open(ThunkGuestPath.c_str(), O_RDONLY);

Expand Down Expand Up @@ -655,6 +638,24 @@ VDSOMapping LoadVDSOThunks(bool Is64Bit, FEX::HLE::SyscallHandler* const Handler
LoadUnique32BitSigreturn(&Mapping);
}

if (Is64Bit) {
// Set the Thunk definition pointers for x86-64
VDSODefinitions[0].ThunkFunction = FEX::VDSO::x64::Handler_time;
VDSODefinitions[1].ThunkFunction = FEX::VDSO::x64::Handler_gettimeofday;
VDSODefinitions[2].ThunkFunction = FEX::VDSO::x64::Handler_clock_gettime;
VDSODefinitions[3].ThunkFunction = FEX::VDSO::x64::Handler_clock_gettime;
VDSODefinitions[4].ThunkFunction = FEX::VDSO::x64::Handler_clock_getres;
VDSODefinitions[5].ThunkFunction = FEX::VDSO::x64::Handler_getcpu;
} else {
// Set the Thunk definition pointers for x86
VDSODefinitions[0].ThunkFunction = FEX::VDSO::x32::Handler_time;
VDSODefinitions[1].ThunkFunction = FEX::VDSO::x32::Handler_gettimeofday;
VDSODefinitions[2].ThunkFunction = FEX::VDSO::x32::Handler_clock_gettime;
VDSODefinitions[3].ThunkFunction = FEX::VDSO::x32::Handler_clock_gettime64;
VDSODefinitions[4].ThunkFunction = FEX::VDSO::x32::Handler_clock_getres;
VDSODefinitions[5].ThunkFunction = FEX::VDSO::x32::Handler_getcpu;
}

return Mapping;
}

Expand Down
Loading