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 / GB10_IORT_DECODE.md

282 lines · 17691 bytes Raw Blame History Rendered
1# GB10 IORT decode: stream id, SMMU node, reserved regions (aienos#286, cut B5)
2
3Report only. Host only. Read-only. No kernel code was changed, no hardware
4register was touched, no QEMU run was made. Base commit of aienos read:
5`be514b5` (main). Firmware table read on the Spark on 2026-10-10
6(`/sys/firmware/acpi/tables/IORT`, 3904 bytes, sha256
7`5e0096a2be83ce2025c5c6395455c6814c16e01ff433791e8057c245f4939cb1`).
8
9Tags: [SOURCE file:line] read in the named file or table. [INFERRED] reasoned
10from sources, not directly shown. [UNKNOWN] nothing read answers it.
11Paths without a repo prefix are in aienos. `actbl2.h` is
12`/usr/src/linux-headers-6.11.0-1014-nvidia/include/acpi/actbl2.h` on the Spark
13(ACPICA layout of the IORT, ARM DEN 0049). `linux iort.c` is
14`drivers/acpi/arm64/iort.c` at torvalds/linux master, fetched 2026-10-10.
15
16## 1. Short answer
17
18- The GB10 (PCI segment 15, requester id 0x0100 = bus 1, device 0, function 0)
19 resolves to the SMMUv3 at base `0x13000000` with **StreamID 0x100**, and
20 from there to ITS group 0 with **MSI DeviceID 0x100**. [SOURCE IORT node
21 offsets 0x72c, 0xa0, 0x30; section 4]
22- That SMMU is the **second** SMMUv3 node in the table (node offset 0xa0). The
23 first SMMUv3 node (offset 0x48, base `0x13800000`) serves PCI segments 0 to 14
24 and the USB named components. [SOURCE IORT; section 3]
25- aienos keeps only the first SMMUv3 node and only the root-complex mappings
26 that point at it, so the segment 15 mapping is dropped at parse time and
27 `ck_dma_confine(15, 0x0100, ...)` returns `CK_SMMU_NOSTREAM` on this
28 machine. It fails closed, which is right, but it means **no GB10 DMA can be
29 confined until the kernel drives a second SMMUv3 instance**.
30 [SOURCE native/kernel/core/acpi.c:368-375,384-387; native/kernel/core/smmu_svc.c:110,142-143]
31- StreamID 0x100 is inside the 4096-entry stream table aienos allocates
32 (`STE_N`), so table size is not the obstacle. [SOURCE native/kernel/core/smmu_svc.c:14]
33- The table carries one RMR node (reserved memory ranges) for stream ids 0x0
34 to 0x100 inclusive on the GB10's SMMU, so it covers the GB10. Three physical
35 ranges must stay identity-mapped (Normal Non-cacheable, remap not
36 permitted) for those streams: `0x280000000` + 2 GiB, `0x300000000` + 48 MiB,
37 `0xa1600000` + 386 MiB. Linux exposes exactly these as `direct` reserved
38 regions of the GB10's IOMMU group. [SOURCE IORT node 0xc18; /sys/kernel/iommu_groups/20/reserved_regions]
39 What those ranges hold is [UNKNOWN] (`/proc/iomem` lists
40 `280000000-3237fffff : reserved`, no owner name).
41- Segment 15 is the only root complex with ATS marked supported. Its DMA
42 address limit is 40 bits and it is marked cache coherent. [SOURCE IORT node 0x72c]
43
44## 2. Method
45
461. Read the layout first: `actbl2.h` structs `acpi_iort_node` (:470),
47 `acpi_iort_id_mapping` (:492), `acpi_iort_root_complex` (:549),
48 `acpi_iort_smmu_v3` (:603), `acpi_iort_rmr` and `acpi_iort_rmr_desc`
49 (:640-651), and the id-range rule from `linux iort.c:361`
50 (`rid_in > map->input_base + map->id_count` means ranges are inclusive;
51 `id_count` is the number of ids minus one). Both recorded with `docs-read`.
522. Dumped the table (root read of `/sys/firmware/acpi/tables/IORT`) and decoded
53 it with `scripts/iort_decode.rs` (Rust, standard library only, reads a file,
54 touches no hardware). `scripts/gb10_iort_decode.sh` does both steps.
553. Ground check against Linux (section 5) before trusting the decode.
56
57## 3. What the table contains
58
5968 nodes, revision 6, OEM `MEDTEK`. [SOURCE IORT header]
60
61| Node | Offset | What | Mappings |
62|---|---|---|---|
63| ITS group 0 | 0x30 | ITS id 0 | none (terminal) |
64| SMMUv3 A | 0x48 | base `0x13800000`, flags 0x1 (COHACC override), event/pri/gerr/sync GSIV 342/347/340/341 | stream 0x10000..=0x110000 to ITS group, DeviceID = stream + 0x200000 |
65| SMMUv3 B | 0xa0 | base `0x13000000`, flags 0x1, GSIV 366/371/364/365 | stream 0x0..=0x10000 to ITS group, DeviceID = stream |
66| SMMUv3 C | 0xf8 | base `0x14900000`, flags 0x1, GSIV 397/0/395/396 | none (no MSI path) |
67| Named USB0..USB5, UBF0..UBF3 | 0x150..0x36c | platform USB controllers | single stream 0x0..0x9 on SMMUv3 A |
68| Root complex seg 0..14 | 0x3a8..0x6f0 | ATS 0, 40-bit, coherent | rid 0x0..=0xffff to SMMUv3 A, stream base 0x10000 * (seg + 1) |
69| Root complex seg 15 | 0x72c | **ATS 1**, 40-bit, coherent | rid 0x0..=0xffff to **SMMUv3 B**, stream = rid |
70| Named HDA0 | 0x768 | audio | single stream 0x500 on SMMUv3 B |
71| Named ROT0/1, DSP1..3, CNT0, ASD0, I2C0..6, SPI0/2/3, PMU0, DMA0 | 0x7a4..0xbdc | platform peripherals | single streams on SMMUv3 C |
72| RMR | 0xc18 | flags 0x10: remap NOT permitted, unprivileged, attributes Normal NC; 3 ranges (section 1) | stream 0x0..=0x100 on SMMUv3 B |
73| PMCG x17 | 0xc98..0xf18 | performance monitor pages per SMMU | none |
74
75[SOURCE IORT decode, full listing reproduced by `scripts/gb10_iort_decode.sh`]
76
77## 4. Resolution walk for the GB10
78
79```
80segment 15, rid 0x0100
81 root complex @0x72c map in 0x0..=0xffff out 0x0 -> SMMUv3 B @0xa0 StreamID 0x100
82 SMMUv3 B @0xa0 map in 0x0..=0x10000 out 0x0 -> ITS group @0x30 DeviceID 0x100
83```
84
85The PCIe root port of that segment (`000f:00:00.0`, rid 0x0000) is StreamID
860x0 on the same SMMU. [INFERRED from the same mapping]
87
88## 5. Ground checks (Linux on the same machine, read-only)
89
90| Check | Decode says | Linux says | Result |
91|---|---|---|---|
92| GB10 SMMU | SMMUv3 B, base 0x13000000 | `/sys/bus/pci/devices/000f:01:00.0/iommu` -> `smmu3.0x0000000013000000` | match |
93| Negative control: segments 0 to 9 devices (8 functions) | SMMUv3 A, base 0x13800000 | every `/sys/bus/pci/devices/000[0-9]:*/iommu` -> `smmu3.0x0000000013800000` | match |
94| Number of SMMUs | 3 | `/sys/class/iommu`: 0x13000000, 0x13800000, 0x14900000 | match |
95| RMR covers the GB10 stream | yes (0x0..=0x100 inclusive) | group 20 `reserved_regions`: `a1600000-b97fffff direct`, `280000000-302ffffff direct` (= RMR ranges 2, 1+0 merged) | match |
96| MSI doorbell | ITS group 0 | group 20 `reserved_regions`: `8000000-80fffff msi` | consistent |
97
98The inclusive id-range rule is what makes the RMR cover the GB10: with an
99exclusive reading the RMR would stop at 0xff and Linux would not list those
100regions for group 20. [SOURCE linux iort.c:361; sysfs above]
101
102## 6. What this means for aienos
103
104| Fact | Where in the kernel | Consequence |
105|---|---|---|
106| Parser kept only the first SMMUv3 node (until cut B7a, section 9: now every node, `smmus[]`) | native/kernel/core/acpi.c | until B7a SMMUv3 A was the only SMMU aienos could bring up; B is now brought up by its first confined stream |
107| Root-complex mappings whose output is another SMMU are skipped (`rd32(e + 12) != s.node_off`) | native/kernel/core/acpi.c:386-387 | segment 15 has no mapping in `g.iort`; `ck_iort_stream_id(15, 0x100)` returns -1 |
108| `ck_dma_confine` returned `CK_SMMU_NOSTREAM` (B5), `CK_SMMU_OTHER` (B6); since B7a it routes to SMMUv3 B | native/kernel/core/smmu_svc.c | fail closed throughout: never granted unconfined; a GB10 window now needs a caller (B7b) |
109| Only the named-component path knows the "other SMMU" case (`CK_SMMU_OTHER`) | native/kernel/core/smmu_svc.c:162-167; native/kernel/include/ck.h:116 | the PCI path reports NOSTREAM where OTHER is the truth; a report-only mismatch, not a safety hole |
110| Range test `rel > m->id_count` | native/kernel/core/acpi.c:430 | inclusive, agrees with Linux; no change needed |
111| `STE_N 4096` | native/kernel/core/smmu_svc.c:14 | StreamID 0x100 fits |
112| Window leaf is Normal Non-cacheable | native/kernel/core/smmu_svc.c:16-19 | same attribute the RMR demands (Normal NC), so the RMR ranges could be expressed as windows [INFERRED] |
113| One window plus the stream's RMR ranges per stream (B7a) | native/kernel/core/smmu_svc.c `map_reserved` | the three RMR ranges are identity-mapped beside the window in one stage-1 table |
114
115Gaps a future cut would have to close before any GB10 DMA (design facts, not a plan):
1161. Bring up SMMUv3 B (base 0x13000000) in addition to or instead of A: own
117 stream table, command and event queues, GSIVs 366/371/364/365.
1182. Select the SMMU per root complex, not "the first node"; `ck_iort_parse`
119 would have to carry several SMMU nodes or be called per node.
1203. Honour the RMR for StreamID 0x100: identity windows for the three ranges
121 with Normal NC, or the GPU's firmware traffic into them faults. [INFERRED;
122 what the ranges hold is UNKNOWN]
1234. Keep DMA addresses under 40 bits for segment 15 (address limit 40).
1245. MSI: DeviceID 0x100 at ITS 0 if interrupts are ever used instead of polling.
125
126## 7. Unknowns
127
128- What lives in the three RMR ranges (GPU firmware carveout is a guess, not a
129 reading). [UNKNOWN]
130- Whether SMMUv3 B shares the stream table format and feature set of A (the
131 table says model 0, generic, for all three; the hardware ID registers were
132 not read in this cut). [UNKNOWN]
133- Whether Linux's stream table entry for 0x100 uses stage 1, stage 2 or
134 bypass (not decoded; needs a register read, out of scope here). [UNKNOWN]
135
136## 8. Cut B6 (done, QEMU/host only)
137
138`ck_iort_parse` now remembers every SMMUv3 node and the root-complex mappings
139that target one other than the first (`struct ck_iort_other`,
140`ck_iort_other_stream`), and `ck_dma_confine` returns `CK_SMMU_OTHER` with that
141SMMU and stream named (len 0, never granted) instead of `CK_SMMU_NOSTREAM`.
142Host checks: test_smmu Spark-shape case (segment 15 rid 0x100 -> stream 0x100
143on 0x13000000), `iort-mutants` with the new `CK_IORT_MUTANT_OTHER_BLIND`
144killed, and `ck_acpi_scan --iort` on the real table printing the segment 15
145mapping as not driven. The second SMMU is still not brought up; that is a
146later cut with its own approval.
147
148## 9. Cut B7a (done, QEMU/host only): several SMMUs, RMR honoured
149
150Approval: aienos#286 (comment of 2026-10-10). Hardware boot is cut B7b and
151needs a machine window; nothing here was run on the Spark's SMMUs.
152
153What changed:
154
155- `ck_iort_parse` keeps every SMMUv3 node in table order (`smmus[]`,
156 `nsmmus`, cap `CK_IORT_MAX_SMMUS`) and every RMR node (type 6) that maps
157 to one of them (`rmr[]`: SMMU index, inclusive stream range, flags, up to
158 `CK_IORT_MAX_RMR_RANGES` page-aligned non-empty ranges). A malformed RMR
159 node (zero or too many descriptors, descriptor array past the node,
160 unaligned or empty range) refuses the whole table, like every other
161 malformed node.
162- `ck_iort_route(segment, rid)` is the one routing lookup: the SMMU index,
163 base and node offset, the stream id, and the RMR nodes covering that
164 stream. `ck_iort_rmr_for(smmu_off, sid)` serves the named-component path.
165- `core/smmu_svc.c` holds one instance block per SMMUv3 node. The IORT is
166 parsed once per boot; an instance is brought up (own stream table, queues,
167 context descriptors, `GBPA.ABORT` first) the first time a stream behind it
168 is confined. `ck_dma_confine` routes through `ck_iort_route`;
169 `ck_dma_confine_named` finds the instance by the component's target node.
170 `CK_SMMU_OTHER` is now reported only for a node the parser did not keep
171 (beyond `CK_IORT_MAX_SMMUS`). `ck_dma_unconfine` looks through every live
172 instance (the same stream id confined on two SMMUs at once is ambiguous
173 and refused with `CK_SMMU_EARG`; stream ids are per SMMU, IHI0070H.a
174 "The StreamID namespace is per-SMMU."). `ck_dma_faults` drains every live
175 instance.
176- RMR: when a confined stream is covered by an RMR node, its ranges are
177 identity-mapped in the same stage-1 table as the DMA window, Normal
178 Non-cacheable, and the confine log says how many. Attributes 4 (Normal NC)
179 and 5 (Normal IWB-OWB) are honoured, both as Normal NC like the window; any
180 other attribute refuses the confinement (`CK_SMMU_FAILED`, fail closed).
181 A stream the RMR names that nobody confines stays aborted. The page-table
182 mapper uses 1 GiB and 2 MiB blocks, so the Spark's 2 GiB range costs two
183 level-1 entries, not a page table per 4 KiB.
184
185Behaviour on the Spark that this cut does NOT change: USB0..USB5 and
186UBF0..UBF3 (the xHCI path) sit on SMMUv3 A (section 3), so the keyboard and
187recovery flows still touch only the first SMMU. SMMUv3 B is brought up only
188when a caller confines a segment 15 requester (the GB10) or HDA0; no such
189caller exists yet (that is cut B7b, with its own approval and a machine
190window).
191
192Checks (host, QEMU): `test_smmu` Spark-shape case with the RMR node
193(`route(15, 0x100)` -> instance 1, base 0x13000000, stream 0x100, one RMR
194with three ranges; `0x101` has none; `route(4, 0x100)` -> instance 0 stream
1950x50100; malformed RMR nodes refused), `iort-mutants` with three new killed
196mutants (`CK_IORT_MUTANT_RMR_BLIND`: RMR nodes ignored;
197`CK_IORT_MUTANT_RMR_EXCLUSIVE`: stream range read as exclusive, dropping
198stream 0x100; `CK_IORT_MUTANT_ROUTE_FIRST`: every requester routed to the
199first SMMU), sanitizer build, the freestanding build, the QEMU gates (one
200SMMU on QEMU virt: behaviour unchanged), and `ck_acpi_scan --iort` on the
201real table printing the three instances, the segment 15 route to instance 1
202and the RMR node.
203
204Still unknown after this cut: everything in section 7, plus whether SMMUv3 B
205comes up with this driver's geometry (IDR0/IDR1 read only at B7b).
206
207## 10. Cut B7b preparation (done, QEMU/host only): the probe image
208
209Approval: Drake's ruling of 2026-10-10 (aien-architecture#190, item 5): B7b
210*preparation* is authorized, not an unattended boot. The boot itself needs a
211first operator-confirmed, two-hour attended window after the recovery media,
212rollback, trust and preflight checks pass. Nothing in this cut ran on the
213Spark's SMMUs.
214
215What changed:
216
217- `make [full] CK_B7B_PROBE=1` builds a probe image (own OUT,
218 `target/native-kernel-b7b-probe`; allowed with `CK_HARDWARE_STAGING`).
219 After `kernel: alive` and before the secondary cores start, `ck_b7b_probe`
220 (core/smmu_svc.c) runs once: it prints the IORT route for PCI segment 15
221 requester 0x100, confines that requester on a one-page DMA window through
222 the normal `ck_dma_confine` path (which brings up the SMMUv3 node behind
223 it and identity-maps its RMR ranges, section 9), reads `SMMU_IDR0` and
224 `SMMU_IDR1` of that node (read-only registers: "Access to this field is
225 RO", IHI0070H.a 6.3.1 and 6.3.2), unconfines, and prints one summary line
226 `AIENOS_B7B_PROBE: CONFINED_AND_RELEASED | REFUSED | FAIL`. No DMA is
227 started and the window page is never handed to a device.
228- `CK_B7B_PROBE_TEST_SEGMENT0=1` (TEST-ONLY, needs `CK_B7B_PROBE=1`, refused
229 with `CK_HARDWARE_STAGING` in the Makefile and by an `#error` in the
230 source) probes segment 0 instead, so QEMU exercises the granted path.
231- The image checks (`b7b_check`) refuse a default image that carries the
232 probe, a probe image that lacks it, and any image that carries the
233 segment-0 announcement without its flag.
234- Gate `scripts/qemu_ck_b7b_probe_test.sh` (also a CI step in
235 `.github/workflows/ck-kernel.yml`):
236 - default: the Spark-target probe image on QEMU virt (one SMMUv3, no
237 segment 15) must refuse, fail closed: `route none`, `confine refused
238 rc=-3 (nostream)`, nothing confined, summary `REFUSED`, the boot goes on
239 to the SMP summary, no panic. Local run 2026-10-11: PASS.
240 - `--positive`: the TEST-ONLY segment-0 image must route to instance 0
241 stream 0x100, confine one page, read IDR0/IDR1 with a SIDSIZE that
242 covers 0x100, unconfine with rc 0 and print `CONFINED_AND_RELEASED`.
243 Local run: PASS (QEMU 0x9050000: idr0=0x0d44101a idr1=0x02730010,
244 ST_LEVEL 1, SIDSIZE 16).
245 - `--self-test`: canned logs for 19 cases (2 that must pass, 17 that must fail: (something
246 granted on the refusal image, wrong segment, other refusal reason,
247 missing or doubled summary, boot stopped, panic, probe before `kernel:
248 alive`, a route found where none should be, the TEST image on the gate,
249 and on the positive path: no announcement, unconfine failure, SIDSIZE
250 too small, no IDR line, wrong window, forged summary)) plus four Makefile
251 refusals. Local run: PASS.
252
253What the B7b window would show on the Spark (expected from sections 3 and 9
254and `ck_acpi_scan --iort` on this machine's table, not observed):
255
256 b7b_probe: start segment=15 rid=0x100 window_bytes=4096 no_dma=yes
257 b7b_probe: route instance=1 base=0x13000000 stream=0x100 rmr_nodes=1 (smmus=3)
258 smmu: instance 1 up base=0x13000000
259 smmu: stream 0x100 on 0x13000000: 3 firmware-reserved range(s) identity-mapped beside the window
260 b7b_probe: confined stream=0x100 smmu_base=0x13000000 iova=0x... len=0x1000
261 b7b_probe: instance=1 idr0=0x........ idr1=0x........ st_level=. sidsize=..
262 b7b_probe: unconfine rc=0 (ok); stream 0x100 aborts again
263 AIENOS_B7B_PROBE: CONFINED_AND_RELEASED
264
265Any other summary is a finding, not a retry: `REFUSED` names the reason
266(`nostream`: the route differs from section 3; `failed`: bring-up or an RMR
267attribute was refused), `FAIL` means the unconfine failed or no live
268instance matched the confined base.
269
270Still open before the window (not done in this cut):
271
272- The one-time staging script (`scripts/stage_one_time_boot_ck.sh`) builds
273 the infer image; it has no probe variant yet. Adding one touches the
274 NVRAM staging path and is left for the window's own preparation with
275 Drake.
276- After the probe, SMMUv3 B stays enabled with every stream aborting until
277 the next reset (the same state any unconfine leaves). UNKNOWN whether the
278 GB10 or HDA0 attempt DMA while no OS drives them; an abort there would be
279 recorded as an event, not acted on.
280- The preconditions of the ruling (recovery media, rollback, trust,
281 preflight) are checked by their own procedures
282 (`docs/NATIVE_BOOT_ONE_TIME.md` section 3); this cut does not change them.