mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-14 13:00:41 +02:00
Wine: Change behaviour around SMC and NtReadFile
JIT invalidation around syscalls and kernel calls is mighty fickle. This is why the previous code path was born. In order to properly handle this case we need strong coordination between Wine and FEX around invalidating code and memory protections. This doesn't quite exist today so we're kind of stuck with a kludge solution. Instead of forcing the Persona 5 code invalidation on to every process, only do it on P5R. This fixes a hang in msiexec with PhysX trying to do a blocking read and jitting code or creating threads, while also maintaining the P5R approach. The full comment is in the file about the reasoning.
This commit is contained in:
2 files changed
+57
-35
No files matched your search
@@ -1034,22 +1034,15 @@ void BTCpuNotifyUnmapViewOfSection(void* Address, BOOL After, ULONG Status) {
|
||||
}
|
||||
|
||||
void BTCpuNotifyReadFile(HANDLE Handle, void* Address, SIZE_T Size, BOOL After, NTSTATUS Status) {
|
||||
auto& InLockedRWXRead = GetFrontendThreadData(GetTLS().ThreadState())->InLockedRWXRead;
|
||||
if (!After) {
|
||||
ThreadCreationMutex.lock();
|
||||
CTX->GetCodeInvalidationMutex().lock();
|
||||
if (InvalidationTracker->BeginUntrackedWriteLocked(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size))) {
|
||||
InLockedRWXRead = true;
|
||||
} else {
|
||||
CTX->GetCodeInvalidationMutex().unlock();
|
||||
ThreadCreationMutex.unlock();
|
||||
}
|
||||
} else {
|
||||
if (InLockedRWXRead) {
|
||||
InLockedRWXRead = false;
|
||||
CTX->GetCodeInvalidationMutex().unlock();
|
||||
ThreadCreationMutex.unlock();
|
||||
}
|
||||
auto* ThreadState = GetTLS().ThreadState();
|
||||
if (!InvalidationTracker || !ThreadState) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See arm64ec `BTCpu64NotifyReadFile` for why this like this.
|
||||
if (After && Status == STATUS_SUCCESS) {
|
||||
std::scoped_lock Lock(ThreadCreationMutex);
|
||||
InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user