Skip to content

Commit

Permalink
Merge pull request #4024 from Sonicadvance1/fix_vdso_on_vdso_host
Browse files Browse the repository at this point in the history
VDSO: Fixes a pretty nasty bug where we were never using the host VDSO
  • Loading branch information
Sonicadvance1 authored Sep 2, 2024
2 parents 114112a + f8eaf9c commit 0754aff
Showing 1 changed file with 18 additions and 17 deletions.
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

0 comments on commit 0754aff

Please sign in to comment.