]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: Allow accessing 48 bit address space in Windows 8.1 or later
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 4 Jun 2019 14:58:53 +0000 (16:58 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 4 Jun 2019 14:58:53 +0000 (16:58 +0200)
64 bit Windows started out with a 44 bit address space due to a
restriction of the AMD64 CPUs at the time.  Starting with Windows
8.1, these CPUs are not supported anymore and Windows switched to
the full 48 bit address space supported by AMD64.

Cygwin didn't follow suit yet so mmaps are still restricted to
the lower 44 bit address space.  Fix that by using a system-specific
upper address for mmap allocations, 44 bit up to Windows 8, 48 bit
starting with Windows 8.1.

While at it, move the heap by another 8 Gigs to leave some space
for a potential extension of DLL address space, and restrict the
mmap lower address so the heap can grow to 32 Gigs before colliding
with mmaps.

winsup/cygwin/heap.cc
winsup/cygwin/mmap.cc
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h

index e18cd5508259131cbdbd5ef24974f69dd7d9e2f1..b839c8cd48eeb74cb5ef098409904bca7922e62e 100644 (file)
@@ -34,9 +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.
-     So we let the heap start at 0x6:00000000L. */
-  uintptr_t start_address = 0x600000000L;
+     in the region from 0x4:00000000L up to 0x6:00000000L.  Leave another
+     8 Gigs slack space, so lets start the heap at 0x8:00000000L. */
+  uintptr_t start_address = 0x800000000L;
 #else
   /* Windows performs heap ASLR.  This spoils the entire region below
      0x20000000 for us, because that region is used by Windows to randomize
index 9eb1643a02c4f41e7c0fa423c9f63ff98e38620f..8b1aedc48ea627c28b7b125c266c136213fb06a2 100644 (file)
@@ -801,8 +801,10 @@ mmap_worker (mmap_list *map_list, fhandler_base *fh, caddr_t base, size_t len,
 #ifdef __x86_64__
 
 /* The memory region used for memory maps */
-#define MMAP_STORAGE_LOW       0x00800000000L  /* Leave 8 Gigs for heap. */
-#define MMAP_STORAGE_HIGH      0x70000000000L  /* Leave enough room for OS. */
+#define MMAP_STORAGE_LOW       0x001000000000L /* Leave 32 Gigs for heap. */
+/* Up to Win 8 only supporting 44 bit address space, starting with Win 8.1
+   48 bit address space. */
+#define MMAP_STORAGE_HIGH      wincap.mmap_storage_high ()
 
 /* FIXME?  Unfortunately the OS doesn't support a top down allocation with
           a ceiling value.  The ZeroBits mechanism only works for
index 17e0cf1be0bc887f31aef1d010d7c714a226396a..5c6e6428ec96da8408a4378dd402b8ffb5a315c0 100644 (file)
@@ -20,6 +20,7 @@ details. */
 
 wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:1,
+  mmap_storage_high:0x070000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:true,
@@ -46,6 +47,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
 
 wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:1,
+  mmap_storage_high:0x070000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -72,6 +74,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
 
 wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x070000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -98,6 +101,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
 
 wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x700000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -124,6 +128,7 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
 
 wincaps  wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x700000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -150,6 +155,7 @@ wincaps  wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
 
 wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x700000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -176,6 +182,7 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
 
 wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x700000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -202,6 +209,7 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
 
 wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x700000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
@@ -228,6 +236,7 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
 
 wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) = {
   def_guard_pages:2,
+  mmap_storage_high:0x700000000000LL,
   {
     is_server:false,
     needs_count_in_si_lpres2:false,
index 73b6f5ffc52a8608d4b2f762acd0276bfdc61b1b..ba01a156563ef4a36a54856c90b0f542ec937e39 100644 (file)
@@ -12,6 +12,7 @@ details. */
 struct wincaps
 {
   DWORD def_guard_pages;
+  int64_t mmap_storage_high;
   /* The bitfields must be 8 byte aligned on x86_64, otherwise the bitfield
      ops generated by gcc are off by 4 bytes. */
   struct  __attribute__ ((aligned (8))) {
@@ -71,6 +72,9 @@ public:
   {
     return ((wincaps *) this->caps)->def_guard_pages * page_size ();
   }
+#ifdef __x86_64__
+  intptr_t IMPLEMENT (mmap_storage_high)
+#endif
   bool  IMPLEMENT (is_server)
   bool IMPLEMENT (needs_count_in_si_lpres2)
   bool IMPLEMENT (needs_query_information)
This page took 0.033556 seconds and 5 git commands to generate.