You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 21b8a2b
Browse filesBrowse the repository at this point in the historyBrowse files
kext plan: §9 kext userland tools (port kext_tools, kld backend); no SIP by design
- §9 tool-mapping table: kextstat/kextload/kextunload/kextutil/kextcache/
kextd all open source (kext_tools APSL 2.0); OSKext engine in IOKitUser.
Each is a thin front-end over kld; kmutil is the only non-OSS gap.
- Pick an older (pre-SIP/pre-collections) kext_tools tag on purpose — best
base for a kld-backed loader.
- kld tools kept as the engine, not dropped.
- §6 codesign caveat → 'no SIP/codesign by design', deliberately pre-SIP.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
<li><strong>Boot-critical drivers: same split Apple uses.</strong> Apple <em>does</em> have boot-critical kexts (storage/PCI/console/…) — it loads them via the <strong>Boot Kernel Collection</strong> (the prelinked kernelcache pre-Big Sur), which the <em>bootloader</em> loads alongside the kernel <em>before</em><code>kextd</code>/<code>kernelmanagerd</code> runs; the daemon only does post-boot on-demand loads. NextBSD already has the faithful analog of that boot tier: drivers built into the <code>NEXTBSD</code> kernel (GENERIC) + <code>.ko</code> preloaded by the FreeBSD loader from <code>/boot/kernel</code> (<code>loader.conf</code>). So boot-critical drivers ride that tier (mirroring Apple’s bootloader/collection tier), and <code>.kext</code> bundles + the <code>kextd</code>-derived daemon are the <strong>post-boot, on-demand</strong> tier (mirroring Apple’s daemon tier). <code>OSBundleRequired</code> is load-bearing on Apple (it selects Boot-KC membership) but <em>informational</em> on NextBSD until a bundle-aware boot-collection / loader-preload mechanism exists (a possible future step: teach the loader to preload the <code>.ko</code> out of a <code>.kext</code> bundle, i.e. a real boot collection). <strong>launchd can’t do this tier</strong> — it’s PID 1, started only <em>after</em> root mounts, which already needs the storage driver; so boot-critical loading is inherently a bootloader / kernel-built-in job on Apple <em>and</em> FreeBSD, never a userland daemon. Shrinking <code>loader.conf</code> means building drivers into <code>NEXTBSD</code> or a loader-loaded collection, not moving the work to launchd.</li>
150
151
<li><strong>Dependencies: <code>OSBundleLibraries</code> is decorative.</strong> Real load ordering stays <code>MODULE_DEPEND</code> + <code>linker.hints</code> resolved by <code>kern_linker</code>; the Info.plist dep list is metadata only. Keep the FreeBSD side authoritative (don’t let the two diverge).</li>
151
-
<li><strong>No codesign/SIP.</strong> Apple’s <code>kextd</code>/<code>kextutil</code>validate signatures; the ported loader stubs that out. A behavior divergence to document, not a blocker.</li>
152
+
<li><strong>No codesign/SIP — by design.</strong>NextBSD does not want SIP or kext signature enforcement, so this isn’t a reluctant stub-out: we deliberately port a <em>pre-SIP</em>, pre-codesign <code>kext_tools</code> (§9) where that machinery doesn’t exist yet. Apple’s modern <code>kextd</code>/<code>kextutil</code>gate on signatures; we drop the check entirely and never add it back.</li>
152
153
<li><strong>Matching is userspace, not in-kernel.</strong> Personalities feed the libIOKit→hwregd matcher, not an in-kernel IOCatalogue driving <code>probe/score/start</code> (that’s newbus, and the XNU rework we’re not doing).</li>
153
154
</ul>
154
155
@@ -158,6 +159,7 @@ <h2 id="sequencing">7. Effort & sequencing</h2>
<li><strong>This <code>.ko</code>→<code>.kext</code> conversion</strong> — establishes the bundle format + personalities + <code>/System/Library/Extensions</code>, with the interim <code>kld</code> loader. <strong>Lands before kextd porting</strong> (kextd must load this format). Can start now; no dependency on the busyState/EVFILT phases.</li>
160
161
<li><strong>kextd porting</strong> (device-matching convergence #177) — the ported <code>kextd</code> loads the <code>.kext</code> bundles this conversion produces, driven by match-notifications + <code>waitQuiet</code>.</li>
162
+
<li><strong>kext userland tools</strong> (§9) — port <code>kextstat</code>/<code>kextload</code>/<code>kextunload</code>/<code>kextutil</code> as front-ends over <code>kld</code>; rides in <em>this</em> epic (they consume the bundles, so they don’t gate the converter, but they ship together so the system is genuinely Apple-shaped).</li>
161
163
<li><strong>3rd-party kexts — same <code>nextbsd-kernel-modules</code> repo</strong> (not a separate repo): convert <code>drm-kmod</code> and other pkg kmods with the same workflow. Option: one combined <code>drm</code> bundle carrying the driver(s) + all GPU firmware, resolved at runtime by the driver’s existing ASIC→name <code>firmware_get</code> (see §4).</li>
<p><strong>Repo split:</strong> the lever is <code>nextbsd-kernel/config/NEXTBSD</code> (today just a <code>GENERIC</code> passthrough — this is where the <code>options</code> land). The one real refactor is <strong>mach-into-kernel</strong>: mach builds out-of-tree as <code>mach_kmod</code> in <code>nextbsd</code>; <code>options MACH</code> means adding its sources + a <code>files</code>/config entry via the kernel <strong>patch series</strong> (never touching <code>freebsd-src</code>). <code>nextbsd</code> drops the <code>*_load</code> lines as they migrate; <code>nextbsd-kernel-modules</code> converts drivers to kexts and stops shipping dead <code>.ko</code>; <code>nextbsd-freebsd-compat</code> owns any residual boot-config/userland glue. Scoped under its own ticket; sequence it alongside the built-ins work, independent of the kextd port.</p>
185
187
188
+
<h2id="userland">9. kext userland tools (port from <code>kext_tools</code>)</h2>
189
+
<p>If we’re converting <code>.ko</code>→<code>.kext</code>, we port Apple’s tools too — not as polish but so the system is genuinely Apple-shaped. The whole family except <code>kmutil</code> is <strong>open source</strong>: <code>kext_tools</code> (APSL 2.0, on <code>opensource.apple.com</code> / <code>apple-oss-distributions/kext_tools</code>) ships the CLI + daemon source, and the bundle/load engine <code>OSKext</code> lives in <code>IOKitUser</code> (<code>kext.subproj/OSKext.c</code>, also APSL) — the same <code>libIOKit</code> lineage already being ported for device matching. Because the backend is <code>kld</code>, each tool is a thin front-end:</p>
190
+
<table>
191
+
<thead><tr><th>Apple tool</th><th>Source</th><th>NextBSD port = front-end over…</th></tr></thead>
192
+
<tbody>
193
+
<tr><td><code>kextstat</code></td><td><code>kext_tools</code> (APSL 2.0)</td><td><code>kldstat(2)</code> — list loaded</td></tr>
194
+
<tr><td><code>kextload</code></td><td><code>kext_tools</code></td><td><code>kldload(2)</code> of the inner <code>.ko</code> + register <code>IOKitPersonalities</code></td></tr>
<tr><td><code>kextcache</code></td><td><code>kext_tools</code></td><td>collection builder — ties to <strong>#180</strong> boot collection</td></tr>
199
+
<tr><td><code>kmutil</code></td><td><em>not open source</em></td><td>present a <code>kmutil</code>-shaped front later if wanted; build from <code>kext_tools</code></td></tr>
200
+
</tbody>
201
+
</table>
202
+
<p><strong>Pick an older <code>kext_tools</code> tag on purpose.</strong> Apple publishes <code>kext_tools</code> per macOS release, and older revisions are <em>substantially</em> simpler — pre-SIP, pre-codesign-enforcement, pre-kext-collections, no <code>kmutil</code>. That is exactly the shape that maps onto a <code>kld</code>-backed loader, so an older <code>kext_tools</code> + matching <code>IOKitUser</code> is the better porting base than current main.</p>
203
+
<p><strong>What we do <em>not</em> drop:</strong><code>kldload</code>/<code>kldstat</code>/<code>kldxref</code> remain the <em>engine</em> — <code>kextd</code> calls <code>kldload</code>, <code>kextstat</code> reads <code>kldstat</code>, <code>kldxref</code> still builds <code>linker.hints</code> (its PNP role is <em>supplemented</em> by <code>IOKitPersonalities</code>, not replaced). The <code>kext*</code> tools become the front; <code>kld</code> stays the back. Fully removing <code>kld</code> would mean reimplementing XNU’s in-kernel <code>OSKext</code> loader — out of scope (§1).</p>
204
+
186
205
<pclass="footnote">Conversion plan, 2026-06-03. Gates the kextd port in the <ahref="nextbsd-apple-device-matching-plan.html">device-matching convergence (#177)</a>. Sourced from XNU <code>OSKextLib.h</code> + Apple KEXT/IOKit docs, <code>freebsd-src@releng/15.0</code> (<code>sys/sys/module.h</code>, <code>usr.sbin/kldxref</code>, <code>sys/sys/firmware.h</code>, <code>sys/conf/kmod.mk</code>), the firmware ports, and a ravynOS/Darling/PureDarwin prior-art pass (none package <code>.ko</code> as <code>.kext</code>).</p>
0 commit comments