[PATCH] ntdll: set user_shared_data to 0x7fffffff0000 and virtual_alloc_first_teb can run succeeded on android aarch64
--- dlls/ntdll/unix/virtual.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 1f817cd977d..543c04e0dae 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -173,7 +173,16 @@ static void *user_space_limit = (void *)0x7fff0000; static void *working_set_limit = (void *)0x7fff0000; #endif +#if defined(__aarch64__) && defined(__ANDROID__) +/* Note: Android-AARCH64 only support 3-level page table: + * user_shared_data = page_size * pow(page_size / ptr_size, page_level) - 0x20000 + * = 0x1000 * pow(0x1000 / 8, 3) - 0x20000 + * = 0x7ffffe0000 + */ +struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffffe0000; +#else struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000; +#endif /* TEB allocation blocks */ static void *teb_block; -- 2.32.0 (Apple Git-132)
Am 10.01.2022 um 14:53 schrieb fanwj(a)mail.ustc.edu.cn:
+#if defined(__aarch64__) && defined(__ANDROID__) +/* Note: Android-AARCH64 only support 3-level page table: + * user_shared_data = page_size * pow(page_size / ptr_size, page_level) - 0x20000 + * = 0x1000 * pow(0x1000 / 8, 3) - 0x20000 + * = 0x7ffffe0000 + */ +struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffffe0000;
You can't simply move this structure. It's location is constant on Windows, applications and other Wine modules (e.g. kernel32, kernelbase, ntoskrnl) depend on it. Where does aarch64 Windows place it? I am not a VM expert, and I don't see what the 3 level page table has to do with the address. Is it possible that 0x7ffe0000 is not a multiple of your page size? I remember seeing this alloc failure on Android myself, but only in one of the Wine processes, not all of them. I didn't investigate closely though. André Zwing might know more.
participants (2)
-
fanwj@mail.ustc.edu.cn -
Stefan Dösinger