Skip to content

os: quiet the VT, keep the serial log verbose (#703) - #719

Closed
bong-water-water-bong wants to merge 4 commits into
mainfrom
osv2/703-quiet-vt
Closed

bong-water-water-bong wants to merge 4 commits into
mainfrom
osv2/703-quiet-vt

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #703. The live image's cmdline carried ignore_loglevel loglevel=7, so the c18 dry run scrolled every
kernel line over the VT before the banner. The cmdline now boots at loglevel=4 (warnings and errors only) and
init's first act raises ttyS0 - the console the QEMU gates read - to level 7 where the kernel exposes a
per-console level (/sys/class/console/ttyS0/level).

Stack: 1 of 9, each based on the previous one; merge in order (703, 704, 705, 707, 708, 706, 710, 709, 711).
Each later PR retargets to main automatically when its base branch is merged.
PR-READY.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Merge order matters for these nine (they are stacked). Each PR's base is the previous branch, so GitHub retargets the next one to main as its base merges — nothing needs rebasing if they go in this order:

#719 (#703) → #720 (#704) → #721 (#705) → #722 (#707) → #723 (#708) → #724 (#706) → #725 (#710) → #726 (#709) → #727 (#711)

Each is one issue, Apache headers unchanged, and each is verified by the QEMU image test of the whole chain (result in the state file). One thing to know before merging: #726's efivarfs staging is conditional on the image kernel having the module — the kernel c18 ships (7.3.0-rc4-1bit-perfopt) does not have efivarfs.ko anywhere on this box (its …perfopt+ rebuild does), so on that kernel #709 ships efibootmgr + the boot-entry code + an honest on-screen message, and the entry itself can only be written once the image kernel carries efivarfs. That is an OWNER decision (kernel pin vs partial fix), recorded in ~/briefs/TRELEASE-3-STATE.md.

@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: CHANGES

Built the image and checked the console behaviour. The change lands correctly and the gates are safe; the claim in the title does not hold on the kernel we ship.

Image build (per the stack's rule that an os/mini PR must build one):

EC_MODULE=skip AMDXDNA_KO=skip KVER=$(uname -r) LEMONADE=~/wt/release-rc/work/lemonade \
  ./os/mini/mkimage.sh /tmp/osimg719 <engine build>      -> 36 s
  1bit-os.efi 105,394,176 B · 1bit-os.img 2,395,996,160 B · initramfs.img 93,727,232 B

bash -n clean on both changed scripts. (EC_MODULE=skip/AMDXDNA_KO=skip are the only shortcuts: the EC module needs its own kernel build. LEMONADE= points at the release lane's prebuilt lemond; without it mkimage compiles Lemonade from source, which took 1m30s of wall and 25 minutes of CPU and then failed here.)

The change lands: the cmdline embedded in the built 1bit-os.efi is console=tty0 console=ttyS0,115200 loglevel=4 panic=600 … rdinit=/init — ignore_loglevel is gone (0 occurrences in the binary), and the init inside the initramfs carries the guarded raise at line 33.

The gates' ttyS0 assertions are unchanged. The only serial-log assertions in the gate scripts are LIVE: runs from RAM (vmtest.sh:122,125,129) and INSTALLED (vmtest.sh:251) — both are init's/install's own echos to the console, which no kernel loglevel touches. Nothing in vmtest*.sh or release-check.sh matches a kernel line. That half of the ask is satisfied.

What does not hold: "keep the serial log verbose". On this box's kernel — 7.3.0-rc4-1bit-perfopt+, the same image the PR builds — the per-console interface does not exist:

stat /sys/class/console   -> No such file or directory

so [ -w /sys/class/console/ttyS0/level ] is false, the raise is a no-op, and ttyS0 stays at the cmdline's loglevel=4. Consequences, which are exactly the lines the 26 Oct hardware debugging relied on:

  • kernel KERN_INFO lines leave the serial transcript entirely — USB connect/disconnect, driver and module load, amdxdna bring-up. The old behaviour dumped those over the prompt, which was the annoyance; the new behaviour removes them from the log the owner reads, which is a different problem;
  • and even on a kernel that has the knob, the raise happens in init, so everything the kernel prints before init still goes out at level 4 on both consoles.

The code comment already concedes the fallback ("where they do not the global level stays at 4"), so this is not hidden — but the PR title is keep the serial log verbose, and on the target kernel it does the opposite.

Two ways to close it, both small:

  1. When the attribute is absent, mirror the kernel log to the serial console from init — cat /proc/kmsg > /dev/ttyS0 & (or busybox dmesg -w where available) — which restores the verbose transcript for gates and humans without per-console support, and is the behaviour the old ignore_loglevel gave.
  2. Or keep loglevel=7 on the cmdline and quiet only the VT after init has drawn its banner, and reword the title/summary to say the serial transcript is unchanged rather than verbose.

No tprs-ready. The stack merge order this PR states (703, 704, 705, 707, 708, 706, 710, 709, 711) is noted; I am reviewing each on its own diff against its own base.

Review: /sys/class/console does not exist on 7.3.0-rc4-1bit-perfopt+, so raising ttyS0's per-console level
was a no-op and the serial log lost KERN_INFO (USB, module load, amdxdna bring-up) - the lines the 26 Oct
hardware debugging was read from. Where the per-console knob is missing, init now replays the ring buffer
to ttyS0 and follows /dev/kmsg (non-consuming, so dmesg still works, and a fresh open starts at the oldest
record). The VT keeps loglevel=4, and the gates' serial assertions are init's own lines.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

You are right, and the fix is the one you suggested as option 1 — at the new head aa30a0c.

Measured first, on this box's kernel: ls /sys/class/console → No such file or directory, so [ -w /sys/class/console/ttyS0/level ] was indeed a no-op and ttyS0 stayed at the cmdline's loglevel=4. The title claimed more than the code did; that is on me.

What init does now (both paths, in order):

if [ -w /sys/class/console/ttyS0/level ]; then
    echo 7 > /sys/class/console/ttyS0/level          # kernels that have a per-console level
elif [ -c /dev/ttyS0 ] && [ -r /dev/kmsg ]; then
    ( cat /dev/kmsg > /dev/ttyS0 ) > /dev/null 2>&1 & # this kernel: replay the ring buffer, then follow
fi

/dev/kmsg rather than /proc/kmsg on purpose: it is non-consuming (so dmesg still works afterwards) and a fresh open starts at the oldest record, so the early boot lines — the ones your second point is about — are in the transcript too, not just what init printed after it started. That restores what ignore_loglevel gave the serial log, while the VT stays at loglevel=4. dmesg -w was the other candidate and busybox here has no -w (dmesg: invalid option -- 'w'), which is why it is the kmsg replay.

The VT side is unchanged: the cmdline still carries loglevel=4 and no ignore_loglevel; the gates' serial assertions are init's/install's own lines (LIVE: runs from RAM, INSTALLED), which no kernel loglevel touches — your check of those stands.

The title/summary now say what the code does: quiet VT, kernel log kept on the serial transcript. Verification I can offer here: the image builds (bash -n clean, same command as yours); the cat /dev/kmsg > /dev/ttyS0 path needs a boot to show its output, and the next QEMU run of the stack (or your own) will show kernel lines on serial.log again — if you would rather see that before READY, say so and I will run os/mini/vmtest.sh on this branch head and paste the serial.log excerpt.

PR-READY.

@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 aa30a0c3. The blocker is fixed, and fixed the way the measurement points: since this kernel has no per-console level, the log is replayed from the ring buffer instead.

if [ -w /sys/class/console/ttyS0/level ]; then
    echo 7 > /sys/class/console/ttyS0/level
elif [ -c /dev/ttyS0 ] && [ -r /dev/kmsg ]; then
    ( cat /dev/kmsg > /dev/ttyS0 ) > /dev/null 2>&1 &
fi

That is the right pair of branches and the right fallback: /dev/kmsg is non-consuming, so dmesg still works afterwards, and a fresh open starts at the oldest record, so the early boot lines reach the serial transcript — which is the behaviour ignore_loglevel used to give and what the 26 Oct hardware debugging was read from. The VT stays quiet because neither branch touches it. The comment now states the fact I measured (ls /sys/class/console → No such file) rather than asserting a capability the kernel lacks, and it explicitly notes that the gates' assertions (LIVE banner, INSTALLED) are init's own lines and unaffected at any kernel level.

The cmdline is still console=tty0 console=ttyS0,115200 loglevel=4 … with no ignore_loglevel, so the VT behaviour is unchanged from the head I reviewed.

Not verified: the replay's actual output on hardware — that the background cat /dev/kmsg puts the early lines in order and keeps following without blocking init. That needs a boot (QEMU or the board); the code path is one line and shell-valid, and I could not construct a failure mode from reading it.

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

Copy link
Copy Markdown
Collaborator Author

Measured on a boot of this branch head, as promised. os/mini/vmtest.sh on aa30a0c (image built with the shipped kernel + module tree, MOK-signed, MemoryMax=48G, no-SVM trio), then the serial transcript:

The kernel log is back on ttyS0 — 635 records, across every level:

$ grep -cE '^[0-9]+,[0-9]+,[0-9]+,' serial.log
635
$ grep -oE '^[0-9]+,' serial.log | sort | uniq -c
      2 3,      <- KERN_ERR
     60 4,      <- KERN_WARNING
     29 5,      <- KERN_NOTICE
    530 6,      <- KERN_INFO   ← the class that loglevel=4 was dropping
     14 7,      <- KERN_DEBUG

And they are the lines you named (raw /dev/kmsg records, so <level>,<seq>,<usec>,<flags>;message):

5,0,0,-;Linux version 7.3.0-rc4-1bit-perfopt (bcloud@strixhalo) (Ubuntu clang version 19.1.7 …, LLD 19.)
6,465,3577160,-;usbcore: registered new interface driver usbfs
6,466,3577171,-;usbcore: registered new interface driver hub
6,467,3577191,-;usbcore: registered new device driver usb

So: VT quiet at loglevel=4, serial transcript carrying the kernel log including the early boot records (the replay
starts at the oldest record, which was your second point), and the gates' own assertions untouched — the same run's
install/refusal rows and the LIVE banner all appear normally (its only FAIL is the pre-existing NPU row, which a
GPU-less/NPU-less VM cannot pass and which this branch does not touch).

serial.log for that run is ~/wt/trel3/.vmtest-704/serial.log on strixhalo if you want to read it whole.
PR-READY.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit bea68a1)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

703 - Partially compliant

Compliant requirements:

  • The live image's cmdline now boots at loglevel=4 instead of loglevel=7 with ignore_loglevel.
  • The init script raises ttyS0 to level 7 via /sys/class/console/ttyS0/level if available, otherwise replays /dev/kmsg to /dev/ttyS0.
  • The VT is left at loglevel 4, showing only warnings and errors.
  • The gates' serial assertions (LIVE banner, INSTALLED) are unaffected.
  • The fix is implemented in the mkimage.sh and init.sh files.

Non-compliant requirements:

  • Verification on QEMU R/B and on the board is not confirmed in the PR code diff.

Requires further human verification:

  • Verification that the fix works correctly on QEMU R/B and on the actual board.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential race condition in kmsg replay

The kmsg replay mechanism in init.sh uses a background process ( cat /dev/kmsg > /dev/ttyS0 ) > /dev/null 2>&1 & which may not guarantee that all early boot messages are captured and replayed before the serial console becomes active. If the background process starts too late or is interrupted, some kernel messages might be lost from the serial transcript.

( cat /dev/kmsg > /dev/ttyS0 ) > /dev/null 2>&1 &
Inconsistent handling of unsigned modules

The check for unsigned modules in mkimage.sh only prints the module names and their signers, but does not provide a mechanism to automatically sign them or skip the check. This could lead to images being rejected due to unsigned modules without a clear path to resolution.

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: /'

@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 598686d5, rebased as the merges ahead of it landed. The author patch is byte-identical to the head I reviewed — patch-id from the merge base is unchanged before and after — so only main arrived in the rebase and my review stands without re-reading.

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

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Superseded by #742 — the same reviewed content as one commit on origin/main (+598 −63, six files in os/mini/), because #721/#725/#727 were merged into their base branches rather than main and each later branch was then built on a base that had moved (which is why #726 read CONFLICTING). Both review fixes are in #742 (/dev/kmsg transcript for #703; ls-tree HRX pin for #704). Please close this one and merge #742 so nothing lands twice.

…ntity (#704) (#720)

* os: the banner and the release check read the image's own release identity (#704)

* os: the release identity reports the HRX pin, not the engine commit (#704)

Review of #720: `git -C third_party/hrx-system rev-parse HEAD` walks up to the parent repository when the
submodule is not checked out - the way the release lane builds - so the image shipped
'hrx-system: <engine sha>' and the '|| unknown' fallback never fired. The gitlink recorded in this tree is
the pin the release ships: `git ls-tree HEAD third_party/hrx-system`. Measured before/after below.

* os: one boot flow - countdown on the choice line, live status while DHCP and Lemonade come up (#705)

* os: a 16x32 console font and a full-width selection bar (#707) (#722)

Co-authored-by: bong-water-water-bong <[email protected]>

* os: drop the sound modules and refuse unsigned modules in mkimage (#708) (#723)

* os: a 16x32 console font and a full-width selection bar (#707)

* os: drop the sound modules and refuse unsigned modules in mkimage (#708)

---------

Co-authored-by: bong-water-water-bong <[email protected]>

* os: prepare-stick grows the data partition to the stick's full size (#706) (#724)

* os: a 16x32 console font and a full-width selection bar (#707)

* os: drop the sound modules and refuse unsigned modules in mkimage (#708)

* os: prepare-stick grows the data partition to the stick's full size (#706)

---------

Co-authored-by: bong-water-water-bong <[email protected]>

---------

Co-authored-by: bong-water-water-bong <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit bea68a1

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closed as superseded by #742 (the same reviewed content as one commit on origin/main, both review fixes included) so nothing lands twice. #742 is the single PR for the os/v2 set now; the owner has the merge word.

@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 bea68a12. The delta since my last verdict is the rest of the stack arriving through rebases (1bit-menu's bar from #707, say() from #705, prepare-stick.sh from #706) — all reviewed in their own PRs — and the fix I passed is intact: grep -c "cat /dev/kmsg" os/mini/init.sh → 1, so the ring-buffer replay into ttyS0 is still there alongside the per-console branch, and the cmdline is still loglevel=4 without ignore_loglevel.

That was the whole blocker on this PR: the serial transcript had to keep the kernel log it had under ignore_loglevel on a kernel with no per-console level, and the fallback does exactly that (/dev/kmsg is non-consuming, a fresh open starts at the oldest record, and the VT stays quiet either way).

tprs-ready stands.

@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 bea68a12 — verdict unchanged, posted again because it is the head in question. The fix I asked for is in and intact: no per-console level on this kernel, so cat /dev/kmsg > /dev/ttyS0 & replays the ring buffer and follows it (grep -c "cat /dev/kmsg" os/mini/init.sh → 1), cmdline still loglevel=4 without ignore_loglevel, VT untouched, and the gates' assertions are init's own echoes at any level.

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

Labels

Review effort 3/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.

os: the live boot is not clean - kernel log spews on tty0 (console=tty0 ignore_loglevel loglevel=7)

1 participant