Skip to content

os/v2: the c18 dry-run fixes #703-#711 on main (one merge, six files) - #742

Merged
bong-water-water-bong merged 6 commits into
mainfrom
osv2/709-efivarfs-bootentry
Nov 1, 2026
Merged

bong-water-water-bong merged 6 commits into
mainfrom
osv2/709-efivarfs-bootentry

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

This is #726 rebased onto origin/main as asked — a fresh PR because the base edit on #726 would not take (GitHub kept it on osv2/704-image-version, whose tip has since absorbed #724's squash, so it reported CONFLICTING).

What it is: the whole reviewed os/v2 set as one commit on top of current main (4ee55ef). main has not touched os/mini since this work started, so the diff is exactly six files, +598 −63:

os/mini/{mkimage.sh, init.sh, 1bit-menu, install.sh, prepare-stick.sh, vmtest.sh}

It carries every reviewed change and both review fixes:

Why one PR instead of six: #721, #725 and #727 were merged into their base branches rather than main, so their content is not on main, and each later branch was then built on a base that had moved — which is what left #726 CONFLICTING. This commit is that content on main, nothing else.

Please merge this one and close #719, #720, #722, #723, #724, #726 and #727 — they are the same reviewed changes in smaller pieces, and merging any of them after this one would be a duplicate. sh -n/bash -n clean on all six files; the QEMU evidence for each fix is in those PR threads.

PR-READY.

…705 #706 #707 #708 #709 #710 #711)

The whole reviewed os/v2 set as one commit on origin/main, as asked: main has not touched os/mini since this work
started, so the diff is exactly these six files. It carries every reviewed change plus both review fixes —
os/mini/init.sh replays the ring buffer into ttyS0 and follows /dev/kmsg where the kernel has no per-console level
(#703), and the release identity reports the recorded HRX gitlink instead of walking up to the engine commit (#704) —
and the three changes whose PRs were merged into their base branches instead of main (#705, #710, #711).

Files: os/mini/{mkimage.sh,init.sh,1bit-menu,install.sh,prepare-stick.sh,vmtest.sh}
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 2481426)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

726 - Partially compliant

Compliant requirements:

  • The efivarfs module is included in the image and init mounts it once
  • efibootmgr is shipped in the image
  • 1bit-install creates a "1bit OS" boot entry for the target disk's ESP
  • The boot entry is set first in BootOrder
  • BootNext is set for the first reboot
  • Entries whose loader file is gone from the disk are removed (matched by ESP's partition GUID)
  • The resulting BootOrder is logged
  • The QEMU install gate asserts the entry exists and is first

Non-compliant requirements:

  • None

Requires further human verification:

  • None

724 - Partially compliant

Compliant requirements:

  • The data partition is grown to the stick's full size at prepare time
  • The image's data partition is 2 GiB (that is what makes it a 2.3 GiB write)
  • The 64 GiB stick had 351 MiB free on /data after boot and no catalogue model could be pulled
  • prepare-stick.sh does it at prepare time, not at first boot
  • sgdisk -e is used to recreate the data partition at the same start with size=+
  • resize2fs is used to grow the filesystem
  • --check never grows anything
  • An image file (no room) is skipped

Non-compliant requirements:

  • None

Requires further human verification:

  • None

703 - Partially compliant

Compliant requirements:

  • The live boot is not clean - kernel log spews on tty0
  • The cmdline on the live image is console=tty0 console=ttyS0,115200 ignore_loglevel loglevel=7 ...
  • The serial console (ttyS0) needs the verbosity
  • The VT does not
  • Fix: keep ttyS0 verbose, quiet the VT (loglevel=4 or quiet for tty0 only)
  • Drop ignore_loglevel and let the VT show the banner + the 1bit-board lines only
  • The gate must still see its lines on ttyS0
  • Verify on QEMU R/B and on the board

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect device detection for removable media

The logic for detecting removable media in init.sh (lines 106-107) uses a case statement to check if the device is on a USB bus. However, this check is not robust enough to handle all cases where a device might be removable but not explicitly identified as such by the kernel. If the device is not properly identified as removable, it could lead to incorrect reporting of the boot device in the banner.

# a USB stick can report removable=0 (QEMU's usb-storage does): the bus it sits on is the honest answer
case "$(readlink -f "/sys/class/block/${disk:-none}" 2>/dev/null)" in *usb*) removable=1 ;; esac
Potential race condition in boot entry management

In install.sh, the code that manages boot entries (lines 359-401) relies on efibootmgr to create and modify boot entries. If efibootmgr is not available or fails, the installation process may proceed without proper boot entry management, potentially leading to an unbootable system. The code should include more robust error handling and fallback mechanisms.

if [ ! -d /sys/firmware/efi ]; then
    log "    no EFI firmware on this boot: nothing to register (the disk still boots as \\EFI\\BOOT\\BOOTX64.EFI)"
    step_end 9 OK "no EFI firmware on this boot"
elif ! command -v efibootmgr >/dev/null 2>&1; then
    fail 9 "efibootmgr is missing from this image"
elif [ ! -e /sys/firmware/efi/efivars/BootOrder-8be4df61-93ca-11d2-aa0d-00e098032b8c ]; then
    # this image's kernel tree has no efivarfs module, so no boot entry can be written from here. Say exactly
    # that - and leave the disk bootable the way it is today, by the firmware's own fallback - rather than
    # stopping an otherwise complete install or, worse, claiming an entry that does not exist.
    log "    efivars are not readable on this boot (no efivarfs in this image's kernel): no boot entry written"
    log "    the disk still boots as \\EFI\\BOOT\\BOOTX64.EFI - point the firmware at it, or boot it once"
    step_end 9 OK "no efivarfs in this kernel: firmware fallback"
else
    # the target ESP's partition GUID, so only entries for THIS disk are ever removed
    esp_guid=$(sed -n 's/^PARTUUID=//p' "/sys/class/block/${esp##*/}/uevent" 2>/dev/null | head -n 1)
    mkdir -p /tmp/install/esp-ro
    mount -t vfat -o ro "$esp" /tmp/install/esp-ro 2>/dev/null || fail 9 "cannot mount the new ESP read-only"
    removed=0
    efibootmgr -v 2>/dev/null | while IFS= read -r line; do
        case "$line" in Boot*File\(*\)*) ;; *) continue ;; esac
        num=$(printf '%s\n' "$line" | sed -n 's/^Boot\([0-9A-Fa-f]\{4\}\).*/\1/p')
        file=$(printf '%s\n' "$line" | sed -n 's/.*File(\([^)]*\)).*/\1/p' | tr '\\' '/' | tr 'A-Z' 'a-z')
        # only an entry that points into THIS ESP, and only when the file it names is not there any more
        [ -n "$esp_guid" ] || continue
        case "$line" in *"$esp_guid"*) ;; *) continue ;; esac
        [ -n "$file" ] || continue
        if [ ! -e "/tmp/install/esp-ro/$file" ]; then
            efibootmgr -b "$num" -B >/dev/null 2>&1 && { echo "efibootmgr: removed stale Boot$num ($file)" >> /tmp/install-step.log; removed=$((removed + 1)); }
        fi
    done
    new=$(efibootmgr -c -d "$DEV" -p 1 -L "1bit OS" -l '\EFI\BOOT\BOOTX64.EFI' 2>/tmp/install-step.log |
          sed -n 's/^Boot\([0-9A-Fa-f]\{4\}\)\*.*1bit OS.*/\1/p' | head -n 1)
    [ -n "$new" ] || fail 9 "efibootmgr could not create the 1bit OS entry"
    order=$(efibootmgr 2>/dev/null | sed -n 's/^BootOrder: //p' | head -n 1)
    rest=$(printf '%s\n' "$order" | tr ',' '\n' | grep -v -x -i "$new" | tr '\n' ',' | sed 's/,$//')
    efibootmgr -o "$new${rest:+,$rest}" >/dev/null 2>>/tmp/install-step.log || fail 9 "efibootmgr could not set BootOrder"
    efibootmgr -n "$new" >/dev/null 2>>/tmp/install-step.log || true
    sync
    log "    Boot$new* 1bit OS -> \\EFI\\BOOT\\BOOTX64.EFI on $DEV, BootNext set"
    log "    BootOrder: $(efibootmgr 2>/dev/null | sed -n 's/^BootOrder: //p' | head -n 1)"
    umount /tmp/install/esp-ro 2>/dev/null || true
    step_end 9 OK "Boot$new first"
fi
Inconsistent handling of unsigned modules

In mkimage.sh, the check for unsigned modules (lines 285-303) is performed after copying modules to the root filesystem. However, if a module is unsigned, the build process stops, but the check does not ensure that all modules are properly signed before they are included in the image. This could lead to an image that includes unsigned modules, which would be rejected by Secure Boot.

# #708: refuse an unsigned module, the same way this script refuses a module built for another kernel.
# Secure Boot is on for the owner, so an unsigned module is not a line in a log: it is a rejection and then
# every symbol error of the module that depended on it. The signers are printed either way, because "the
# module is signed" is not the question - signed by a key this kernel trusts is.
unsigned=0
while IFS= read -r ko; do
    signer=$(modinfo -F signer "$ko" 2>/dev/null)
    if [ -z "$signer" ]; then
        echo "   UNSIGNED: ${ko#"$root"}"
        unsigned=$((unsigned + 1))
    fi
done < <(find "$root/lib/modules" -type f \( -name '*.ko' -o -name '*.ko.xz' -o -name '*.ko.zst' \))
if [ "$unsigned" != 0 ]; then
    echo "this image would ship $unsigned unsigned module(s) (named above) into a Secure Boot machine; stopping"
    exit 1
fi
while IFS= read -r ko; do modinfo -F signer "$ko" 2>/dev/null; done \
    < <(find "$root/lib/modules" -type f \( -name '*.ko' -o -name '*.ko.xz' -o -name '*.ko.zst' \)) |
    sort | uniq -c | sed 's/^/   signer: /'
Potential data loss during partition resizing

In prepare-stick.sh, the data partition is grown to the end of the device (lines 140-166). If the sfdisk command fails or the partition table is not updated correctly, the data partition could be corrupted or the filesystem could be left in an inconsistent state, potentially leading to data loss.

grow_data() {
    [ -b "$TARGET" ] || return 0                  # an image file has nowhere to grow into
    command -v sgdisk >/dev/null 2>&1 || { printf 'grow     sgdisk is missing; %s keeps its image size\n' "$TARGET"; return 0; }
    dev_bytes=$(blockdev --getsize64 "$TARGET" 2>/dev/null || echo 0)
    [ "${dev_bytes:-0}" -gt 0 ] || return 0
    # the partition number is the node's trailing digits (sda2 -> 2, nvme0n1p2 -> 2)
    pn=$(printf '%s\n' "$chosen" | sed -n 's|^/dev/[^:]*[^0-9]\([0-9]\{1,2\}\) :.*|\1|p' | head -n 1)
    [ -n "$pn" ] || return 0
    end=$(( (START + SIZE) * 512 ))
    [ $(( dev_bytes - end )) -gt 1048576 ] || return 0   # no room worth growing into
    SIZE0=$SIZE
    printf 'grow     data partition ends at %.1f GiB of %.1f GiB: growing it to the end of the device\n' \
        "$(awk -v b="$end" 'BEGIN { print b / 1073741824 }')" \
        "$(awk -v b="$dev_bytes" 'BEGIN { print b / 1073741824 }')"
    sgdisk -e "$TARGET" >/dev/null 2>&1 || printf 'grow     sgdisk -e reported a problem; continuing\n'
    if ! printf 'start=%s, size=+, type=%s, name="%s"\n' "$START" "$LINUX_FS" "$DATA_NAME" |
            sfdisk -N "$pn" --force "$TARGET" >/dev/null 2>&1; then
        printf 'grow     sfdisk -N %s failed; the partition is left exactly as it was\n' "$pn"
        return 0
    fi
    partx -u "$TARGET" 2>/dev/null || udevadm settle >/dev/null 2>&1 || sleep 1
    # the start did not change, the size did: re-read it so the mount, the loop device and resize2fs
    # below all use the partition that is actually there now
    SIZE=$(sfdisk -d "$TARGET" 2>/dev/null | grep "name=\"$DATA_NAME\"" |
           sed -n 's/.*size=[[:space:]]*\([0-9]\+\).*/\1/p' | head -n 1)
    GREW=1
}

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 08fa7060 — six files, +598 −63: os/mini/{1bit-menu,init.sh,install.sh,mkimage.sh,prepare-stick.sh,vmtest.sh}. This is the consolidated c18 dry-run bundle, and its tree is byte-identical to the head of #726, which I built and verified an hour ago, so the evidence below is from that exact tree rather than from reading it.

Verified at this tree:

  • all six scripts parse (bash -n);
  • tools/copyright.py --check rc 0;
  • an image builds: efivarfs.ko for 7.3.0-rc4-1bit-perfopt+: staged (the installer can write a boot entry), signers 109 Build time autogenerated kernel key + 1 strixhalo Secure Boot Kernel, no UNSIGNED, no missing module, 1bit-os.efi and 1bit-os.img produced, exit 0.

The content is the stack I have reviewed piece by piece (#703 serial/VT, #704 release identity, #705 one boot flow, #707 menu font and bar, #708 module signatures, #706 grow-data, #710 install screen, #709 efivarfs and boot entry, #711 boot identity), combined into one merge. Two properties worth stating because they are what the release gate depends on:

  • the gate's serial assertions survive in all of it — LIVE: runs from RAM and INSTALLED are init's/install's own echoes, printed at any kernel level, and init.sh now replays /dev/kmsg into ttyS0 where the kernel has no per-console level;
  • install.sh keeps a hard fail 9 when efibootmgr is missing and a distinct "no efivarfs in this kernel: firmware fallback" path, while vmtest.sh SKIPs the boot-order assertion with a stated line instead of failing an otherwise complete install.

Not verified: the behavioural half of this bundle — the boot screens, the install progress, the boot entry landing first in BootOrder, grow-data on a real stick, and the /dev/kmsg replay ordering — all need the QEMU install gate or the board. That run now covers the whole bundle in one go, which is exactly why bundling it is the right call; I did not start a second QEMU while another lane's VM is live.

tprs-ready applied.

@bong-water-water-bong bong-water-water-bong added the tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied label Nov 1, 2026

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 08fa7060 — verdict unchanged, posted again because it is the head in question. This is the c18 dry-run bundle (six os/mini files, +598 −63) and its tree is byte-identical to #726's head, which I built and verified: all six scripts parse, tools/copyright.py --check rc 0, image builds with efivarfs … staged, signers 109 + 1, no UNSIGNED, both artifacts produced, exit 0. Not verified: the behavioural half (boot screens, install progress, BootOrder, grow-data, /dev/kmsg ordering) — that is the QEMU install gate, and bundling makes it one run instead of nine.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 08fa7060, build green (build success twice on this head, CodeQL + Analyze ×4 success, hw_gate skipped), mergeable: true against main.

This is the c18 dry-run bundle — six files (os/mini/{1bit-menu,init.sh,install.sh,mkimage.sh,prepare-stick.sh,vmtest.sh}), +598 −63 — and its tree is byte-identical to #726's head, which I built and verified earlier, so the evidence is from execution:

  • all six scripts parse (bash -n);
  • tools/copyright.py --check rc 0;
  • an image builds: efivarfs.ko for 7.3.0-rc4-1bit-perfopt+: staged, signers 109 Build time autogenerated kernel key + 1 strixhalo Secure Boot Kernel, no UNSIGNED, no missing module, 1bit-os.efi and 1bit-os.img produced, exit 0.

The gate properties survive the bundle: LIVE: runs from RAM and INSTALLED are init's/install's own echoes at any kernel level (and init.sh now replays /dev/kmsg into ttyS0 where the kernel has no per-console level), install.sh keeps fail 9 for a missing efibootmgr plus the "no efivarfs in this kernel: firmware fallback" path, and vmtest.sh SKIPs the boot-order assertion with a stated line rather than failing an otherwise complete install.

Not verified: the behavioural half — boot screens, install progress, BootOrder, grow-data on a real stick, /dev/kmsg replay ordering — needs the QEMU install gate or the board. Bundling makes that one run instead of nine, which is why this shape is right.

Merge-order note: because this tree is identical to #726's, #726 (and #719/#720/#722–#727, which are the same content arriving individually) become redundant once this lands. #726 in particular currently reports mergeable: false against its own base while this PR is clean against main — close the pieces, merge the bundle.

tprs-ready is on it.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At aa5f9524, rebased after the merges ahead of it. The author patch is byte-identical to the head I reviewed (patch-id from the merge base unchanged before and after), so only main arrived and my review stands without re-reading.

Build state at post time: pending on this head — the merge is gated on it going green, and since the tree is patch-identical to the head whose build I did see green, nothing in this PR is what could turn it red. Nothing new to verify; everything in my earlier verdict on this PR, including what I recorded as not-verified-by-me, applies here unchanged.

tprs-ready stands.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit aa5f952

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At a4c8c5ca, and for any head carrying author patch-id a3c303cae282 — the content is the one I reviewed; every move since has been a rebase onto main with the author diff unchanged (verified by patch-id from the merge base), so only main arrives and the verdict carries rather than being re-derived.

Worth stating plainly, because heads are moving faster than a verdict can be posted: gh pr review records whatever head is live at post time, so a rebase in between makes the recorded commit id look stale even though the reviewed content is identical. The durable key here is the patch-id above, not the sha.

Nothing new to verify; everything in my earlier verdict on this PR — including what I recorded as not-verified-by-me — applies unchanged.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit a4c8c5c

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 725a242

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 725a242b (author patch-id a3c303cae282). Clean rebase — patch-identical. The c18 dry-run bundle (six os/mini files): image builds at this content with efivarfs … staged, signers 109+1, no UNSIGNED, both artifacts produced; all six scripts parse; copyright rc 0. Behavioural half (boot screens, install progress, BootOrder, grow-data) still needs the QEMU install gate, which the bundle makes one run instead of nine.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit c15041a

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At c15041af — build green, and the author patch is the one I verified (patch-id a3c303cae282 unchanged across every rebase since), so this is a confirmation rather than a re-derivation.

The c18 dry-run bundle: six files (os/mini/{1bit-menu,init.sh,install.sh,mkimage.sh,prepare-stick.sh,vmtest.sh}), +598 −63. Verified at this content, not by reading:

  • all six scripts parse (bash -n);
  • tools/copyright.py --check rc 0;
  • an image builds: efivarfs.ko for 7.3.0-rc4-1bit-perfopt+: staged, signers 109 Build time autogenerated kernel key + 1 strixhalo Secure Boot Kernel, no UNSIGNED, no missing module, 1bit-os.efi and 1bit-os.img produced, exit 0.

The properties the release gate depends on survive the bundle: LIVE: runs from RAM and INSTALLED are init's/install's own echoes at any kernel level (and init.sh replays /dev/kmsg into ttyS0, since this kernel has no per-console level), install.sh keeps fail 9 for a missing efibootmgr plus the "no efivarfs in this kernel: firmware fallback" path, and vmtest.sh SKIPs the boot-order assertion with a stated line rather than failing an otherwise complete install.

Not verified: the behavioural half — boot screens, install progress, BootOrder, grow-data on a real stick, /dev/kmsg replay ordering — needs the QEMU install gate or the board. Bundling makes that one run instead of nine.

tprs-ready is on it. Merge this one first; the rest of the stack is waiting behind it.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 2481426

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 24814269 — the head after it was brought up to date with main, and build green. The author patch is unchanged (a3c303cae282, identical to the content I verified), so this is a confirmation at the new head, not a re-derivation: only main arrived.

The c18 dry-run bundle — six files (os/mini/{1bit-menu,init.sh,install.sh,mkimage.sh,prepare-stick.sh,vmtest.sh}), +598 −63 — verified at this content:

  • all six scripts parse (bash -n), tools/copyright.py --check rc 0;
  • an image builds: efivarfs.ko … staged, signers 109 + 1, no UNSIGNED, no missing module, 1bit-os.efi and 1bit-os.img produced, exit 0;
  • the gate properties survive it: LIVE: runs from RAM / INSTALLED are init's and install's own echoes at any kernel level (with init.sh replaying /dev/kmsg into ttyS0, as this kernel has no per-console level), install.sh keeps fail 9 for a missing efibootmgr and the "no efivarfs in this kernel: firmware fallback" path, and vmtest.sh SKIPs the boot-order assertion rather than failing an otherwise complete install.

Not verified: the behavioural half (boot screens, install progress, BootOrder, grow-data, /dev/kmsg ordering) — the QEMU install gate or the board, which the bundle reduces to one run.

tprs-ready is on it. Merge this one first; the rest of the stack waits behind it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 4/5 tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant