interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / IMAC_DMAR_INVENTORY.md

71 lines · 4035 bytes Raw Blame History Rendered
1# iMac DMAR firmware inventory
2
3This implements the first discovery step of
4[aienux #411](https://github.com/aien-dev/aienux/issues/411). It does not
5implement or qualify device DMA confinement. Existing device startup continues
6unchanged after the inventory, including when the table is absent or refused.
7The image must not be treated as safe for sensitive memory or unrestricted
8remote operations on the strength of this inventory.
9
10## Implementation
11
12`native/kernel/core/dmar.c` reads one explicitly bounded byte buffer using
13the format in the [Intel VT-d Architecture Specification, revision 5.0,
14sections 8.1 through 8.4](https://cdrdv2-public.intel.com/831418/vt-directed-io-spec.pdf).
15It checks the signature, declared size, checksum, revision, reserved fields,
16entry ordering, nested lengths, device/function bounds, remapping-unit
17alignment and reserved-region range/alignment. It retains DRHD units, their
18device scopes, and RMRR reserved ranges with their scopes. Other structure
19types are counted and skipped by declared length, as the specification requires.
20Skipping them is not a declaration that their requirements are supported.
21
22Storage is fixed: at most 64 KiB of table bytes, eight units, sixteen regions,
2364 scopes across both owner types and eight device/function pairs per path.
24Oversized inventories return a capacity error. Unknown scope types or table
25revisions return unsupported. Every failure clears the output, including
26failures after valid entries. There is no allocation, register access or
27device configuration in the parser.
28
29`native/kernel/x86/dmar_x86.c` locates the table with the existing checked ACPI
30lookup, inventories it before PCI drivers start, and prints `dmar:` diagnostics.
31It retains segment numbers and complete paths. A one-hop path has a direct
32source ID. A longer path remains unresolved until each bridge's secondary bus
33has been read; the last path element alone is insufficient. A subhierarchy
34also needs downstream enumeration. Reserved regions are reported as firmware
35requirements, never treated as granted windows.
36
37The report ends with `inventory-only register_access=none; DMA confinement
38NOT QUALIFIED`. Absence, invalid data and refusal also explicitly state that
39confinement is not qualified. The optional lab diagnostic report allowlists
40these lines. Its existing unauthenticated status remains unchanged. Default
41images still contain no network report.
42
43## Verification
44
45The host test `native/kernel/tests/test_dmar.c` covers a multi-segment fixture,
46multi-hop device paths, an IOAPIC, a reserved region, an unknown structure,
47every truncated prefix, corrupt fields, capacity exhaustion and a 64-bit
48address boundary. The same test runs with address and undefined-behavior
49sanitizers through the normal kernel host targets.
50
51`scripts/qemu_ck_imac_kernel_test.sh` checks that the default simulated machine
52reports the absent table without claiming protection. Setting
53`AIENOS_IMAC_DMAR=1` adds QEMU's Intel IOMMU device and requires a parsed unit,
54IOAPIC scope and inventory-only marker under both existing CPU models. These
55are firmware discovery tests. They neither enable remapping nor test blocked
56DMA. The existing read-only disk checks and deliberate W^X failures remain.
57
58`scripts/ck_imac_report_test.sh` checks that inventory diagnostics survive the
59allowlist while chat, keys and tokens remain excluded. Its lab build uses the
60existing explicit test-key option solely for this hosted test. No hardware
61staging image is produced by that script.
62
63## Remaining work
64
65Read and preserve the actual iMac's map on an explicitly authorized, attended
66boot. Resolve all relevant device paths against its PCI topology and account
67for reserved memory and any additional DMAR structures. Then implement and
68test domain construction, approved windows, invalidation, fault handling and
69fail-closed driver lifecycles. Physical out-of-window DMA and device recovery
70tests are still required by #411. No isolation claim follows from a successful
71inventory or an emulator boot.