From 9748b5525ed6690037d3c3827a68022f0014649f Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Wed, 1 Jun 2022 01:49:59 +0900 Subject: [PATCH] dart: Only allocate a max of 2 L2 tables This is what iBoot normally does, and >2 will panic macOS Signed-off-by: Hector Martin --- src/dart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dart.c b/src/dart.c index ac8d8473..d7a294ea 100644 --- a/src/dart.c +++ b/src/dart.c @@ -188,8 +188,8 @@ int dart_setup_pt_region(dart_dev_t *dart, const char *path, int device) printf("dart: dart %s ignoring large pt-region-0, %lu L2 tables\n", path, tbl_count); return -1; } - /* first index is the l1 table */ - tbl_count -= 1; + /* first index is the l1 table, cap at 2 or else macOS hates it */ + tbl_count = min(2, tbl_count - 1); u64 l2_start = region[0] + SZ_16K; for (u64 index = 0; index < tbl_count; index++) { int ttbr = index >> 11; @@ -204,6 +204,7 @@ int dart_setup_pt_region(dart_dev_t *dart, const char *path, int device) off, l2tbl); continue; } else { + printf("dart: allocating L2 tbl at %d, %d to 0x%lx\n", ttbr, idx, l2tbl); memset((void *)l2tbl, 0, SZ_16K); }