Added patch to fix issues with write watches when using Exagear.

This commit is contained in:
Sebastian Lackner 2014-11-22 05:51:42 +01:00
parent 50b6b69053
commit 7c3d480e56
4 changed files with 57 additions and 2 deletions

1
debian/changelog vendored
View File

@ -5,6 +5,7 @@ wine-compholio (1.7.32) UNRELEASED; urgency=low
* Added patch to take abs() of vertex z coordinate as FFP fog coordinate.
* Added patch to ensure ShowWindow avoids interthread no-op messages.
* Added patch to avoid race-conditions of async WSARecv() operations with write watches.
* Added patch to fix issues with write watches when using Exagear.
* Removed patch to close server fd is there is no space in thread inflight fd list (accepted upstream).
* Removed patch to fix bugs in StrStr functions (accepted upstream).
* Removed patches to avoid sending messages in FindWindowExW (accepted upstream).

View File

@ -0,0 +1,51 @@
From 8c7754a1da9f43cf15057a8467c0b76c9da2ce40 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 22 Nov 2014 05:49:30 +0100
Subject: ntdll: Fix issues with write watches when using Exagear.
---
dlls/ntdll/virtual.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 1a8e4a4..4140323 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1558,6 +1558,26 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err )
{
void *page = ROUND_ADDR( addr, page_mask );
BYTE *vprot = &view->prot[((const char *)page - (const char *)view->base) >> page_shift];
+#ifdef EXAGEAR_COMPAT
+ /* Exagear doesn't correctly set err, so always check for write watches, and
+ * retry after removing the VPROT_WRITEWATCH or VPROT_WRITECOPY flag. In
+ * contrary to the general implementation below this is not completely race-
+ * condition safe. When multiple threads trigger the write watch at the same
+ * time only the first thread will properly continue the execution, the rest
+ * will crash. */
+ if ((view->protect & VPROT_WRITEWATCH) && (*vprot & VPROT_WRITEWATCH))
+ {
+ *vprot &= ~VPROT_WRITEWATCH;
+ VIRTUAL_SetProt( view, page, page_size, *vprot );
+ if (VIRTUAL_GetUnixProt( *vprot ) & PROT_WRITE) ret = STATUS_SUCCESS;
+ }
+ if (*vprot & VPROT_WRITECOPY)
+ {
+ *vprot = (*vprot & ~VPROT_WRITECOPY) | VPROT_WRITE;
+ VIRTUAL_SetProt( view, page, page_size, *vprot );
+ if (VIRTUAL_GetUnixProt( *vprot ) & PROT_WRITE) ret = STATUS_SUCCESS;
+ }
+#else
if (err & EXCEPTION_WRITE_FAULT)
{
if ((view->protect & VPROT_WRITEWATCH) && (*vprot & VPROT_WRITEWATCH))
@@ -1573,6 +1593,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err )
/* ignore fault if page is writable now */
if (VIRTUAL_GetUnixProt( *vprot ) & PROT_WRITE) ret = STATUS_SUCCESS;
}
+#endif
if (*vprot & VPROT_GUARD)
{
VIRTUAL_SetProt( view, page, page_size, *vprot & ~VPROT_GUARD );
--
2.1.3

View File

@ -0,0 +1 @@
Depends: ntdll-WRITECOPY

View File

@ -171,13 +171,15 @@ clean:
# Patchset Exagear
# |
# | Modified files:
# | * configure.ac, dlls/ntdll/signal_i386.c
# | * configure.ac, dlls/ntdll/signal_i386.c, dlls/ntdll/virtual.c
# |
.INTERMEDIATE: Exagear.ok
Exagear.ok:
Exagear.ok: ntdll-WRITECOPY.ok
$(call APPLY_FILE,Exagear/0001-ntdll-Implement-emulation-of-SIDT-instruction-when-u.patch)
$(call APPLY_FILE,Exagear/0002-ntdll-Fix-issues-with-write-watches-when-using-Exage.patch)
@( \
echo '+ { "Sebastian Lackner", "ntdll: Implement emulation of SIDT instruction when using Exagear.", 1 },'; \
echo '+ { "Sebastian Lackner", "ntdll: Fix issues with write watches when using Exagear.", 1 },'; \
) > Exagear.ok
# Patchset Miscellaneous