← Back to Blog
MILESTONE · 0.7.0 · KERNEL · x86 · USB

VT-d IOMMU Bring-Up + xHCI Port Routing — Real-Metal Keyboard Enumeration

kernelx86iommuvt-dxhciusbreal-metalmilestone0.7.0

Real-metal x86 keyboard fully enumerated through xHCI with VT-d IOMMU present. Enable Slot works, HSE cleared, slots 2→5 COMPLETE. The x86 USB keyboard hardware path is proven on @grio's real hardware.

New: hal/x86/vtd.sg

Intel VT-d / IOMMU bring-up. Parses ACPI DMAR table to find the IOMMU. Key insight: augment the BIOS's live root/context table — don't replace it. Replacing clobbered the BIOS QIE/IRE/TE bits and faulted the device. Instead, set the xHCI bus's context entries to pass-through in place and invalidate, leaving GCMD/TE untouched. Per-step on-screen diagnostic row for debugging.

VT-d turned out present-but-disabled on @grio's machine. This code handles the "on" case for the secure-pillar requirement — when VT-d is active, DMA from the xHCI controller must be permitted through the IOMMU or transfers silently fail.

xHCI port routing

Intel PCH routing
XUSB2PR=XUSB2PRM, USB3_PSSEN=USB3PRM — vendor-gated port switchover moves USB2 ports off the companion EHCI controller to xHCI. Without this, the keyboard stays on EHCI and xHCI never sees it.
VT-d before DMA
vtd_setup() called before any xHCI DMA operations — ensures IOMMU pass-through is configured before the first transfer descriptor hits the bus.
USBLEGSUP handoff
BIOS→OS ownership transfer for xHCI. Enable Slot succeeds after handoff + HSE clear.
PORTSC.PP
Port power enabled per-port. Required on real metal; QEMU auto-powers ports.

Result on real hardware

Enable Slot works. HSE cleared. Slots 2→5 enumerated COMPLETE — keyboard fully enumerated with VT-d present. The xHCI driver changes (USBLEGSUP handoff, PORTSC.PP port power, register-paint diagnostic, HID-poll fast-path, report markers) are in the sigil-drivers submodule.