Rebase against 4ccf7498aac20b2b0afa2118f8d919718e5fcbbe.

This commit is contained in:
Zebediah Figura
2021-04-27 20:03:45 -05:00
parent 552dc36846
commit 592b9480ef
8 changed files with 56 additions and 56 deletions

View File

@@ -1,7 +1,7 @@
From 0fdd0e4d59af06ed8b225e87802001ab53cb4906 Mon Sep 17 00:00:00 2001
From 5ac57c442cc9ce10ee8b8e0e82d3e3c199bd3862 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Mon, 31 Aug 2020 22:56:03 -0500
Subject: [PATCH 03/13] ntdll: Use a separate mutex to lock the TEB list.
Subject: [PATCH] ntdll: Use a separate mutex to lock the TEB list.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
@@ -9,10 +9,10 @@ Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 785583a340a..2e5e94f80f8 100644
index f3e6b612b93..f0cec5e1347 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -163,6 +163,7 @@ static void *teb_block;
@@ -175,6 +175,7 @@ static void *teb_block;
static void **next_free_teb;
static int teb_block_pos;
static struct list teb_list = LIST_INIT( teb_list );
@@ -20,27 +20,27 @@ index 785583a340a..2e5e94f80f8 100644
#define ROUND_ADDR(addr,mask) ((void *)((UINT_PTR)(addr) & ~(UINT_PTR)(mask)))
#define ROUND_SIZE(addr,size) (((SIZE_T)(size) + ((UINT_PTR)(addr) & page_mask) + page_mask) & ~page_mask)
@@ -2556,7 +2557,9 @@ static void init_teb( TEB *teb, PEB *peb )
@@ -2880,7 +2881,9 @@ static TEB *init_teb( void *ptr, PEB *peb )
thread_data->reply_fd = -1;
thread_data->wait_fd[0] = -1;
thread_data->wait_fd[1] = -1;
+ pthread_rwlock_wrlock( &teb_list_lock );
list_add_head( &teb_list, &thread_data->entry );
+ pthread_rwlock_unlock( &teb_list_lock );
return teb;
}
@@ -2678,7 +2681,9 @@ void virtual_free_teb( TEB *teb )
@@ -2997,7 +3000,9 @@ void virtual_free_teb( TEB *teb )
}
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
+ pthread_rwlock_wrlock( &teb_list_lock );
list_remove( &thread_data->entry );
+ pthread_rwlock_unlock( &teb_list_lock );
ptr = (char *)teb - teb_offset;
if (!is_win64) ptr = (char *)ptr - teb_offset;
*(void **)ptr = next_free_teb;
next_free_teb = ptr;
@@ -2692,17 +2697,16 @@ void virtual_free_teb( TEB *teb )
@@ -3011,17 +3016,16 @@ void virtual_free_teb( TEB *teb )
NTSTATUS virtual_clear_tls_index( ULONG index )
{
struct ntdll_thread_data *thread_data;
@@ -60,7 +60,7 @@ index 785583a340a..2e5e94f80f8 100644
}
else
{
@@ -2710,13 +2714,13 @@ NTSTATUS virtual_clear_tls_index( ULONG index )
@@ -3029,13 +3033,13 @@ NTSTATUS virtual_clear_tls_index( ULONG index )
if (index >= 8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits))
return STATUS_INVALID_PARAMETER;
@@ -77,5 +77,5 @@ index 785583a340a..2e5e94f80f8 100644
return STATUS_SUCCESS;
}
--
2.29.2
2.30.2

View File

@@ -1,4 +1,4 @@
From 17e0fb2e0be8d53b485c96941faaa76d30d0c032 Mon Sep 17 00:00:00 2001
From 32902deea99f78645f82f283f5cde453607cec1d Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Mon, 31 Aug 2020 23:03:34 -0500
Subject: [PATCH] ntdll: Implement thread-id alerts on top of Mach semaphores
@@ -88,10 +88,10 @@ index f4f87ba5642..7d6423083e1 100644
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 87f5a97131e..e97a9657f03 100644
index bfcd7bf04a7..9b3c9a91abc 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -252,7 +252,11 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
@@ -262,7 +262,11 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
thread_data->start = start;
thread_data->param = param;
@@ -104,7 +104,7 @@ index 87f5a97131e..e97a9657f03 100644
pthread_attr_init( &pthread_attr );
pthread_attr_setstack( &pthread_attr, teb->DeallocationStack,
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 2da19c6844f..3c4d5dd8a2b 100644
index 4c38ed8ef29..3d629de09b2 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -27,6 +27,11 @@
@@ -117,9 +117,9 @@ index 2da19c6844f..3c4d5dd8a2b 100644
+#endif
+
#ifdef __i386__
static const enum cpu_type client_cpu = CPU_x86;
static const WORD current_machine = IMAGE_FILE_MACHINE_I386;
@@ -62,10 +67,14 @@ struct ntdll_thread_data
#elif defined(__x86_64__)
@@ -60,10 +65,14 @@ struct ntdll_thread_data
struct list entry; /* entry in TEB list */
PRTL_THREAD_START_ROUTINE start; /* thread entry point */
void *param; /* thread entry point parameter */
@@ -135,5 +135,5 @@ index 2da19c6844f..3c4d5dd8a2b 100644
C_ASSERT( sizeof(struct ntdll_thread_data) <= sizeof(((TEB *)0)->GdiTebBatch) );
--
2.20.1
2.30.2