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 / scripts / qemu_ck_net_test.sh

332 lines · 20319 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Network gate for the AIENOS C kernel: AIENOS_CK_NET (C-only gate; the Rust
18# kernel has no virtio-net queue driver, so there is no Rust counterpart).
19# Boots the full C image (make full) in QEMU AArch64 with UEFI (AAVMF), an
20# NVMe disk (so the boot is the normal full boot) and a virtio-net-pci NIC on
21# QEMU user networking (slirp). QEMU is not hardware: a PASS here qualifies
22# nothing physical.
23#
24# The devices stage (native/kernel/dev/net_bind.c) binds native/net's polled
25# virtio-net driver: SMMU window for its one DMA region first, then memory
26# decode + bus master, vnet_init_flags with VIRTIO_F_ACCESS_PLATFORM required
27# (the NIC is iommu_platform=on,disable-legacy=on, so QEMU sends every ring
28# and buffer access of the device through the smmuv3 vIOMMU), then ARP for the slirp gateway 10.0.2.2 and
29# one UDP datagram from 10.0.2.15:47030 to 10.0.2.2:47029, then device reset,
30# bus master off, SMMU stream back to abort. Slirp forwards 10.0.2.2:47029 to
31# the host's 127.0.0.1:47029, where the in-tree C helper
32# native/kernel/tools/ck_udp_echo.c (make udp-echo; no Python, no nc/socat)
33# answers "AIENOS-CK-NET pong token=<per-run random token> echo=<datagram>".
34#
35# boot 1 iommu=smmuv3: must pass every M1 check (scripts/lib_ck_m1_checks.sh)
36# and show
37# (a) attach: caps parsed, SMMU window for virtio_net, "dma_gate: virtio_net
38# granted (Confined)", "virtio_net: attached ... mac=52:54:00:12:34:56"
39# (QEMU's default NIC MAC), ARP reply from the slirp gateway MAC
40# 52:55:0a:00:02:02;
41# (b) TX: the guest's "net: udp tx ... completed=yes" line (the device
42# returned the TX descriptor) AND the helper's log shows that exact
43# datagram (same nonce) arriving from 127.0.0.1;
44# (c) RX: the guest's "net: udp rx ... udp_csum=verified parsed=m6a
45# echo_of_ours=yes" line carries this run's helper token and the
46# guest's own nonce, and the helper logged its reply;
47# (d) fence: after the round trip the kernel points every RX descriptor the
48# device holds at a 0x5a page outside the window and sends one probe
49# datagram (helper logs it and replies). The SMMU event queue must hold
50# an F_TRANSLATION (0x10) record whose stream id is the NIC's (from the
51# smmu_dma_window line) and whose address is in that page; this script
52# re-checks those printed event fields itself (page outside the window,
53# sid equal, addr in page), the page must read back intact (whether QEMU
54# completes the RX via its bounce buffer is reported, not judged), and
55# the positive round trip must have raised no fault;
56# (e) recovery: device reset + re-init (ACCESS_PLATFORM again) and a second
57# full ARP + UDP round trip inside the window with no new fault;
58# plus the release order (device reset, bus master revoked, stream back to
59# abort, after the fence and recovery) and "devices: ... virtio_net=selftest-ok".
60# boot 2 no SMMU, same image: virtio-net DMA must be denied (NoSmmu), no
61# grant, no datagram sent, and the helper must log nothing new.
62# boot 3 SMMU on, modern-only NIC WITHOUT iommu_platform (QEMU offers no
63# ACCESS_PLATFORM and would DMA around the vIOMMU): the driver must
64# refuse it before FEATURES_OK ("init FAIL (NoAccessPlatform)"), no
65# attach, no datagram, helper logs nothing new, device released.
66# Not proven (stated, not hidden): QEMU's smmuv3 and virtio models are not
67# hardware; measured on QEMU 8.2.2 the refused DMA does not set NEEDS_RESET (QEMU
68# completes the RX through its bounce buffer, write dropped); the kernel
69# discards the redirected descriptors and shows recovery by reset + re-init,
70# not a device that keeps running through the fault.
71# Netdev: -netdev user,ipv6=off,restrict=off (AIENOS_NET_RESTRICT overrides).
72# Measured 2026-10-01 with QEMU on the Spark: AIENOS_NET_RESTRICT=on makes the
73# gate FAIL (ARP still answers, but the datagram never reaches the helper on
74# 127.0.0.1), so restricted slirp cannot carry this round trip; nothing else
75# listens for the guest and the run lasts two short boots.
76#
77# Reads the machine quiet flag and takes the QEMU gate lock through
78# scripts/lib_gate_hold.sh like the other qemu_ck_* scripts. Final line: AIENOS_CK_NET:
79# PASS|FAIL|NOT_RUN. Exit 0 PASS, 1 FAIL, 2 missing tools, 3 NOT_RUN.
80# Needs qemu-system-aarch64, AAVMF (Ubuntu: qemu-system-arm qemu-efi-aarch64)
81# and a C compiler.
82set -euo pipefail
83
84repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
85cd "${repo_root}"
86
87code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}"
88vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}"
89command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not installed"; echo "AIENOS_CK_NET: NOT_RUN"; exit 2; }
90[[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "AAVMF firmware not found"; echo "AIENOS_CK_NET: NOT_RUN"; exit 2; }
91
92cross=""
93if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi
94commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
95out="${repo_root}/target/native-kernel"
96make -s -C native/kernel CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" full >/dev/null
97make -s -C native/kernel OUT="${out}" udp-echo gpt-image >/dev/null
98efi="${out}/full/BOOTAA64.EFI"
99echo_bin="${out}/host/ck_udp_echo"
100port="$(sed -nE 's/^#define CK_NET_ECHO_PORT ([0-9]+)u.*/\1/p' native/kernel/dev/net_udp.h)"
101lport="$(sed -nE 's/^#define CK_NET_LOCAL_PORT ([0-9]+)u.*/\1/p' native/kernel/dev/net_udp.h)"
102[[ -n "${port}" && -n "${lport}" ]] || { echo "FAIL ports not found in native/kernel/dev/net_udp.h"; echo "AIENOS_CK_NET: FAIL"; exit 1; }
103
104# Machine quiet flag (read only) and the QEMU gate lock (one gate at a time):
105# scripts/lib_gate_hold.sh (aienos#278).
106. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib_gate_hold.sh"
107if ! gh_quiet_check || ! gh_lock_take "qemu_ck_net_test" "${AIENOS_GATE_MINUTES:-60}"; then
108 echo "NOT_RUN ${gh_why}"
109 echo "AIENOS_CK_NET: NOT_RUN"
110 exit 3
111fi
112# Release only this run's own gate lock record, at most once.
113release_flag() { gh_lock_release; }
114top="$(mktemp -d)"
115helper_pid=""
116cleanup() {
117 if [[ -n "${helper_pid}" ]]; then kill "${helper_pid}" 2>/dev/null || true; wait "${helper_pid}" 2>/dev/null || true; fi
118 rm -rf "${top}"
119 release_flag
120}
121trap cleanup EXIT
122
123# Per-run token: the guest can only print it if the helper's reply reached it.
124token="$(od -An -N8 -tx1 /dev/urandom | tr -d ' \n')"
125[[ "${token}" =~ ^[0-9a-f]{16}$ ]] || { echo "FAIL could not read a random token"; echo "AIENOS_CK_NET: FAIL"; exit 1; }
126hlog="${top}/helper.log"
127"${echo_bin}" "${port}" "${token}" "${hlog}" "${AIENOS_NET_HELPER_SECONDS:-600}" &
128helper_pid=$!
129for _ in $(seq 1 50); do
130 grep -q '^ready port=' "${hlog}" 2>/dev/null && break
131 kill -0 "${helper_pid}" 2>/dev/null || break
132 sleep 0.1
133done
134if ! grep -q "^ready port=${port}$" "${hlog}" 2>/dev/null; then
135 echo "NOT_RUN UDP echo helper could not listen on 127.0.0.1:${port}: $(head -c 200 "${hlog}" 2>/dev/null || true)"
136 echo "AIENOS_CK_NET: NOT_RUN"
137 exit 3
138fi
139echo "PASS UDP echo helper listening on 127.0.0.1:${port} (token ${token})"
140
141# shellcheck source=scripts/lib_ck_m1_checks.sh
142source "${repo_root}/scripts/lib_ck_m1_checks.sh"
143img_bytes=67108864
144image="${top}/nvme.img"
145# GPT boot disk with an AIENOS partition (native/kernel/tools/ck_gpt_image.c):
146# the kernel binds NVMe only when it finds one (dev/disk_part.h).
147"${out}/host/ck_gpt_image" create "${image}" 512 $(( img_bytes / 1048576 )) aienos-middle >/dev/null
148net_fail=0; m1_fail=0
149
150# boot <name> [smmu|nosmmu] [nic options]: one QEMU boot; serial text in
151# ${work}/serial.txt. The NIC defaults to modern-only behind the vIOMMU.
152nic_confined="disable-legacy=on,iommu_platform=on"
153boot() {
154 work="${top}/$1"
155 mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS"
156 touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
157 cp "${efi}" "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
158 cp "${vars_fd}" "${work}/vars.fd"
159 local machine="virt,virtualization=on,gic-version=3"
160 [[ "${2:-}" != smmu ]] || machine+=",iommu=smmuv3"
161 set +e
162 # Issue #61: single-threaded TCG (see qemu_boot_test.sh).
163 timeout "${AIENOS_QEMU_TIMEOUT:-180}" qemu-system-aarch64 \
164 -M "${machine}" -accel tcg,thread=single -cpu max -smp 4 -m 2048 \
165 -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
166 -drive if=pflash,format=raw,file="${work}/vars.fd" \
167 -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \
168 -device virtio-blk-pci,drive=esp \
169 -drive if=none,id=nvme0,format=raw,file="${image}" \
170 -device nvme,drive=nvme0,serial=aienos-net-test \
171 -netdev user,id=n0,ipv6=off,restrict="${AIENOS_NET_RESTRICT:-off}" \
172 -device "virtio-net-pci,netdev=n0,mac=52:54:00:12:34:56${3+,$3}" \
173 -device ramfb -display none \
174 -serial file:"${work}/serial.log" -no-reboot
175 qemu_status=$?
176 set -e
177 tr -d '\r' <"${work}/serial.log" >"${work}/serial.txt"
178 [[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${work}/serial.txt" "${AIENOS_LOG_DIR}/qemu_ck_net_$1.log"
179 echo "== boot $1: qemu exit ${qemu_status}"
180 failed=0
181 ck_m1_checks
182 [[ "${failed}" == 0 ]] || m1_fail=1
183 failed=0
184}
185line_of() { grep -n -- "$1" "${work}/serial.txt" | head -1 | cut -d: -f1; }
186
187# ---- boot 1: SMMU present, full round trip ----
188boot net-smmu smmu "${nic_confined}"
189echo "-- (a) attach"
190check "virtio-net capabilities parsed" "^virtio_net: [0-9a-f:.]* caps ok common=bar"
191check "SMMU window programmed for the virtio-net DMA region only" \
192 "^smmu_dma_window: virtio_net only iova=0x[0-9a-f]* len=0x[0-9a-f]* rid=0x[0-9a-f]* stream_id=0x[0-9a-f]*$"
193check "virtio-net DMA granted only after confinement" "^dma_gate: virtio_net granted (Confined), bus master on$"
194check "driver attached, QEMU NIC MAC read from the device, ACCESS_PLATFORM negotiated (features = VERSION_1|ACCESS_PLATFORM|MAC)" \
195 "^virtio_net: attached [0-9a-f:.]* rid=0x[0-9a-f]* qsize=rx[0-9]*/tx[0-9]* mac=52:54:00:12:34:56 features=0x300000020 access_platform=yes$"
196check "ARP reply from the slirp gateway (52:55:0a:00:02:02)" \
197 "^net: arp who-has 10.0.2.2 tell 10.0.2.15 -> 52:55:0a:00:02:02 tries=[0-9]*$"
198echo "-- (b) TX"
199tx_re="^net: udp tx 10\.0\.2\.15:${lport} -> 10\.0\.2\.2:${port} frame=[0-9]+ bytes payload=\"(AIENOS-CK-NET ping nonce=[0-9a-f]{8})\" try=[0-9]+ completed=yes$"
200tx_line="$(grep -E "${tx_re}" "${work}/serial.txt" | head -1 || true)"
201nonce=""
202if [[ "${tx_line}" =~ ${tx_re} ]]; then
203 nonce="${BASH_REMATCH[1]}"
204 echo "PASS guest sent one UDP frame and the device completed it (${nonce})"
205else
206 echo "FAIL guest UDP TX line with completed=yes"; failed=1
207fi
208if [[ -n "${nonce}" ]] && grep -qE "^rx from 127\.0\.0\.1:[0-9]+ len=[0-9]+ payload=\"${nonce}\"$" "${hlog}"; then
209 echo "PASS host helper received the guest's datagram through slirp (same nonce)"
210else
211 echo "FAIL host helper did not log the guest's datagram"; failed=1
212fi
213echo "-- (c) RX"
214if grep -qE '^tx to 127\.0\.0\.1:[0-9]+ len=[0-9]+ reply=[0-9]+$' "${hlog}"; then
215 echo "PASS host helper sent its reply"
216else
217 echo "FAIL host helper reply not logged"; failed=1
218fi
219rx_want="^net: udp rx 10\.0\.2\.2:${port} -> 10\.0\.2\.15:${lport} payload_len=[0-9]+ udp_csum=verified parsed=m6a echo_of_ours=yes payload=\"AIENOS-CK-NET pong token=${token} echo=${nonce:-NONE}\"$"
220if [[ -n "${nonce}" ]] && grep -qE "${rx_want}" "${work}/serial.txt"; then
221 echo "PASS guest received and parsed (M6-A, checksum verified) the helper's reply with this run's token"
222else
223 echo "FAIL guest UDP RX line with this run's token and its own nonce"; failed=1
224fi
225check "round trip reported" "^net: udp round trip ok tx_reclaimed=[1-9][0-9]* rx_frames=[1-9][0-9]*$"
226echo "-- (d) fence: device DMA outside the window"
227win_re='^smmu_dma_window: virtio_net only iova=0x([0-9a-f]+) len=0x([0-9a-f]+) rid=0x[0-9a-f]+ stream_id=0x([0-9a-f]+)$'
228win_line="$(grep -E "${win_re}" "${work}/serial.txt" | head -1 || true)"
229w_lo=""; w_len=""; w_sid=""
230if [[ "${win_line}" =~ ${win_re} ]]; then w_lo=$((16#${BASH_REMATCH[1]})); w_len=$((16#${BASH_REMATCH[2]})); w_sid=$((16#${BASH_REMATCH[3]})); fi
231probe_re='^net_smmu_negative: rx descriptors redirected=([1-9][0-9]*) to iova=0x([0-9a-f]+) \(outside window 0x[0-9a-f]+\+0x[0-9a-f]+\); probe datagram "(AIENOS-CK-NET ping smmu-probe nonce=[0-9a-f]{8})" tx=Ok$'
232probe_line="$(grep -E "${probe_re}" "${work}/serial.txt" | head -1 || true)"
233probe=""
234if [[ "${probe_line}" =~ ${probe_re} ]]; then
235 probe="${BASH_REMATCH[3]}"
236 echo "PASS ${BASH_REMATCH[1]} RX descriptors pointed outside the window, probe datagram sent"
237else
238 echo "FAIL probe line (RX descriptors redirected, probe datagram tx=Ok)"; failed=1
239fi
240if [[ -n "${probe}" ]] && grep -qE "^rx from 127\.0\.0\.1:[0-9]+ len=[0-9]+ payload=\"${probe}\"$" "${hlog}" &&
241 grep -A1 -F "payload=\"${probe}\"" "${hlog}" | tail -n +2 | grep -qE "^tx to 127\.0\.0\.1:[0-9]+ len=[0-9]+ reply=[0-9]+$"; then
242 echo "PASS host helper received the probe and replied (the device had a frame to write)"
243else
244 echo "FAIL host helper did not log the probe datagram and a reply to it"; failed=1
245fi
246neg_re='^net_smmu_negative: refused rx dma outside window iova=0x([0-9a-f]+) faults=([1-9][0-9]*) type=0x10 sid=0x([0-9a-f]+) addr=0x([0-9a-f]+) page=intact rx_completed=([0-9]+) device_status=0x([0-9a-f]{2}) needs_reset=(yes|no) faults_during_roundtrip=0 overflow=([01])$'
247neg_line="$(grep -E "${neg_re}" "${work}/serial.txt" | head -1 || true)"
248if [[ -n "${w_lo}" && "${neg_line}" =~ ${neg_re} ]]; then
249 c_iova=$((16#${BASH_REMATCH[1]})); e_sid=$((16#${BASH_REMATCH[3]})); e_addr=$((16#${BASH_REMATCH[4]}))
250 e_rx="${BASH_REMATCH[5]}"; e_status="${BASH_REMATCH[6]}"; e_nr="${BASH_REMATCH[7]}"; e_ovf="${BASH_REMATCH[8]}"; e_n="${BASH_REMATCH[2]}"
251 if (( (c_iova + 4096 <= w_lo || c_iova >= w_lo + w_len) && e_sid == w_sid && (e_addr & ~4095) == c_iova )); then
252 echo "PASS SMMU event F_TRANSLATION (0x10) x${e_n} for the NIC's stream 0x${BASH_REMATCH[3]} at 0x${BASH_REMATCH[4]}, in the target page 0x${BASH_REMATCH[1]} outside the window; page intact; positive round trip fault-free (device model reaction, reported not judged: rx_completed=${e_rx} device_status=0x${e_status} needs_reset=${e_nr} event_overflow=${e_ovf})"
253 else
254 echo "FAIL event fields do not match the window/stream/page (iova=0x${BASH_REMATCH[1]} sid=0x${BASH_REMATCH[3]} addr=0x${BASH_REMATCH[4]} window=${w_lo}+${w_len} stream=${w_sid})"; failed=1
255 fi
256else
257 echo "FAIL SMMU refused-DMA line (F_TRANSLATION for this stream, page intact, fault-free round trip before it)"; failed=1
258fi
259echo "-- (e) recovery inside the window"
260check "device reset + re-init with ACCESS_PLATFORM after the fault" \
261 "^net_smmu_recovery: device reset + reinit ok (Ok) access_platform=yes late_probe_faults=[0-9][0-9]*$"
262check "second round trip after the fault, no new SMMU fault" \
263 "^net_smmu_recovery: round trip after the fault ok (rc=0 new_faults=0)$"
264if [[ "$(grep -cE "^net: udp rx .* echo_of_ours=yes payload=\"AIENOS-CK-NET pong token=${token} echo=AIENOS-CK-NET ping nonce=[0-9a-f]{8}\"$" "${work}/serial.txt" || true)" -ge 2 ]]; then
265 echo "PASS two helper replies with this run's token parsed (before and after the fault)"
266else
267 echo "FAIL fewer than two parsed helper replies with this run's token"; failed=1
268fi
269check "net selftest PASS (round trip, fence and recovery)" "^net: selftest PASS (rc=0)$"
270echo "-- release"
271check "device reset before the revoke" "^virtio_net: device reset status=0x00 (stopped)$"
272check "virtio-net bus master revoked" "^dma_gate: virtio_net bus master revoked$"
273check "virtio-net SMMU stream returned to abort" "^smmu: virtio_net stream 0x[0-9a-f]* returned to abort (rc=0)$"
274lg="$(line_of '^dma_gate: virtio_net granted (Confined)')"; lt="$(line_of '^net: udp round trip ok')"; ld="$(line_of '^virtio_net: device reset status=0x00 (stopped)$')"
275lr="$(line_of '^dma_gate: virtio_net bus master revoked$')"; la="$(line_of '^smmu: virtio_net stream .* returned to abort')"
276ln="$(line_of '^net_smmu_negative: refused ')"; lv="$(line_of '^net_smmu_recovery: round trip after the fault ok')"
277if [[ -n "${lg}" && -n "${lt}" && -n "${ln}" && -n "${lv}" && -n "${ld}" && -n "${lr}" && -n "${la}" && "${lg}" -lt "${lt}" && "${lt}" -lt "${ln}" && "${ln}" -lt "${lv}" && "${lv}" -lt "${ld}" && "${ld}" -lt "${lr}" && "${lr}" -lt "${la}" ]]; then
278 echo "PASS order: grant < round trip < fault refused < recovery round trip < device reset < bus master off < stream abort"
279else
280 echo "FAIL order (lines ${lg:-none} ${lt:-none} ${ln:-none} ${lv:-none} ${ld:-none} ${lr:-none} ${la:-none})"; failed=1
281fi
282check "devices stage summary" "^devices: pci=ok nvme=bound virtio_net=selftest-ok$"
283check_absent "no virtio-net failure lines" "^net: .*FAIL\|^net_smmu_[a-z]*: .*FAIL\|^virtio_net: .*FAIL\|^virtio_net: not bound"
284[[ "${failed}" == 0 ]] || net_fail=1
285failed=0
286helper_rx_after_boot1="$(grep -c '^rx from ' "${hlog}" || true)"
287
288# ---- boot 2: no SMMU, fail closed ----
289boot net-nosmmu nosmmu "${nic_confined}"
290check "virtio-net DMA denied without an SMMU" "^dma_gate: virtio_net denied (NoSmmu rc=-1), bus master stays off$"
291check "virtio-net not bound without an SMMU" "^virtio_net: not bound (SMMU DMA isolation not active)$"
292check_absent "no virtio-net grant without an SMMU" "dma_gate: virtio_net granted"
293check_absent "no datagram sent without an SMMU" "^net: udp tx"
294check "devices stage summary (no SMMU)" "virtio_net=selftest-failed$"
295if [[ "$(grep -c '^rx from ' "${hlog}" || true)" == "${helper_rx_after_boot1}" ]]; then
296 echo "PASS host helper saw nothing from the no-SMMU boot"
297else
298 echo "FAIL host helper received traffic during the no-SMMU boot"; failed=1
299fi
300[[ "${failed}" == 0 ]] || net_fail=1
301failed=0
302helper_rx_after_boot2="$(grep -c '^rx from ' "${hlog}" || true)"
303
304# ---- boot 3: SMMU on, NIC without iommu_platform: refused (fail closed) ----
305boot net-noap smmu "disable-legacy=on"
306check "SMMU window programmed (the refusal is the driver's, not the SMMU's)" \
307 "^smmu_dma_window: virtio_net only iova=0x[0-9a-f]* len=0x[0-9a-f]* rid=0x[0-9a-f]* stream_id=0x[0-9a-f]*$"
308check "driver refuses a NIC that does not offer ACCESS_PLATFORM" "^virtio_net: init FAIL (NoAccessPlatform)$"
309check_absent "no attach without ACCESS_PLATFORM" "^virtio_net: attached"
310check_absent "no datagram sent without ACCESS_PLATFORM" "^net: udp tx"
311check "device released (reset, bus master revoked, stream back to abort)" \
312 "^smmu: virtio_net stream 0x[0-9a-f]* returned to abort (rc=0)$"
313check "devices stage summary (no ACCESS_PLATFORM)" "virtio_net=selftest-failed$"
314if [[ "$(grep -c '^rx from ' "${hlog}" || true)" == "${helper_rx_after_boot2}" ]]; then
315 echo "PASS host helper saw nothing from the no-ACCESS_PLATFORM boot"
316else
317 echo "FAIL host helper received traffic during the no-ACCESS_PLATFORM boot"; failed=1
318fi
319[[ "${failed}" == 0 ]] || net_fail=1
320release_flag
321
322if [[ "${m1_fail}${net_fail}" != 00 || -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then
323 for s in "${top}"/*/serial.txt; do
324 echo "---- serial console $(basename "$(dirname "${s}")") (net lines) ----"
325 grep -E '^(virtio_net|net:|net_smmu|dma_gate: virtio|smmu|devices:|stage |report_kind:)' "${s}" | head -60 || true
326 done
327 echo "---- helper log ----"; head -20 "${hlog}" || true
328fi
329[[ "${m1_fail}" != 0 ]] && echo "M1 checks failed on at least one boot: the NET verdict cannot pass"
330if [[ "${m1_fail}${net_fail}" == 00 ]]; then echo "AIENOS_CK_NET: PASS"; exit 0; fi
331echo "AIENOS_CK_NET: FAIL"
332exit 1