Skip to content

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

C

XNU patch: hosted platform registers a stand-in sep-endpoint,scrd service (AMFI's device-state thread waits for it by name; launchd's AMFI sysctl waits on that thread)

Heyang Zhoud6f796aa6152
diff --git a/xnu-patches/0001-linux64-stage-hook.patch b/xnu-patches/0001-linux64-stage-hook.patch
index 1a5929d..a942abd 100644
--- a/xnu-patches/0001-linux64-stage-hook.patch
+++ b/xnu-patches/0001-linux64-stage-hook.patch
@@ -386,7 +386,7 @@ index 0cc7f6e..c07d35c 100644
DEBUG_INFO("region = %d\n", currentRegion->type);
cnt = 0;
diff --git a/iokit/Kernel/IOPlatformExpert.cpp b/iokit/Kernel/IOPlatformExpert.cpp
-index 76555f6..0e36dfd 100644
+index 76555f6..c602cc1 100644
--- a/iokit/Kernel/IOPlatformExpert.cpp
+++ b/iokit/Kernel/IOPlatformExpert.cpp
@@ -1540,6 +1540,43 @@ IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
@@ -470,7 +470,7 @@ index 76555f6..0e36dfd 100644
class IOPanicPlatform : IOPlatformExpert {
OSDeclareDefaultStructors(IOPanicPlatform);
-@@ -2361,6 +2419,19 @@ IOPanicPlatform::start(IOService * provider)
+@@ -2361,6 +2419,32 @@ IOPanicPlatform::start(IOService * provider)
platform_name = provider->getName();
}
@@ -484,6 +484,19 @@ index 76555f6..0e36dfd 100644
+ return false;
+ }
+ registerService();
++ /*
++ * No SEP while hosted: AMFI's device-state thread waits forever for the SEP's "scrd" endpoint by name (and
++ * launchd's first AMFI sysctl waits on that thread). A plain registered service of that name lets it go on.
++ */
++ IOService *scrd = OSTypeAlloc(IOService);
++ if (scrd && scrd->init()) {
++ scrd->setName("sep-endpoint,scrd");
++ if (scrd->attach(this)) {
++ scrd->registerService();
++ IOLog("linux64: stand-in sep-endpoint,scrd registered\n");
++ }
++ scrd->release();
++ }
+ return true;
+ }
+