https://bugs.winehq.org/show_bug.cgi?id=46179
Bug ID: 46179 Summary: Multiple Windows 10 ARM64 apps need 'kernel32.dll.GetCurrentThreadStackLimits' to get stack start address Product: Wine Version: 3.20 Hardware: aarch64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: focht@gmx.net Distribution: ---
Hello folks,
another valuable resource of improving/fixing Wine on ARM64 is the Chrome browser port to Windows 10 ARM64 platform that is currently underway and going to continue for some months.
I'm following various Chromium and LLVM/Clang pull requests related to Win10 ARM64 porting activities.
Related PR to this ticket:
https://chromium-review.googlesource.com/c/chromium/src/+/1344870
https://chromium-review.googlesource.com/c/chromium/src/+/1344870/3/third_pa...
--- snip --- // On Windows stack limits for the current thread are available in // the thread information block (TIB). Its fields can be accessed through // FS segment register on x86 and GS segment register on x86_64. // On Windows ARM64, stack limits could be retrieved by calling
// GetCurrentThreadStackLimits. This API doesn't work on x86 and x86_64 here
// because it requires Windows 8+.
#if defined(ARCH_CPU_X86_64) return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))); #elif defined(ARCH_CPU_X86) return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase)));
#elif defined(ARCH_CPU_ARM64)
ULONG_PTR lowLimit, highLimit;
::GetCurrentThreadStackLimits(&lowLimit, &highLimit);
return reinterpret_cast<void*>(highLimit); #endif --- snip ---
Microsoft docs:
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-pr...
Regards
https://bugs.winehq.org/show_bug.cgi?id=46179
André H. nerv@dawncrow.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |ee9f2c62d53c8838fda5b6f485e | |1f865f4a8bf69 CC| |nerv@dawncrow.de Resolution|--- |FIXED
--- Comment #1 from André H. nerv@dawncrow.de --- Fixed by https://source.winehq.org/git/wine.git/commit/ee9f2c62d53c8838fda5b6f485e1f8...
https://bugs.winehq.org/show_bug.cgi?id=46179
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL| |https://aka.ms/chakracore/c | |c_windows_all_1_11_3 Summary|Multiple Windows 10 ARM64 |Multiple Windows 10 |apps need |ARM{32,64} apps need |'kernel32.dll.GetCurrentThr |'kernel32.dll.GetCurrentThr |eadStackLimits' to get |eadStackLimits' to get |stack start address |stack start address Keywords| |download
--- Comment #2 from Anastasius Focht focht@gmx.net --- Hello André,
thanks. I've found some apps for x86_64, arm32, arm64 architecture using this API on Github.
Example: ChakraCore
--- quote --- ChakraCore is the core part of Chakra, the high-performance JavaScript engine that powers Microsoft Edge and Windows applications written in HTML/CSS/JS. ChakraCore supports Just-in-time (JIT) compilation of JavaScript for x86/x64/ARM, garbage collection, and a wide range of the latest JavaScript features. ChakraCore also supports the JavaScript Runtime (JSRT) APIs, which allows you to easily embed ChakraCore in your applications. --- quote ---
https://github.com/Microsoft/ChakraCore
https://github.com/Microsoft/ChakraCore/blob/master/lib/Runtime/Base/StackPr...
--- snip --- ...
void StackProber::Initialize() { // NumGuardPages is 2 on x86/x86-64 // 1 MEM_RESERVE page at the bottom of the stack // 1 PAGE_GUARD | PAGE_READWRITE page that serves as the guard page const size_t guardPageSize = Js::Constants::NumGuardPages * AutoSystemInfo::PageSize; const size_t stackOverflowBuffer = Js::Constants::StackOverflowHandlingBufferPages * AutoSystemInfo::PageSize;
size_t stackBottom = 0; // This is the low address limit (here we consider stack growing down). ULONG stackGuarantee = 0;
#if defined(_M_IX86) && defined(_MSC_VER) stackBottom = __readfsdword(0xE0C); // points to the DeAllocationStack on the TEB - which turns to be the stack bottom. #elif defined(_M_AMD64) && defined(_MSC_VER) stackBottom = __readgsqword(0x1478); #elif defined(_M_ARM) ULONG lowLimit, highLimit; ::GetCurrentThreadStackLimits(&lowLimit, &highLimit); stackBottom = lowLimit; #elif defined(_M_ARM64) ULONG64 lowLimit, highLimit; ::GetCurrentThreadStackLimits(&lowLimit, &highLimit); stackBottom = lowLimit; #elif !defined(_MSC_VER) ULONG_PTR lowLimit = 0; ULONG_PTR highLimit = 0; ::GetCurrentThreadStackLimits(&lowLimit, &highLimit); stackBottom = lowLimit; #else stackBottom = NULL; Js::Throw::NotImplemented(); #endif
Assert(stackBottom);
#ifdef _WIN32 // Calling this API with stackGuarantee == 0 *gets* current stack guarantee. SetThreadStackGuarantee(&stackGuarantee); #endif
stackLimit = stackBottom + guardPageSize + stackGuarantee + stackOverflowBuffer; } --- snip ---
https://aka.ms/chakracore/cc_windows_all_1_11_3
--- snip --- $ unzip -l cc_windows_1_11_3.zip Archive: cc_windows_1_11_3.zip Length Date Time Name --------- ---------- ----- ---- 0 11-13-2018 15:56 arm_release/ 281216 11-13-2018 15:56 arm_release/ch.exe 4657152 11-13-2018 15:56 arm_release/ch.pdb 4599032 11-13-2018 15:56 arm_release/ChakraCore.dll 56020992 11-13-2018 15:56 arm_release/ChakraCore.pdb 0 11-13-2018 15:56 x64_release/ 350024 11-13-2018 15:56 x64_release/ch.exe 4739072 11-13-2018 15:56 x64_release/ch.pdb 6511152 11-13-2018 15:56 x64_release/ChakraCore.dll 67653632 11-13-2018 15:56 x64_release/ChakraCore.pdb 0 11-13-2018 15:56 x86_release/ 308344 11-13-2018 15:56 x86_release/ch.exe 5050368 11-13-2018 15:56 x86_release/ch.pdb 4863232 11-13-2018 15:56 x86_release/ChakraCore.dll 69365760 11-13-2018 15:56 x86_release/ChakraCore.pdb --------- ------- 224399976 15 files --- snip ---
--- snip --- $ wget https://raw.githubusercontent.com/Microsoft/ChakraCore/master/test/es6module...
$ wget https://raw.githubusercontent.com/Microsoft/ChakraCore/master/test/es6module...
$ file * ChakraCore.dll: PE32 executable (DLL) (console) ARMv7 Thumb, for MS Windows ChakraCore.pdb: MSVC program database ver 7.00, 4096*13677 bytes ch.exe: PE32 executable (console) ARMv7 Thumb, for MS Windows ch.pdb: MSVC program database ver 7.00, 4096*1137 bytes moduletest1.js: ASCII text, with CRLF line terminators passmodule.js: ASCII text, with CRLF line terminators
$ WINEDEBUG=+seh,+loaddll,+relay wine ./ch.exe ./moduletest1.js >>log.txt 2>&1 ... 0029:Call KERNEL32.GetCurrentThreadStackLimits(f5edf97c,f5edf980) ret=1003b285 0029:Ret KERNEL32.GetCurrentThreadStackLimits() retval=f77f1000 ret=1003b285 ... 0029:Call KERNEL32.SetThreadStackGuarantee(f5edf978) ret=1003b295 0029:fixme:thread:SetThreadStackGuarantee (0xf5edf978): stub 0029:Ret KERNEL32.SetThreadStackGuarantee() retval=00000001 ret=1003b295 ... --- snip ---
$ du -sh cc_windows_1_11_3.zip 51M cc_windows_1_11_3.zip
$ sha1sum cc_windows_1_11_3.zip e388575db7385ad2b5d87a9f078c5db95c73d1f5 cc_windows_1_11_3.zip
$ wine --version wine-3.21-58-gb1a0482b80
Regards
https://bugs.winehq.org/show_bug.cgi?id=46179
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #3 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 4.0-rc1.
https://bugs.winehq.org/show_bug.cgi?id=46179
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL|https://aka.ms/chakracore/c |https://web.archive.org/web |c_windows_all_1_11_3 |/20190510095311/https://aka | |.ms/chakracore/cc_windows_a | |ll_1_11_3