Files
reims-vgpu/scripts/internal/lane-gate/msi-image.sh
T
Anees Iqbal b6455b1eac 🆕 Add the lane's landing gate
scripts/internal/lane-gate.sh checks a candidate tree of the graphics-kext
lane end to end and compares it with the last passing baseline, so a landing
is decided by one command instead of a hand-run list.

On the Mac it runs the kext's check against the KDK, the kext's, the bundle's
and RgfxGate's tests, rustfmt, and the cargo tests the change reaches (the
lane's own, plus the packages changed since the baseline and their
dependents), under the GPU lock. Meanwhile, on the lane host, it builds the
candidate's dist, QEMU and option ROM, and a SIP-on OpenCore image carrying
the candidate's kexts, checked back from its ESP.

The verdict comes from a shared correctness boot through rgk-boot2.sh (a VM
slot, then the GPU, in turnstile order): the guest runner checks SIP, the
loaded kexts, the loader's binding, the bundle's signature and the Metal
device, then runs the 57-case sweep, the H.264 and HEVC MD5 sets on the
hardware decoder, Safari WebGL readPixels, present_probe, and checks that
WindowServer lived and no crash report appeared. The host side counts
'reims-vgpu: fatal' lines and checks the desktop composited.

An exclusive bench boot runs after the verdict, without blocking it: the
bench, present_probe, the timed decodes and QEMU's CPU, compared with the
baseline's medians inside a noise band measured from repeated passes.

Steps record their results, so a pass resumes where it stopped.
2026-11-05 21:59:27 -08:00

48 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# The lane gate's OpenCore image, made on the lane host: BASE, a SIP-on image of the lane's
# OpenCore set, with the candidate's kexts in place of BASE's (opencore-add-kexts.sh replaces each
# bundle of the same name in its own entry's place): the loader that matches the candidate's
# ReimsGraphics, its IOGraphicsFamily and AppleGraphicsDeviceControl shims, ReimsGraphics itself
# (the loader builder's staged copy, whose Info.plist carries no personalities: the loader holds
# them), and RgfxGate, which carries the candidate's bundle as its payload. Checks that OUT
# carries exactly the given binaries.
#
# msi-image.sh OCADD BASE OUT KEXTS RGFXGATE
# OCADD scripts/internal/opencore-add-kexts.sh
# KEXTS the loader builder's kexts: AppleParavirtGPULoader.kext, ReimsGraphics.kext and
# the *Bridge.kext shims
# RGFXGATE the candidate's RgfxGate.kext
set -euo pipefail
OCADD=$1 BASE=$2 OUT=$3 KEXTS=$4 GATEKEXT=$5
[[ -f $BASE ]] || { echo "msi-image: no base image $BASE" >&2; exit 2; }
rm -f "$OUT"
shims=("$KEXTS"/*Bridge.kext)
bash "$OCADD" "$BASE" "$OUT" "${shims[@]}" "$KEXTS/ReimsGraphics.kext" \
"$KEXTS/AppleParavirtGPULoader.kext" "$GATEKEXT" > "$OUT.entries"
# What the image carries, read back from its ESP (the GPT's first partition).
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
qemu-img convert -O raw "$OUT" "$tmp/disk.raw"
off=$(python3 -I - "$tmp/disk.raw" << 'EOF'
import struct, sys
with open(sys.argv[1], "rb") as f:
f.seek(512)
h = f.read(92)
lba, = struct.unpack_from("<Q", h, 72)
f.seek(lba * 512)
first, = struct.unpack_from("<Q", f.read(128), 32)
print(first * 512)
EOF
)
export MTOOLS_SKIP_CHECK=1
mcopy -s -i "$tmp/disk.raw@@$off" ::/EFI/OC/Kexts "$tmp/"
for k in "$KEXTS"/*.kext "$GATEKEXT"; do
n=$(basename "$k" .kext)
want=$(sha256sum < "$k/Contents/MacOS/$n" | cut -d' ' -f1)
got=$(sha256sum < "$tmp/Kexts/$n.kext/Contents/MacOS/$n" | cut -d' ' -f1)
[[ $want == "$got" ]] || { echo "msi-image: $OUT carries another $n ($got, not $want)" >&2; exit 1; }
echo "IMAGE $n ${want:0:16}"
done
echo MSI_IMAGE_OK