Framework modules: CharTable glue, Driver::load, unsafe cb_ops; private current_context/servicing_interrupt/module_loaded #8
Loading…
Reference in a new issue
No description provided.
Delete branch "r5a-char-table"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Framework-module support for illumos-drm R5a (
misc/drm_core), stacked on #7 (g1-gate-pin).illumos-drm's DRM core became one kernel module,
misc/drm_core, that serves the character devices its driver modules attach and exports a C facade. This branch adds what such a framework module needs from illumos-ddi, under the panic-to-type rule (docs/DESIGN.md §5.12 rows for every new rule).Public layer
module:CharTable(unsafe trait) andtable_glue— entry points for devices a framework module serves, found by device number instead of the module's own soft state; themodule! { driver: X, cb_ops: unsafe EXPR }form (theunsafeis the caller's promise that the pointer is a valid, 'staticcb_opswhose entry points find its devices;compile_faildoctest for a bare pointer).Driver::load(&Sleepable) -> Result<(), Errno>: a check in_init(9E)before anything is set up (illumos-drm's drivers check the facade version there).TaskQueue::without_node(a module without a device node).IntrPriority::newrefuses 0 and every priority at or aboveddi_intr_get_hilevel_pri()(host tests of the bound, an rselftest check);IntrError::HighLevel/VirtioError::HighLevelcarry the rawu32, so no high-levelIntrPrioritycan be taken out of an error.Private tier (
unstable-gate-cda5b9a49f)private::fd::FileRef::char_dev.private::current_contextis anunsafe fnwhose contract names the contextsservicing_interruptcannot tell from a thread (callouts,quiesce(9E),chpoll(9E), raised PIL, spin locks held);compile_faildoctest.private::servicing_interrupt(): the context question without minting a token.private::module_loaded(modname, &Sleepable): whether a module is loaded, without loading it (the DDI has none:ddi_modopen(9F)loads). Walksmodulesundermod_lockby module name (the framework's own identity; a module's file name is whatever path its latest load used), takes no hold (a hold waits on a busy module, so two modules guarding against each other could deadlock), calls nothing with the lock held. Newillumos-kernel-private-sys::modctl:modctl_t(size 144, 25 offsets),mod_lock,modules, cited atcda5b9a49f. Host tests (name matching, flags),compile_faildoctests (no token, anAtomictoken), rselftest checks (genunix and unix loaded, a made-up name not).Evidence
private-gate;ddilib tests 12 / 18 (virtio feature); doctests 34 passed, 7 ignored on stable and on the pinned nightly (error codes checked);cargo doc -D warnings;lint-manclean for the new citations.7e802e88a3, 3 Oct 2026): illumos-drm'scargo xtask kernel-checkverified the private tier withmisc/drm_coreloaded —illumos-kernel-private-sys: sizes 3/3, offsets 46/46, symbols 15/15(themodctllayout,mod_lock,modules);misc/drm_core's_initrefused withmodule_loaded(c"drm")true while gfx-drm'smisc/drmwas loaded, and loaded once it was gone; the char-table glue,Driver::loadandcb_ops: unsaferan in illumos-drm's full R5a suite (167 checks).kmod-illumosjob (owner's CI).Review
Two review rounds against the anima-review bar (with the illumos-drm R5a branch). Round 1 findings fixed here: B3a (
current_contextunsafe), B3b (IntrPriority::newbound), B3c (cb_ops: unsafe).module! { driver: X, cb_ops: <expr> } accepted any *mut cb_ops in safe code, a null pointer included, which the kernel dereferences at the first open(2). The form is now cb_ops: unsafe <expr>; the keyword is the invoker's assertion that the pointer is a valid 'static cb_ops of table_glue entry points (or functions with their rules) whose module stays loaded, documented on the macro, CharTable and table_glue. The internal @common arm takes the same unsafe, so it is no way around the rule. The ops: forms are unchanged. compile_fail doctest (no rule matches without unsafe) with a compiling twin, the section 5.2 paragraph updated, and a row in DESIGN.md section 5.12.