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 / native / net / README.md

273 lines · 19020 bytes Raw Blame History Source

native/net: AIENOS M6-A hosted network stack (C)

C port of the Rust reference crates/aienos-kernel/src/net.rs and virtio_net.rs (read as the spec, not extended), plus a framed control-transport stub. No Rust, no Python, no heap, no outside library.

FileWhat it is
aienos_net.{h,c}Ethernet II, ARP + fixed ARP cache, IPv4 (no reassembly), ICMP echo, UDP. Bounded parsers; error order matches the reference.
aienos_virtio_pci.{h,c}virtio 1.x PCI vendor-capability walk over a config image (no device access). Accepts the real QEMU virtio-net-pci layout (see Lane 26 below).
aienos_virtio_net.{h,c}Lane 26: virtio-net driver core, split virtqueues, polled. New C written from the virtio 1.x spec (the Rust reference has no queue code). Device access only through a small ops struct.
aienos_ctl.{h,c}Control-transport stub: authenticated frames, ordered exactly-once delivery, retransmit, link-down. TEST identity only. The frame format is specified in the header.
x25519.{h,c}M6-B: X25519 (RFC 7748), constant-time ladder, small-order outputs refused.
aienos_sec.{h,c}M6-B: mutually authenticated secure control transport over the M6-A UDP framing. TEST identities only. The wire format is specified in the header.
aienos_rtl8127.{h,c}L198: driver core for the Spark's Realtek RTL8127 10 GbE (10ec:8127), polled, one DMA region, TX no-close, RX type 1, interrupts masked. Realtek publishes no datasheet (DOCS SILENT); written from Realtek's Linux r8127 v11.014.00. Tested only against a chip model (tests/rtl8127_test.c); never run on the chip. Details and the UNKNOWN list: docs/SPARK_RTL8127.md.
aienos_report.{h,c}L198: a boot report as UDP broadcast datagrams (the iMac wire format, tag as a parameter; the Spark uses AIENUX-SPARK-REPORT).
tcp/L232: native TCP over IPv4/ARP in seeded Omega (tcp.om), with a QEMU gate under loss, reordering and hostile injection, and a hosted hostile corpus. See tcp/README.md. QEMU only; not bound into the kernel NIC path.

Tests (make test, make sanitize)

Deliberate differences from the reference

Not claimed (deferred, with the dependency)

M6-B: secure control transport (hosted)

aienos_sec puts a mutually authenticated, encrypted session between two AIENOS machines. Each datagram is one UDP payload of the M6-A stack. Make targets: make secure runs everything below and prints AIENOS_NET_SECURE: PASS/FAIL; make mutants runs the mutant pass alone.

Scope. The design follows the SIGMA pattern (sign, then MAC), in three messages:

What is proven, hosted only (tests/x25519_test.c, tests/sec_test.c, two in-process machines over real M6-A Ethernet/IPv4/UDP frames):

Not proven:

Mapping onto omega's Fabric. Omega's F5-0 Fabric (src/fabric/fabric.h) takes a `FabTransport {ctx, send(ctx, from, to, msg, len), recv(ctx, self, buf, cap, *len)}, which it treats as untrusted, and a FabAuth {sign, verify}`, which carries a 32-byte tag. The two connect like this:

Lane 26: virtio-net PCI fix and virtqueue data path (hosted)

Update 2026-10-01: the text of this section is the hosted-lane record. The driver is now bound in the C kernel (#200 d75a266, #203 9807281, native/kernel/dev/net_bind.c) and the NET gate passes in QEMU only (slirp UDP round trip; the last receipt predates Lane 31; Lane 31 negotiates VIRTIO_F_ACCESS_PLATFORM and adds an out-of-window DMA check to the gate, QEMU PASS with receipt evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log; polled, no IRQs; no physical NIC; TEST keys). The "not proven" list below still holds for real hardware.

The attach bug. The capability walk refused any vendor capability whose region had length 0, before looking at its type. Real QEMU virtio-net-pci always carries a VIRTIO_PCI_CAP_PCI_CFG (cfg_type 5) capability with bar 0, offset 0, length 0, which the virtio 1.x spec allows, so every real QEMU virtio-net device was refused with InvalidRegion. Confirmed on real config space dumped from QEMU 8.2.2 (no guest: the qtest protocol reads the ECAM window while the CPU is paused; tests/fixtures/dump_qemu_virtio_net_cfg.sh re-dumps it). Fix: the BAR / zero-length / overflow checks now apply to the four structures the driver maps (cfg_type 1..4) only; other cfg types are ignored, as the spec requires. The Rust reference has the same bug (left unedited: no Rust work).

The pinned Rust differential still runs, against a reference-compat build (-DAIENOS_VIRTIO_PCI_REFERENCE_COMPAT, test-only). The default build has its own C-only pin, and make diff-check proves the two differ only on records the reference refused as InvalidRegion (1,622 of 200,000).

The data path (aienos_virtio_net): reset, ACK, DRIVER; VERSION_1 required, MAC and ACCESS_PLATFORM (bit 33) accepted if offered, every other feature declined; vnet_init_flags(..., VNET_INIT_REQUIRE_ACCESS_PLATFORM) refuses a device that does not offer ACCESS_PLATFORM before FEATURES_OK (the C kernel uses it, so a NIC that would DMA around the SMMU never runs); FEATURES_OK read back; queue 0 RX and queue 1 TX, power-of-two size up to 256 (downsized to what the device offers); notify offset checked against the notify window; all RX buffers posted before DRIVER_OK; polled (no MSI-X vector, NO_INTERRUPT). Rings and buffers live in one caller region; descriptors are rebuilt from the id on every post and checked inside the region; nothing the device writes is trusted. A used entry with an id out of range or not outstanding, a length over the buffer, a short RX completion, or a used index running ahead marks the device broken (sticky) until re-init.

Tests (tests/vnet_test.c, in make test and make sanitize):

Not proven (do not read more into the PASS lines): no real device, no real DMA or IOMMU/SMMU mapping, no interrupts, no QEMU slirp round trip, no cache-coherence or MMIO ordering on real hardware, no physical NIC. The only real-QEMU evidence is the static config space. A real QEMU end-to-end needs a guest kernel that drives the device; this module is hosted and the kernel binding belongs to the native kernel lane. (Lane 31: the C kernel binding, native/kernel/dev/net_bind.c, runs this driver in QEMU behind the smmuv3 vIOMMU with ACCESS_PLATFORM required; see gate NET, GATES.md rows 102-112. The ACCESS_PLATFORM attach and the fence rows are QEMU PASS with receipt evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log; hardware NOT_RUN.)

Kernel hook (for the native kernel). After ck_virtio_net_probe accepts the caps: add aienos_virtio_net.c to the stage sources, enable memory space and bus mastering, map the BARs named by the caps, supply vnet_ops (volatile MMIO at BAR + cap offset + off; notify = 16-bit write at the notify window + off), give a DMA-visible region of vnet_mem_size(qsize) bytes with its bus address, and call vnet_init; then poll vnet_rx / vnet_tx_reclaim.