From 826d7a435d781ed5bb9b8e04ad76ff8acb6f57d3 Mon Sep 17 00:00:00 2001 From: Exverge Date: Sat, 11 Jul 2026 20:17:40 -0400 Subject: [PATCH] Conditionally disable NCE on macOS --- CMakeLists.txt | 2 +- src/common/host_memory.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3497aa7bd0..d26063b8b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,7 +300,7 @@ if (NOT EXISTS ${PROJECT_BINARY_DIR}/${compat_json}) file(WRITE ${PROJECT_BINARY_DIR}/${compat_json} "") endif() -if (ARCHITECTURE_arm64 AND (ANDROID OR PLATFORM_LINUX OR APPLE)) +if (ARCHITECTURE_arm64 AND (ANDROID OR PLATFORM_LINUX)) set(HAS_NCE 1) add_compile_definitions(HAS_NCE=1) endif() diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 20a3ecf2cd..bf776036f0 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -444,10 +444,14 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else +// TODO: With the current page table and direct mapping implementation, we need exactly half of the 39-bit +// address space however Apple Silicon macOS reserved a majority of the 39-bit address space from +// `0x1000000000` to `0x7000000000`, making it effectively unusable for NCE. If this reservation is removed +// in a future version (e.g. macOS 28 when Rosetta is dropped) or the page tables are rewritten to support this +// (albeit at the expense of certain games that depending on 39-bit addresses failing to work), NCE on Macs is possible. static void* ChooseVirtualBase(size_t virtual_size) { virtual_size -= HugePageSize; // we handle alignment on our own - // todo: does this have to be 39bit? why? size_t cursor = 0; while (cursor < MACH_VM_MAX_ADDRESS - virtual_size) { u64 region = cursor;