Cygwin: Allow accessing 48 bit address space in Windows 8.1 or later
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.
This commit is contained in:
parent
f03ea8e1c5
commit
e1254add73
|
@ -34,9 +34,9 @@ eval_start_address ()
|
||||||
executable starts at 0x1:00400000L, the Cygwin DLL starts at
|
executable starts at 0x1:00400000L, the Cygwin DLL starts at
|
||||||
0x1:80040000L, other rebased DLLs are located in the region from
|
0x1:80040000L, other rebased DLLs are located in the region from
|
||||||
0x2:00000000L up to 0x4:00000000L, -auto-image-based DLLs are located
|
0x2:00000000L up to 0x4:00000000L, -auto-image-based DLLs are located
|
||||||
in the region from 0x4:00000000L up to 0x6:00000000L.
|
in the region from 0x4:00000000L up to 0x6:00000000L. Leave another
|
||||||
So we let the heap start at 0x6:00000000L. */
|
8 Gigs slack space, so lets start the heap at 0x8:00000000L. */
|
||||||
uintptr_t start_address = 0x600000000L;
|
uintptr_t start_address = 0x800000000L;
|
||||||
#else
|
#else
|
||||||
/* Windows performs heap ASLR. This spoils the entire region below
|
/* Windows performs heap ASLR. This spoils the entire region below
|
||||||
0x20000000 for us, because that region is used by Windows to randomize
|
0x20000000 for us, because that region is used by Windows to randomize
|
||||||
|
|
|
@ -801,8 +801,10 @@ mmap_worker (mmap_list *map_list, fhandler_base *fh, caddr_t base, size_t len,
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
/* The memory region used for memory maps */
|
/* The memory region used for memory maps */
|
||||||
#define MMAP_STORAGE_LOW 0x00800000000L /* Leave 8 Gigs for heap. */
|
#define MMAP_STORAGE_LOW 0x001000000000L /* Leave 32 Gigs for heap. */
|
||||||
#define MMAP_STORAGE_HIGH 0x70000000000L /* Leave enough room for OS. */
|
/* 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
|
/* FIXME? Unfortunately the OS doesn't support a top down allocation with
|
||||||
a ceiling value. The ZeroBits mechanism only works for
|
a ceiling value. The ZeroBits mechanism only works for
|
||||||
|
|
|
@ -20,6 +20,7 @@ details. */
|
||||||
|
|
||||||
wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:1,
|
def_guard_pages:1,
|
||||||
|
mmap_storage_high:0x070000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2:true,
|
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)) = {
|
wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:1,
|
def_guard_pages:1,
|
||||||
|
mmap_storage_high:0x070000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x070000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x700000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x700000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x700000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x700000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x700000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2: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)) = {
|
wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
def_guard_pages:2,
|
def_guard_pages:2,
|
||||||
|
mmap_storage_high:0x700000000000LL,
|
||||||
{
|
{
|
||||||
is_server:false,
|
is_server:false,
|
||||||
needs_count_in_si_lpres2:false,
|
needs_count_in_si_lpres2:false,
|
||||||
|
|
|
@ -12,6 +12,7 @@ details. */
|
||||||
struct wincaps
|
struct wincaps
|
||||||
{
|
{
|
||||||
DWORD def_guard_pages;
|
DWORD def_guard_pages;
|
||||||
|
int64_t mmap_storage_high;
|
||||||
/* The bitfields must be 8 byte aligned on x86_64, otherwise the bitfield
|
/* The bitfields must be 8 byte aligned on x86_64, otherwise the bitfield
|
||||||
ops generated by gcc are off by 4 bytes. */
|
ops generated by gcc are off by 4 bytes. */
|
||||||
struct __attribute__ ((aligned (8))) {
|
struct __attribute__ ((aligned (8))) {
|
||||||
|
@ -71,6 +72,9 @@ public:
|
||||||
{
|
{
|
||||||
return ((wincaps *) this->caps)->def_guard_pages * page_size ();
|
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 (is_server)
|
||||||
bool IMPLEMENT (needs_count_in_si_lpres2)
|
bool IMPLEMENT (needs_count_in_si_lpres2)
|
||||||
bool IMPLEMENT (needs_query_information)
|
bool IMPLEMENT (needs_query_information)
|
||||||
|
|
Loading…
Reference in New Issue