G6: one DRM device numbering across drivers (misc/drm_minor) and Linux's ioctl size rule #8
Loading…
Reference in a new issue
No description provided.
Delete branch "g6-minors"
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?
Anima work item: G6
01a0f442-2d58-7593-9ed4-ccb0a7ba22a9Stacked on #7 (
r4-virtio-gpu, itself on #6 and #5). Two things: one DRM device numbering for every driver built on the core, and Linux'sdrm_ioctl()argument size rule for the core and mode-setting ioctls.What was built
misc/drm_minor(modules/drm-minor, bindings incrates/drm-minor-sys)drm_minor_alloc(owner)anddrm_minor_free(id, owner).id_space(9F)id_freeof an unallocated id would panic instead._finirefuses while a number is taken.ld -B reduce, so only_init,_fini,_infoand the two functions are global. CI and the test scripts check this.packaging/drm-minor.p5m(lints clean; published to a scratch repo on oibldofgate).virtio-gpu.p5mnow depends on it.Numbering
Nwhen it attaches and gives it back when it detaches. Its nodes arecard<N>andrenderD<128+N>, with node minorsNand128+N.drm::minor::bind).instance_of_minorreads that record, so the instance number is no longer limited to 63.drm-minor-sysdeclaresdepends = ["misc/drm_minor"], socargo xtask linkadds-N misc/drm_minorandkernel-checkcovers both symbols.Argument sizes
Ucomes from the command.drm::ioctl::SizePlanis the Linux computation.drm::uaccess::CoreArgapplies it.CoreArgdeliberately does not dereference toIoctlArg, so a core handler cannot fall back to an exact-size copy by accident.ENOTTY, and ILP32 callers still getENOTSUP.Numbering: the decision and the alternatives
(a) A separate misc module with a C ABI: chosen.
-N, and keeps it loaded while such a driver is loaded. So the table outlives every number in it, for any load and unload order.drm.ko), and it is the first piece of the R5 C interface.(b) A registry that the first driver creates behind a well-known symbol: rejected.
unix,genunix, the module itself and its-Ndependencies (illumos-ddi DESIGN §4). The other drivers would needddi_modopenat run time.(c) Stateless schemes: rejected.
card<N>names races with concurrent attaches.Deviations from Linux 7.3's
drm_minor_allocdrm/i915still number their nodes by instance (open issue below).The Linux size rule matched (
drm_ioctl(), read at v7.3-rc5)Linux uses these sizes:
in = Uif both commands haveIOC_IN, otherwise 0.out = Uif both haveIOC_OUT, otherwise 0.max(in, out, K)bytes, whereKis the kernel's size.It copies
inbytes in, zeroes the rest, hands the handlerKbytes, and copiesoutbytes back. So:Ubytes come back.EFAULT) and copied back unchanged by_IOWRcommands, come back as zeros from_IORcommands, and are ignored by_IOWcommands.The core now does exactly this. A host test checks it against a restatement of Linux's code for every table entry, all four directions and every size from 0 to 255.
Remaining differences, documented in the README:
ENOTTY. Linux uses the intersection of both directions.ENOTTY. Linux returnsEINVAL.The four grown commands are served at both sizes with equal results:
SYNCOBJ_HANDLE_TO_FDandFD_TO_HANDLE(16 → 24 bytes),WAIT(32 → 40) andTIMELINE_WAIT(40 → 48). The addedpointanddeadline_nsecfields are carried through unread. Their flags are unknown flags (EINVAL), as on a Linux kernel from before them.Test evidence
Host (macOS, Rust 1.97.1 and nightly-2026-04-16)
cargo test -p drm -p drm-uapi -p drm_minor: 115 + 1 + 4 passed.cargo test -p virtio_gpu --no-default-features: 5 passed.-D warningsis clean, including with thepanic-drillfeature.cargo doc -D warnings,uapi-check: 0 differences.cargo xtask build drm_minor rdrmnull virtio_gpusucceeds, and all three link withldon illumoscda5b9a49f(oibldofgate).Guest (hephaistos, fresh overlay of
golden-20260930: illumos7e802e88a3, osnet 23295, QEMU 6.2virtio-gpu-gl-pci, 2 vCPUs, 3 GiB, port 2410)1e68727) is installed in the overlay only.tools/test/run-g6-test.shpassed: 354 PASS, 0 FAIL. Log:logs/hephaistos/illumos-drm/20261001-g6-run1.log. Per-test outputs:artifacts/g6-minors/run1-outputs/. Kernel archives built from0155ded, scripts atbc5b0d4.virtio_gpufirst, then twordrmnulldevices):card0/renderD128(virtio),card1/renderD129andcard2/renderD130(rdrmnull@0 and @1). The minors match.rdrmnullfirst): rdrmnull gets 0 and 1, virtio gets 2.drmdevicereports 3 devices, andgetsundevpasses 73 checks, 0 failed. It reports 2 and 1 devices after unloads.drm_r4_testpasses on virtio ascard0and ascard2(63 checks each).drm_g6_testpasses on every device (27 checks each).modetestlists every display.misc/drm_minorrefuses to unload while any driver is loaded, and unloads after both. Loadingrdrmnullloads it.virtio_gpu:run-r4-test.sh(KEEP=1, 72 checks),run-r1-test.shwith two rdrmnull devices (513) andrun-r3-test.sh(477) all pass./etc,/devicesand their/dev/drilinks are unchanged.20261001-g6-run1-attempt1.loghas the same kernel results. Its failures were script bugs, fixed inbc5b0d4.Also fixed: the
run-r1-test.sh/run-r3-test.shrace. They grepped/var/adm/messagesfor "detach refused" before syslogd had written it. They now poll with a bounded wait (wait_log, up to 15 s).Review
The Anima review bar, applied locally (anima-review), approved round 1 with non-blocking items. All were addressed in
b7c94e7:Round 2 on
b7c94e7: approve. It asked that the scope of the guest evidence be stated plainly (done incc3f1acand below).Open issues / not done
b7c94e7is deferred: the attach ordering change and the anon id-space name. The test host was taken down right after the run. These changes are covered only by host tests, the cross-build and illumos linking.cargo xtask kernel-checkwas not run against a kernel withdrm_minorloaded. The guest run's::whatisshows both functions resolving fromdrm_minor.drm/i915still name nodes after their instance number, so an i915 device and an illumos-drm device can both claimcard0until gfx-drm usesdrm_minor_alloc(R5).ddi-no-autodetachis open.cargo xtask deps rdrmnulllistsmisc/virtio, because cargo unifies the features ofddiacross the workspace. CI and the scripts link with explicit flags.Resume the guest verification
Verification of the final head
1 October 2026, at
cc3f1ac(the kernel code ofb7c94e7; archive SHA-256drm_minor.a2e115b53…,rdrmnull.aab88f310…,virtio_gpu.a51785d75…), on a fresh overlay ofgolden-20260930(illumos7e802e88a3), guestg6-run2on port 2411, gfx-drm's libdrm 2.4.134 (1e68727) installed in the overlay only:run-g6-test.shpassed: 354 PASS, 0 FAIL, with the same results as the earlier run:drmdevicereports 3, 2 and 1 devices;getsundev73/49/25 passed, 0 failed.drm_r4_testpassed 63 checks as card0 and as card2.drm_g6_testpassed 27 checks on each device.misc/drm_minorrefusing to unload while a driver is loaded.run-r4-test.sh(72 checks),run-r1-test.sh(513) andrun-r3-test.sh(477) pass beside an attached virtio_gpu;/etcand/devicesare unchanged.cargo xtask kernel-checkwithmisc/drm_minorloaded:drm-minor-syssymbols 2/2 (both resolve fromdrm_minor),ddi-syssymbols 984/984 and offsets 185/185,illumos-kernel-private-sys13/13 symbols and 21/21 offsets,illumos-kernel-private-virtio-sys48/48 symbols. No errors.logs/hephaistos/illumos-drm/20261001-g6-run2.loglogs/hephaistos/illumos-drm/20261001-g6-run2-install.loglogs/hephaistos/illumos-drm/20261001-g6-run2-kernel-check.logartifacts/g6-minors/run2-outputs/logs/hephaistos/illumos-drm/g6-console/run/g6-run2/This closes the two items deferred above: the guest run of the post-review kernel code and kernel-check.