diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index 67f9eddb..1bc803a1 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -17,7 +17,7 @@ #ifdef __APPLE__ // Reserve space for the system address space using a zerofill section. -asm(".zerofill GUEST_SYSTEM,GUEST_SYSTEM,__guest_system,0xEFFC00000"); +asm(".zerofill GUEST_SYSTEM,GUEST_SYSTEM,__guest_system,0xFBFC00000"); #endif namespace Core { @@ -287,6 +287,11 @@ struct AddressSpace::Impl { constexpr int protection_flags = PROT_READ | PROT_WRITE; constexpr int base_map_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE; #ifdef __APPLE__ + // On ARM64 Macs, we run into limitations due to the commpage from 0xFC0000000 - 0xFFFFFFFFF + // and the GPU carveout region from 0x1000000000 - 0x6FFFFFFFFF. We can allocate the system + // managed region, as well as system reserved if reduced in size slightly, but we cannot map + // the user region where we want, so we must let the OS put it wherever possible and hope + // the game won't rely on its location. system_managed_base = reinterpret_cast( mmap(reinterpret_cast(SYSTEM_MANAGED_MIN), system_managed_size, protection_flags, base_map_flags | MAP_FIXED, -1, 0)); diff --git a/src/core/address_space.h b/src/core/address_space.h index ea73e2ed..c181b362 100644 --- a/src/core/address_space.h +++ b/src/core/address_space.h @@ -24,8 +24,8 @@ constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL; constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL; constexpr VAddr SYSTEM_RESERVED_MIN = 0x800000000ULL; #ifdef __APPLE__ -// Can only comfortably reserve the first 0x700000000 of reserved space. -constexpr VAddr SYSTEM_RESERVED_MAX = 0xEFFFFFFFFULL; +// Can only comfortably reserve the first 0x7C0000000 of system reserved space. +constexpr VAddr SYSTEM_RESERVED_MAX = 0xFBFFFFFFFULL; #else constexpr VAddr SYSTEM_RESERVED_MAX = 0xFFFFFFFFFULL; #endif