[PATCH] ntdll: set correct address_space_limit and user_shared_data for android aarch64, virtual_alloc_first_teb can run succeeded on android aarch64

fanwj at mail.ustc.edu.cn fanwj at mail.ustc.edu.cn
Mon Jan 10 05:26:10 CST 2022


---
 dlls/ntdll/unix/virtual.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 1f817cd977d..65ab5032ce1 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -158,14 +158,22 @@ static void *address_space_start = (void *)0x10000;
 #endif
 
 #ifdef __aarch64__
+#ifdef __ANDROID__
+/* Note: Android-AARCH64 only support 3-level page table, address_space_limit is page_size * pow(page_size / ptr_size, page_level) - 0x10000 = 4096 * pow(4096 / 8, 3) - 0x10000 = 0x7fffff0000  */
+static void *address_space_limit = (void *)0x7fffff0000;
+#else
 static void *address_space_limit = (void *)0xffffffff0000;  /* top of the total available address space */
+#endif
 #elif defined(_WIN64)
 static void *address_space_limit = (void *)0x7fffffff0000;
 #else
 static void *address_space_limit = (void *)0xc0000000;
 #endif
 
-#ifdef _WIN64
+#if defined(__aarch64__) && defined(__ANDROID__)
+static void *user_space_limit    = (void *)0x7fffff0000;  /* top of the user address space */
+static void *working_set_limit   = (void *)0x7fffff0000;  /* top of the current working set */
+#elif defined(_WIN64)
 static void *user_space_limit    = (void *)0x7fffffff0000;  /* top of the user address space */
 static void *working_set_limit   = (void *)0x7fffffff0000;  /* top of the current working set */
 #else
@@ -173,7 +181,11 @@ static void *user_space_limit    = (void *)0x7fff0000;
 static void *working_set_limit   = (void *)0x7fff0000;
 #endif
 
+#if defined(__aarch64__) && defined(__ANDROID__)
+struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffffe0000; /* user_shared_data use last 64kB address, set to address_space_limit - 0x10000 */
+#else
 struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000;
+#endif
 
 /* TEB allocation blocks */
 static void *teb_block;
-- 
2.32.0 (Apple Git-132)





More information about the wine-devel mailing list