Skip to content

XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)

C

Probe: declare pmap_find_phys locally (not visible in vm_unix.c)

Heyang Zhou923fe36fd819
diff --git a/xnu-patches/0001-linux64-stage-hook.patch b/xnu-patches/0001-linux64-stage-hook.patch
index 0676a09..b668e21 100644
--- a/xnu-patches/0001-linux64-stage-hook.patch
+++ b/xnu-patches/0001-linux64-stage-hook.patch
@@ -337,10 +337,10 @@ index e5e58b5..6e6596d 100644
}
diff --git a/bsd/vm/vm_unix.c b/bsd/vm/vm_unix.c
-index d8fd4af..61033bd 100644
+index d8fd4af..815051f 100644
--- a/bsd/vm/vm_unix.c
+++ b/bsd/vm/vm_unix.c
-@@ -1917,6 +1917,28 @@ _shared_region_map_and_slide(
+@@ -1917,6 +1917,29 @@ _shared_region_map_and_slide(
proc_getpid(p), p->p_comm, kr));
}
@@ -356,8 +356,9 @@ index d8fd4af..61033bd 100644
+ kprintf("linux64: shared region data mapping at 0x%llx size 0x%llx from 0x%llx: sees %d %016llx %016llx %016llx, source %d %016llx %016llx\n",
+ m->sms_address, m->sms_size, m->sms_file_offset, e1, w[0], w[1], w[2], e2, src[0], src[1]);
+ {
++ extern uint32_t pmap_find_phys(struct pmap *, uint64_t);
+ pmap_t upmap = get_task_pmap(current_task());
-+ ppnum_t pn = pmap_find_phys(upmap, (addr64_t)m->sms_file_offset);
++ uint32_t pn = pmap_find_phys(upmap, (uint64_t)m->sms_file_offset);
+ uint64_t pa = ((uint64_t)pn << PAGE_SHIFT) | (m->sms_file_offset & PAGE_MASK);
+ kprintf("linux64: source pn 0x%x pa 0x%llx via phys %016llx %016llx; PAR after AT S1E0R: 0x%llx\n", pn, pa,
+ pn ? ml_phys_read_double_64(pa) : 0, pn ? ml_phys_read_double_64(pa + 8) : 0, ({ uint64_t par; __asm__ volatile ("at s1e0r, %1\n isb\n mrs %0, par_el1" : "=r"(par) : "r"(m->sms_file_offset)); par; }));