Skip to content

Building Arm 64-bit XNU (Darwin 20)

Assuming that instructions from https://kernelshaman.blogspot.com/2021/01/building-xnu-for-macos-big-sur-1101.html were already followed including for the iPhoneOS target…

The patch:

diff --git a/config/Private.exports b/config/Private.exports
index 28b023dd..ebaba915 100644
--- a/config/Private.exports
+++ b/config/Private.exports
@@ -589,15 +589,6 @@ _current_persona_get
 _persona_put
 _pffinddomain:_pffinddomain_old
 _pffindproto:_pffindproto_old
-_pmap_claim_reserved_ppl_page
-_pmap_free_reserved_ppl_page
-_pmap_in_ppl
-_pmap_is_trust_cache_loaded
-_pmap_load_legacy_trust_cache
-_pmap_load_image4_trust_cache
-_pmap_lockdown_image4_slab
-_pmap_lookup_in_static_trust_cache
-_pmap_lookup_in_loaded_trust_caches
 _port_name_to_task
 _port_name_to_thread
 _post_sys_powersource
diff --git a/makedefs/MakeInc.def b/makedefs/MakeInc.def
index d53f3e1a..6e646215 100644
--- a/makedefs/MakeInc.def
+++ b/makedefs/MakeInc.def
@@ -65,8 +65,8 @@ MACHINE_FLAGS_ARM64_S8000 = -DARM64_BOARD_CONFIG_S8000
 MACHINE_FLAGS_ARM64_S8001 = -DARM64_BOARD_CONFIG_S8001
 MACHINE_FLAGS_ARM_T8002 = -DARM_BOARD_CONFIG_T8002
 MACHINE_FLAGS_ARM_T8004 = -DARM_BOARD_CONFIG_T8004
-MACHINE_FLAGS_ARM64_T8010 = -DARM64_BOARD_CONFIG_T8010 -mcpu=hurricane
-MACHINE_FLAGS_ARM64_T8011 = -DARM64_BOARD_CONFIG_T8011 -mcpu=hurricane
+MACHINE_FLAGS_ARM64_T8010 = -DARM64_BOARD_CONFIG_T8010 -mcpu=apple-a10
+MACHINE_FLAGS_ARM64_T8011 = -DARM64_BOARD_CONFIG_T8011 -mcpu=apple-a10
 MACHINE_FLAGS_ARM64_BCM2837 = -DARM64_BOARD_CONFIG_BCM2837
 
 
diff --git a/osfmk/arm64/amcc_rorgn.c b/osfmk/arm64/amcc_rorgn.c
index 35128d53..fe0c6f80 100644
--- a/osfmk/arm64/amcc_rorgn.c
+++ b/osfmk/arm64/amcc_rorgn.c
@@ -42,7 +42,6 @@
 #include <arm/pmap.h>
 #include <arm64/tlb.h>
 #include <arm64/amcc_rorgn.h>
-#include <memmap_types.h>
 
 #if HIBERNATION
 #include <arm64/pal_hibernate.h>
diff --git a/osfmk/arm64/locore.s b/osfmk/arm64/locore.s
index b18a335e..1996e094 100644
--- a/osfmk/arm64/locore.s
+++ b/osfmk/arm64/locore.s
@@ -27,7 +27,6 @@
  */
 
 #include <machine/asm.h>
-#include <arm64/hv/hv_regs.h>
 #include <arm64/machine_routines_asm.h>
 #include <arm64/proc_reg.h>
 #include <pexpert/arm64/board_config.h>
diff --git a/pexpert/pexpert/arm64/board_config.h b/pexpert/pexpert/arm64/board_config.h
index 01265fdf..7adb0f23 100644
--- a/pexpert/pexpert/arm64/board_config.h
+++ b/pexpert/pexpert/arm64/board_config.h
@@ -81,7 +81,7 @@
 #define MAX_L2_CLINE                   7
 
 #if DEVELOPMENT || DEBUG
-#define PMAP_CS                        1
+//#define PMAP_CS                        1
 #define PMAP_CS_ENABLE                 0
 #endif
 #endif  /* ARM64_BOARD_CONFIG_T8010 */
@@ -94,7 +94,7 @@
 #define MAX_CPU_CLUSTERS               1
 
 #if DEVELOPMENT || DEBUG
-#define PMAP_CS                        1
+//#define PMAP_CS                        1
 #define PMAP_CS_ENABLE                 0
 #endif
 #endif  /* ARM64_BOARD_CONFIG_T8011 */
@@ -109,7 +109,7 @@
 #define BROKEN_FRIGGING_SLEEP          1 /* Spurious wake: See rdar://problem/29762505 */
 
 #if DEVELOPMENT || DEBUG
-#define PMAP_CS                        1
+//#define PMAP_CS                        1
 #define PMAP_CS_ENABLE                 0
 #endif
 #endif  /* ARM64_BOARD_CONFIG_T8015 */
@@ -126,8 +126,8 @@
 #define T8020_DART_ALLOW_BYPASS        (1 << 1) /* DART allows translation bypass in certain cases */
 #define XNU_MONITOR_NVME_PPL           1 /* NVMe PPL plugin for secure pmap runtime */
 #define XNU_MONITOR_ANS2_SART          1 /* ANS2 SART plugin for secure pmap runtime */
-#define PMAP_CS                        1
-#define PMAP_CS_ENABLE                 1
+//#define PMAP_CS                        1
+//#define PMAP_CS_ENABLE                 1
 #endif  /* ARM64_BOARD_CONFIG_T8020 */
 
 #ifdef ARM64_BOARD_CONFIG_T8006
@@ -151,8 +151,8 @@
 #define T8020_DART_ALLOW_BYPASS        (1 << 1) /* DART allows translation bypass in certain cases */
 #define XNU_MONITOR_NVME_PPL           1 /* NVMe PPL plugin for secure pmap runtime */
 #define XNU_MONITOR_ANS2_SART          1 /* ANS2 SART plugin for secure pmap runtime */
-#define PMAP_CS                        1
-#define PMAP_CS_ENABLE                 1
+//#define PMAP_CS                        1
+//#define PMAP_CS_ENABLE                 1
 #define PREFER_ARM64_32_BINARIES
 #define PEXPERT_NO_3X_IMAGES           1
 #endif /* ARM64_BOARD_CONFIG_T8006 */
@@ -169,8 +169,8 @@
 #define T8020_DART_ALLOW_BYPASS        (1 << 1) /* DART allows translation bypass in certain cases */
 #define XNU_MONITOR_NVME_PPL           1 /* NVMe PPL plugin for secure pmap runtime */
 #define XNU_MONITOR_ANS2_SART          1 /* ANS2 SART plugin for secure pmap runtime */
-#define PMAP_CS                        1
-#define PMAP_CS_ENABLE                 1
+//#define PMAP_CS                        1
+//#define PMAP_CS_ENABLE                 1
 #endif  /* ARM64_BOARD_CONFIG_T8027 */
 
 #ifdef ARM64_BOARD_CONFIG_T8028
@@ -185,8 +185,8 @@
 #define T8020_DART_ALLOW_BYPASS        (1 << 1) /* DART allows translation bypass in certain cases */
 #define XNU_MONITOR_NVME_PPL           1 /* NVMe PPL plugin for secure pmap runtime */
 #define XNU_MONITOR_ANS2_SART          1 /* ANS2 SART plugin for secure pmap runtime */
-#define PMAP_CS                        1
-#define PMAP_CS_ENABLE                 1
+//#define PMAP_CS                        1
+//#define PMAP_CS_ENABLE                 1
 #endif  /* ARM64_BOARD_CONFIG_T8028 */
 
 #ifdef ARM64_BOARD_CONFIG_T8030
@@ -202,8 +202,8 @@
 #define XNU_MONITOR_NVME_PPL           1 /* NVMe PPL plugin for secure pmap runtime */
 #define XNU_MONITOR_ANS2_SART          1 /* ANS2 SART plugin for secure pmap runtime */
 #define XNU_MONITOR_UAT_PPL            1 /* UAT PPL plugin for secure pmap runtime */
-#define PMAP_CS                        1
-#define PMAP_CS_ENABLE                 1
+//#define PMAP_CS                        1
+//#define PMAP_CS_ENABLE                 1
 #endif  /* ARM64_BOARD_CONFIG_T8030 */

The build command line:

make SDKROOT=iphoneos  ARCH_CONFIGS=ARM64 KERNEL_CONFIGS=DEBUG MACHINE_CONFIGS=T8010 ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG=arm64 USE_WERROR=0

Of course, without kexts that’s not very useful for now… and most macOS arm64 stuff isn’t included yet.

Leave a Reply

Your email address will not be published. Required fields are marked *