Skip to content

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

C

hook: count but do not print the per-entry startup trace

Heyang Zhoub427ca3957f0
diff --git a/xnu-ko/xnu_main.c b/xnu-ko/xnu_main.c
index b2e4331..cbcae40 100644
--- a/xnu-ko/xnu_main.c
+++ b/xnu-ko/xnu_main.c
@@ -126,7 +126,9 @@ long xnu_hook(unsigned long stage, unsigned long a1, unsigned long a2)
m[j++] = 'x'; m[j++] = 'n'; m[j++] = 'u'; m[j++] = ']'; m[j++] = ' ';
while (f && f[i] && j < sizeof(m) - 1) { if (f[i] != '\n') m[j++] = f[i]; i++; }
m[j] = 0;
- logs(m);
+ /* the per-entry startup trace is thousands of lines: count it, do not print it */
+ if (!(f && f[0] == 'k' && f[22] == '[' && f[23] >= '0' && f[23] <= '9'))
+ logs(m);
if (kmax && ++kcount >= kmax) { logs("xnu: kprintf budget reached"); return 1; }
return 0;
}