From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id A221F383602B; Tue, 3 May 2022 13:16:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A221F383602B Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: move x86_64 thread stack area X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: b827d4d36a7df77e8e0bcaed38bf639d83f6d233 X-Git-Newrev: 28970dae34522059e094eb7db466404facb09460 Message-Id: <20220503131651.A221F383602B@sourceware.org> Date: Tue, 3 May 2022 13:16:51 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2022 13:16:51 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D28970dae345= 22059e094eb7db466404facb09460 commit 28970dae34522059e094eb7db466404facb09460 Author: Corinna Vinschen Date: Tue May 3 15:10:24 2022 +0200 Cygwin: move x86_64 thread stack area =20 The x86_64 thread stack area collides with the share user data in recent versions of Windows. Let's get ourselvels get out of the way and move the thread stack area in the former slack space between DLL area and heap, from 0x6:00000000 to 0x8:00000000. That quadruplicates the stack area, so allow bigger maximum stack sizes. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/heap.cc | 5 +++-- winsup/cygwin/miscfuncs.cc | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index f27f81bc4..fa2c8391e 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -34,8 +34,9 @@ eval_start_address () executable starts at 0x1:00400000L, the Cygwin DLL starts at 0x1:80040000L, other rebased DLLs are located in the region from 0x2:00000000L up to 0x4:00000000L, -auto-image-based DLLs are located - in the region from 0x4:00000000L up to 0x6:00000000L. Leave another - 8 Gigs slack space, so lets start the heap at 0x8:00000000L. */ + in the region from 0x4:00000000L up to 0x6:00000000L. Thread stacks + are located in the region from 0x6:00000000L up to 0x8:00000000L. + So the heap starts at 0x8:00000000L. */ uintptr_t start_address =3D 0x800000000L; #else /* Windows performs heap ASLR. This spoils the entire region below diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 905c242c5..4a5db6f2e 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -513,13 +513,14 @@ pthread_wrapper (PVOID arg) } =20 #ifdef __x86_64__ -/* The memory region used for thread stacks */ -#define THREAD_STORAGE_LOW 0x080000000L -#define THREAD_STORAGE_HIGH 0x100000000L +/* The memory region used for thread stacks. The memory layout is outlined + in heap.cc, function eval_start_address(). */ +#define THREAD_STORAGE_LOW 0x600000000L +#define THREAD_STORAGE_HIGH 0x800000000L /* We provide the stacks always in 1 Megabyte slots */ -#define THREAD_STACK_SLOT 0x100000L /* 1 Meg */ +#define THREAD_STACK_SLOT 0x000100000L /* 1 Meg */ /* Maximum stack size returned from the pool. */ -#define THREAD_STACK_MAX 0x10000000L /* 256 Megs */ +#define THREAD_STACK_MAX 0x040000000L /* 1 Gig */ =20 class thread_allocator {