Compare commits

...
Author SHA1 Message Date
BFE EngineeringandClaude Opus 5.5 b4596ed737 kernel: keep the arm32 vDSO clock off the virtual counter (#35)
ci / test (push) Successful in 31s
ci / bench (push) Successful in 14s
ci / mcdc (push) Successful in 26s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 1m18s
ci / badges (push) Skipped
ci / bench (pull_request) Successful in 10s
ci / patches-apply (push) Successful in 52s
ci / qemu-tools (push) Successful in 3m26s
ci / kernel-symbols (push) Successful in 5m12s
ci / test (pull_request) Successful in 8s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / badges (pull_request) Skipped
ci / qemu-tools (pull_request) Successful in 2m59s
ci / mcdc (pull_request) Successful in 19s
ci / patches-apply (pull_request) Successful in 52s
ci / quality (pull_request) Successful in 1m15s
ci / kernel-symbols (pull_request) Successful in 6m57s
On the RV1106 the boot firmware does not enter the kernel in HYP mode and
leaves CNTVOFF non-zero. The DT timer node lists no virtual-timer PPI, so
the kernel keeps time on the physical counter, while the arm32 vDSO always
reads the virtual one: on bench a clock_gettime() ran 738.9 s ahead of the
kernel clock (pure offset, -0.1 ppm over 30 s) and every absolute deadline
taken from it expired minutes late (flare-edge#2319, the #2311 reset loop).

New patch 82-arch-timer-vdso-phys-counter.patch:
- rv1106.dtsi and rv1106-warden-m2.dts: the timer node carries
  arm,cpu-registers-not-fw-configured. The kernel keeps the physical
  timer it uses today, and arch/arm/kernel/vdso.c drops the vDSO clock
  symbols, so libc goes straight to the syscall.
- arm_arch_timer.c: on arm32, a kernel on the physical counter without
  HYP mode sets the counter's vdso_clock_mode to VDSO_CLOCKMODE_NONE, the
  safety net for a device tree without the property. QEMU -M virt (virtual
  PPI present) is unchanged.

tests/arch-timer/check-vdso-counter.py checks both guards in the patched
tree; CI's patches-apply job runs it and its 12 regression cases.

Fixes #35
Refs flare-edge#2319

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-29 03:37:08 -06:00
noah 4ff7c19537 Merge pull request 'qemu: ui-drive waits for the chain start on an init-chain boot (flare-edge#2295)' (#34) from rb/ln-init-chain-wait into rebuild
ci / test (push) Successful in 28s
ci / bench (push) Successful in 14s
ci / qemu-tools (push) Successful in 1m44s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / mcdc (push) Successful in 28s
ci / patches-apply (push) Successful in 47s
ci / quality (push) Successful in 1m28s
ci / kernel-symbols (push) Successful in 4m57s
ci / badges (push) Skipped
2026-10-28 18:00:14 -06:00
BFE EngineeringandClaude Opus 5.5 a9f2b9b26a qemu: ui-drive waits for the chain start on an init-chain boot (flare-edge#2295)
ci / test (pull_request) Successful in 24s
ci / mcdc (pull_request) Successful in 17s
ci / badges (push) Skipped
ci / test (push) Successful in 9s
ci / qemu-tools (push) Successful in 1m27s
ci / bench (pull_request) Successful in 5s
ci / mcdc (push) Successful in 12s
ci / bench (push) Successful in 5s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 43s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 24s
ci / quality (pull_request) Successful in 2m35s
ci / kernel-symbols (pull_request) Successful in 5m7s
ci / quality (push) Successful in 1m28s
ci / qemu-tools (pull_request) Successful in 1m36s
ci / badges (pull_request) Skipped
ci / kernel-symbols (push) Successful in 5m2s
ui-drive.sh --init-chain boots with warden.initchain, where sbin/init starts
the UI through the panel's S99lvgl and prints "init: chain started N
script(s)"; the direct-start line "init: starting warden-ui" is never
printed. ui-drive.sh still waited for that line, so the first flare-edge
"QEMU UI shipped init chain" run (job 99350) gave "warden-ui never started"
after 180 s on a chain that had booted cleanly.

The wait moves to qemu/tests/ui-start.sh (sourced by ui-drive.sh and
ui-shot.sh): wait_ui_started picks the marker by mode and, on a chain boot,
fails at once on WARDEN-QEMU-INITCHAIN-EMPTY or a failed S99lvgl instead of
at the deadline.

Tests: new qemu/tests/ui-start-test.sh (27 checks, in CI): every marker is
the one sbin/init or warden-lib.sh prints in that mode, the job 99350
console counts as started in chain mode, empty and failed chains fail fast,
a dead VM and a silent console fail with their own messages, and both
drivers wait through the helper. The old ui-drive.sh fails 4 checks.

Fixes flare-edge#2295

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-28 17:17:14 -06:00
noah 6e51f1a0e5 Merge pull request 'qemu: ui-drive --init-chain and the assert_ui_chain verb (flare-edge#2210)' (#33) from rb/ln-init-chain-boot into rebuild
ci / test (push) Successful in 27s
ci / bench (push) Successful in 5s
ci / mcdc (push) Successful in 14s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 22s
ci / qemu-tools (push) Successful in 2m58s
ci / quality (push) Successful in 58s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 7m35s
2026-10-28 12:30:24 -06:00
9 changed files with 517 additions and 24 deletions
+12
View File
@@ -178,6 +178,11 @@ jobs:
if command -v busybox >/dev/null; then
WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-chain-test.sh
fi
- name: ui-drive.sh / ui-shot.sh UI start wait regression test (flare-edge#2295)
# The console line that means "UI started" differs between a direct
# start and a shipped init chain boot; every marker is checked
# against sbin/init, and a chain failure fails at once.
run: bash qemu/tests/ui-start-test.sh
- name: mkimage.sh ROOTFS_OVERLAY regression test (flare-edge#2210)
# The panel's scripts land in both slots with their modes; an overlay
# reaching outside etc/ and usr/, or holding a symlink, writes no image.
@@ -323,6 +328,13 @@ jobs:
&& echo "applied $p" || { echo "FAILED to apply $p"; exit 1; }
done
echo "full series applied cleanly onto pristine 6.18.46"
- name: arm32 vDSO stays off the virtual counter (bfe-core1106-sdk#35)
# The kernel times on the physical counter and the firmware leaves
# CNTVOFF non-zero, so the vDSO clock must stay off: the DT property and
# the arm_arch_timer.c fallback both have to survive in the patched tree.
run: |
bash tests/arch-timer/run-check-vdso-counter-tests.sh
python3 tests/arch-timer/check-vdso-counter.py /tmp/linux-6.18.46
# Automatic artifact GC (mirrors flare-edge). An exceeded account-wide Actions
# storage quota blocks ALL new runs (startup_failure), not just uploads, so
@@ -0,0 +1,62 @@
diff --git a/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts b/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts
--- a/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts
+++ b/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts
@@ -74,6 +74,15 @@
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
clock-frequency = <24000000>;
+ /*
+ * The boot firmware does not enter the kernel in HYP mode and leaves
+ * CNTVOFF non-zero (bfe-core1106-sdk#35): the virtual counter the
+ * arm32 vDSO reads runs a fixed offset away from the physical one
+ * the kernel keeps time on. This keeps the kernel on the physical
+ * timer and drops the vDSO clock calls, so clock_gettime() uses the
+ * syscall and agrees with every kernel deadline.
+ */
+ arm,cpu-registers-not-fw-configured;
};
gic: interrupt-controller@ff1f0000 {
diff --git a/arch/arm/boot/dts/rockchip/rv1106.dtsi b/arch/arm/boot/dts/rockchip/rv1106.dtsi
--- a/arch/arm/boot/dts/rockchip/rv1106.dtsi
+++ b/arch/arm/boot/dts/rockchip/rv1106.dtsi
@@ -417,6 +417,15 @@
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
clock-frequency = <24000000>;
+ /*
+ * The boot firmware does not enter the kernel in HYP mode and leaves
+ * CNTVOFF non-zero (bfe-core1106-sdk#35): the virtual counter the
+ * arm32 vDSO reads runs a fixed offset away from the physical one
+ * the kernel keeps time on. This keeps the kernel on the physical
+ * timer and drops the vDSO clock calls, so clock_gettime() uses the
+ * syscall and agrees with every kernel deadline.
+ */
+ arm,cpu-registers-not-fw-configured;
};
grf: syscon@ff000000 {
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -933,6 +933,20 @@ static void __init arch_counter_register(void)
arch_timer_read_counter = rd;
clocksource_counter.vdso_clock_mode = vdso_default;
+ /*
+ * The arm32 vDSO always reads the virtual counter. A kernel that keeps
+ * time on the physical counter and was not entered in HYP mode never
+ * had CNTVOFF zeroed by the hyp stub, so the vDSO clock may sit a fixed
+ * offset away from the kernel's and absolute deadlines taken from it
+ * expire late. Fall back to the syscall then.
+ */
+ if (IS_ENABLED(CONFIG_ARM) && arch_timer_uses_ppi != ARCH_TIMER_VIRT_PPI &&
+ !is_hyp_mode_available() &&
+ clocksource_counter.vdso_clock_mode != VDSO_CLOCKMODE_NONE) {
+ clocksource_counter.vdso_clock_mode = VDSO_CLOCKMODE_NONE;
+ pr_info("physical counter without HYP: vDSO clock disabled\n");
+ }
+
width = arch_counter_get_width();
clocksource_counter.mask = CLOCKSOURCE_MASK(width);
cyclecounter.mask = CLOCKSOURCE_MASK(width);
+4 -2
View File
@@ -1,8 +1,9 @@
# The Kernel Patch Series
The delta that forward-ports the vendor Rockchip 5.10.160 RV1106 support onto a
pristine upstream **linux-6.18.46**, as a reviewable, subsystem-split series. Every
patch applies cleanly onto pristine 6.18.46 (`git apply --check`), and the whole set
pristine upstream **linux-6.18.46**, as a reviewable, subsystem-split series. The
series applies cleanly, in order, onto pristine 6.18.46 (`git apply --check`; a fix
patch such as 82 edits files that an earlier patch adds), and the whole set
reproduces the 223-file / ~136K-line delta that boots and is hardware-verified on
`warden-c8a3` (see `../kernel/rv1106-enablement/`).
@@ -28,6 +29,7 @@ with `../build/warden_defconfig` -> `zImage` + `rv1106-warden.dtb`).
| `60-wifi-aic8800.patch` | out-of-tree AIC8800 wifi/BT (the 88.5K-line vendor blob) |
| `70-audio-codec.patch` | `rv1106_codec` + I2S wiring |
| `80-misc-thermal-rtc-adc.patch` | tsadc, rtc-rockchip, saradc, trng, otp, gmac, goodix touch |
| `82-arch-timer-vdso-phys-counter.patch` | arch timer: keep the arm32 vDSO clock off the virtual counter while the kernel times on the physical one (CNTVOFF left non-zero by the boot firmware, #35); checked by `tests/arch-timer/check-vdso-counter.py` |
| `90-kconfig-no-python-symbol.patch` | drops `DRM_MSM_VALIDATE_XML` so the expanded `.config` (and `KCONFIG_SHA256`) does not depend on the host python (#19) |
## License
+5 -11
View File
@@ -36,6 +36,8 @@
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # qemu/tests/
QDIR="$(cd "$HERE/.." && pwd)" # qemu/
# shellcheck source=qemu/tests/ui-start.sh disable=SC1091
. "$HERE/ui-start.sh"
SEED_FILE=""
REFS_FILE=""
@@ -252,17 +254,9 @@ if [ -n "$RS485_DEVICES" ]; then
fi
echo "== waiting for warden-ui"
deadline=$((SECONDS + 180))
while [ $SECONDS -lt $deadline ]; do
grep -aq 'init: starting warden-ui' "$WORK/console.log" && break
kill -0 "$QEMU_PID" 2>/dev/null || { echo "FATAL: VM exited early" >&2; tail -25 "$WORK/console.log" >&2; exit 1; }
sleep 2
done
grep -aq 'init: starting warden-ui' "$WORK/console.log" || {
echo "FATAL: warden-ui never started (no fb0? wrong kernel?)" >&2
tail -25 "$WORK/console.log" >&2
exit 1
}
# A chain boot reports the start through the chain, not the direct-start line
# (ui-start.sh, flare-edge#2295).
wait_ui_started "$WORK/console.log" "$QEMU_PID" 180 "$([ -n "$INIT_CHAIN" ] && echo 1 || echo 0)" || exit 1
# A started process is not a rendered frame. Poll screendumps until the panel
# stops being a single flat colour, on a bounded deadline: TCG renders CPU-bound
+3 -11
View File
@@ -13,6 +13,8 @@ set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # qemu/tests/
QDIR="$(cd "$HERE/.." && pwd)" # qemu/
# shellcheck source=qemu/tests/ui-start.sh disable=SC1091
. "$HERE/ui-start.sh"
ZIMAGE="${1:-}"
OUTDIR="${2:-$QDIR/out}"
@@ -66,17 +68,7 @@ if [ -z "$QEMU_PID" ] || ! kill -0 "$QEMU_PID" 2>/dev/null; then
exit 1
fi
deadline=$((SECONDS + 120))
while [ $SECONDS -lt $deadline ]; do
grep -aq 'init: starting warden-ui' "$WORK/console.log" && break
kill -0 "$QEMU_PID" 2>/dev/null || { echo "FATAL: VM exited early" >&2; tail -25 "$WORK/console.log" >&2; exit 1; }
sleep 2
done
grep -aq 'init: starting warden-ui' "$WORK/console.log" || {
echo "FATAL: warden-ui never started (no fb0? wrong kernel?)" >&2
tail -25 "$WORK/console.log" >&2
exit 1
}
wait_ui_started "$WORK/console.log" "$QEMU_PID" 120 0 || exit 1
qmp() { python3 "$HERE/qmp.py" "$WORK/qmp.sock" "$@"; }
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env bash
# shellcheck disable=SC2016 # the single-quoted $ strings are literal patterns and child-shell args
# Host test for qemu/tests/ui-start.sh (flare-edge#2295): the console line
# ui-drive.sh and ui-shot.sh wait for before driving the UI. Offline, no VM.
#
# flare-edge job 99350 (the first "QEMU UI shipped init chain" run) booted
# the chain cleanly but ui-drive.sh waited 180 s for the direct-start line,
# which a warden.initchain boot never prints. This test pins:
# - every marker ui-start.sh waits for is printed by rootfs/sbin/init or
# rootfs/etc/warden-lib.sh, in the mode it is used for;
# - a chain-boot console (the 99350 lines) counts as started in chain
# mode, and a direct-start console in direct mode;
# - an empty chain and a failed S99lvgl fail at once, not at the deadline;
# - a dead VM and a silent console fail with their own messages;
# - ui-drive.sh and ui-shot.sh wait through ui-start.sh only, and
# ui-drive.sh passes chain mode exactly when --init-chain is given.
#
# bash ui-start-test.sh
set -uo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
INIT="$HERE/../rootfs/sbin/init"
LIB="$HERE/../rootfs/etc/warden-lib.sh"
WORK="$(mktemp -d "${TMPDIR:-/tmp}/warden-ui-start.XXXXXX")" || exit 1
VMPID=""
# shellcheck disable=SC2317 # called from the EXIT trap
cleanup() { [ -n "$VMPID" ] && kill "$VMPID" 2>/dev/null; rm -rf "$WORK"; }
trap cleanup EXIT
FAIL=0
CHECKS=0
check() { # check <label> <command...>
CHECKS=$((CHECKS + 1))
if "${@:2}"; then echo "[PASS] $1"; else echo "[FAIL] $1"; FAIL=1; fi
}
# shellcheck source=qemu/tests/ui-start.sh disable=SC1091
. "$HERE/ui-start.sh"
UI_START_POLL=0.1
export UI_START_POLL
# --- the markers are the ones init prints -----------------------------------
check "direct-start marker is echoed by sbin/init" \
grep -qF "echo \"$UI_START_DIRECT" "$INIT"
check "chain marker is echoed by sbin/init" \
grep -qF "echo \"$UI_START_CHAIN" "$INIT"
check "empty-chain marker is echoed by sbin/init" \
grep -qF "echo \"$UI_FAIL_CHAIN_EMPTY" "$INIT"
check "the chain marker is printed only on a chain boot" \
awk -v m="echo \"$UI_START_CHAIN" '
/^if \[ "\$initchain" = 1 \]; then/ { inchain = 1 }
inchain && /^fi$/ { inchain = 0 }
index($0, m) { found = 1; if (!inchain) bad = 1 }
END { exit !(found && !bad) }' "$INIT"
check "the direct-start marker is printed only on a direct boot" \
awk -v m="echo \"$UI_START_DIRECT" '
/^if \[ "\$initchain" = 0 \]/ { indirect = 1 }
indirect && /^fi$/ { indirect = 0 }
index($0, m) { found = 1; if (!indirect) bad = 1 }
END { exit !(found && !bad) }' "$INIT"
check "ui_start_marker picks the mode's marker" \
test "$(ui_start_marker 0)|$(ui_start_marker 1)" = "$UI_START_DIRECT|$UI_START_CHAIN"
# The S99lvgl failure line, from the real warden_init_chain with a failing stub.
D="$WORK/init.d"
mkdir -p "$D"
printf '#!/bin/sh\nexit 4\n' > "$D/S99lvgl"
chmod 0755 "$D/S99lvgl"
WARDEN_INITD="$D" sh -c '. "$1"; warden_init_chain 10 99' sh "$LIB" > /dev/null 2> "$WORK/lvgl-fail.err"
check "warden_init_chain prints the S99lvgl failure line ui-start.sh watches for" \
grep -qF "$UI_FAIL_CHAIN_LVGL rc=4" "$WORK/lvgl-fail.err"
# --- console fixtures -------------------------------------------------------
# Chain boot, as flare-edge job 99350 printed it.
cat > "$WORK/chain.log" <<'EOF'
WARDEN-QEMU-ROOTFS-OK slot=_a
init: shipped init chain (warden.initchain)
init: chain S03warden-accounts start
Creating platform accounts: OK
init: rig bus up on /run/warden/bus/bus.sock (broker pid 253)
init: starting warden-modbus
init: starting warden-flared
init: chain S99lvgl start
warden-ui: no backlight device
Starting Warden UI: OK
init: chain started 2 script(s)
init: control bridge on /dev/ttyS0
EOF
cat > "$WORK/direct.log" <<'EOF'
WARDEN-QEMU-ROOTFS-OK slot=_a
init: starting warden-modbus
init: starting warden-ui (fbdev)
EOF
cat > "$WORK/empty-chain.log" <<'EOF'
init: shipped init chain (warden.initchain)
init: starting warden-flared
WARDEN-QEMU-INITCHAIN-EMPTY: warden.initchain but no /etc/init.d/S* script; the UI is not started
EOF
{ head -n 8 "$WORK/chain.log"; cat "$WORK/lvgl-fail.err"; } > "$WORK/lvgl-fail.log"
: > "$WORK/silent.log"
sleep 60 &
VMPID=$!
run_wait() { # run_wait <log> <secs> <chain>: rc in $RC, stderr in $WORK/err, seconds in $TOOK
local t0=$SECONDS
wait_ui_started "$WORK/$1" "$VMPID" "$2" "$3" 2> "$WORK/err"
RC=$?
TOOK=$((SECONDS - t0))
}
run_wait chain.log 5 1
check "chain console counts as started in chain mode (flare-edge#2295)" test "$RC" = 0
run_wait chain.log 0 0
check "the same console is not a direct start (the 99350 failure)" test "$RC" = 1
check "a direct-mode timeout names the direct start" \
grep -qF "warden-ui never started" "$WORK/err"
run_wait direct.log 5 0
check "direct console counts as started in direct mode" test "$RC" = 0
run_wait direct.log 0 1
check "a direct console is not a chain start" test "$RC" = 1
check "a chain-mode timeout names the chain marker" \
grep -qF "the shipped init chain never reported its start" "$WORK/err"
run_wait empty-chain.log 30 1
check "an empty chain fails" test "$RC" = 1
check "an empty chain fails at once, not at the deadline" test "$TOOK" -lt 5
check "an empty chain says why" grep -qF "has no /etc/init.d/S* script" "$WORK/err"
run_wait lvgl-fail.log 30 1
check "a failed S99lvgl fails" test "$RC" = 1
check "a failed S99lvgl fails at once" test "$TOOK" -lt 5
check "a failed S99lvgl names its status" grep -qF "S99lvgl start FAILED rc=4" "$WORK/err"
run_wait silent.log 1 1
check "a silent console times out" test "$RC" = 1
kill "$VMPID" 2>/dev/null
wait "$VMPID" 2>/dev/null
run_wait silent.log 30 1
check "a dead VM fails at once with its own message" \
sh -c 'test "$1" = 1 && test "$2" -lt 5 && grep -qF "VM exited early" "$3"' sh "$RC" "$TOOK" "$WORK/err"
VMPID=""
# --- the drivers use it -----------------------------------------------------
for s in ui-drive.sh ui-shot.sh; do
check "$s sources ui-start.sh" grep -qF '. "$HERE/ui-start.sh"' "$HERE/$s"
check "$s waits through wait_ui_started" grep -q '^wait_ui_started ' "$HERE/$s"
done
check "no driver greps a UI start marker of its own" \
sh -c '! grep -lF "init: starting warden-ui" "$1"/*.sh | grep -v "/ui-start.sh$" | grep -v "/ui-start-test.sh$" | grep -q .' sh "$HERE"
check "ui-drive.sh waits in chain mode exactly when --init-chain is given" \
grep -qF 'wait_ui_started "$WORK/console.log" "$QEMU_PID" 180 "$([ -n "$INIT_CHAIN" ] && echo 1 || echo 0)"' "$HERE/ui-drive.sh"
echo "ui-start: $CHECKS checks, $([ "$FAIL" = 0 ] && echo OK || echo FAILED)"
exit "$FAIL"
+61
View File
@@ -0,0 +1,61 @@
# shellcheck shell=bash
# Sourced by ui-drive.sh and ui-shot.sh: wait for stage-2 init to report the
# UI started, from the VM console log.
#
# The console line depends on how the UI is started (rootfs/sbin/init):
# direct start (default) "init: starting warden-ui (fbdev)"
# shipped chain (warden.initchain, ui-drive.sh --init-chain)
# "init: chain started N script(s)", after
# the panel's S99lvgl ran; the direct start
# line is never printed (flare-edge#2295)
# A chain boot that cannot start the UI says so at once, so these fail fast
# instead of spending the whole deadline:
# "WARDEN-QEMU-INITCHAIN-EMPTY" no /etc/init.d/S* script at all
# "init: chain S99lvgl start FAILED rc=N" the UI's own script failed
# qemu/tests/ui-start-test.sh checks every marker here against sbin/init.
UI_START_DIRECT='init: starting warden-ui'
UI_START_CHAIN='init: chain started '
UI_FAIL_CHAIN_EMPTY='WARDEN-QEMU-INITCHAIN-EMPTY'
UI_FAIL_CHAIN_LVGL='init: chain S99lvgl start FAILED'
# ui_start_marker <initchain 0|1>: the console line that means "UI started".
ui_start_marker() {
if [ "${1:-0}" = 1 ]; then printf '%s' "$UI_START_CHAIN"; else printf '%s' "$UI_START_DIRECT"; fi
}
# wait_ui_started <console.log> <qemu pid> <seconds> <initchain 0|1>
# Returns 0 once the UI is reported started; prints a FATAL line and the
# console tail to stderr and returns 1 on a VM exit, a chain failure or the
# deadline.
wait_ui_started() {
local log="$1" pid="$2" secs="$3" chain="${4:-0}" marker deadline
marker="$(ui_start_marker "$chain")"
deadline=$((SECONDS + secs))
while :; do
grep -aqF "$marker" "$log" && return 0
if [ "$chain" = 1 ]; then
if grep -aqF "$UI_FAIL_CHAIN_EMPTY" "$log"; then
echo "FATAL: the init chain has no /etc/init.d/S* script, so warden-ui is not started" >&2
tail -25 "$log" >&2
return 1
fi
if grep -aqF "$UI_FAIL_CHAIN_LVGL" "$log"; then
echo "FATAL: S99lvgl failed in the shipped init chain: $(grep -aF "$UI_FAIL_CHAIN_LVGL" "$log" | head -1)" >&2
tail -25 "$log" >&2
return 1
fi
fi
kill -0 "$pid" 2>/dev/null || { echo "FATAL: VM exited early" >&2; tail -25 "$log" >&2; return 1; }
[ $SECONDS -lt $deadline ] || break
sleep "${UI_START_POLL:-2}"
done
grep -aqF "$marker" "$log" && return 0
if [ "$chain" = 1 ]; then
echo "FATAL: the shipped init chain never reported its start ('$marker' not on the console)" >&2
else
echo "FATAL: warden-ui never started (no fb0? wrong kernel?)" >&2
fi
tail -25 "$log" >&2
return 1
}
+109
View File
@@ -0,0 +1,109 @@
#!/usr/bin/env python3
"""Check that a patched kernel tree keeps the arm32 vDSO clock off the
virtual counter when the kernel times on the physical one (bfe-core1106-sdk#35).
On the RV1106 the boot firmware does not enter the kernel in HYP mode and
leaves CNTVOFF non-zero. The DT timer node lists no virtual-timer PPI, so the
kernel keeps time on the physical counter, while the arm32 vDSO always reads
the virtual counter: clock_gettime() then runs about 739 s ahead of the kernel
clock and every absolute deadline taken from it expires late (flare-edge#2319).
Two guards must both be present in the patched tree:
1. Every armv7/armv8 timer node in the RV1106 device trees that has no
virtual-timer PPI (GIC_PPI 11) carries `arm,cpu-registers-not-fw-configured`,
which makes arch/arm/kernel/vdso.c drop the vDSO clock symbols.
2. drivers/clocksource/arm_arch_timer.c sets the counter's vdso_clock_mode to
VDSO_CLOCKMODE_NONE on arm32 when the kernel uses the physical counter
without HYP mode (the safety net for a device tree without the property).
Usage: check-vdso-counter.py <patched kernel source dir>
Exit 0 when both hold, 1 with one FAIL line per problem, 2 on bad usage.
"""
import pathlib
import re
import sys
DTS_GLOB = "arch/arm/boot/dts/rockchip/rv1106*.dts*"
TIMER_C = "drivers/clocksource/arm_arch_timer.c"
PROPERTY = "arm,cpu-registers-not-fw-configured"
def strip_comments(text):
text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)
return re.sub(r"//[^\n]*", "", text)
def timer_nodes(text):
"""Yield the body of every node whose compatible is an arch timer."""
for m in re.finditer(r"\b[\w@,.-]+\s*\{", text):
depth, i = 1, m.end()
while depth and i < len(text):
depth += {"{": 1, "}": -1}.get(text[i], 0)
i += 1
body = text[m.end():i - 1]
# Only the node's own properties, not its children's.
own = re.sub(r"\{.*\}", "", body, flags=re.S)
if re.search(r'compatible\s*=\s*"arm,armv[78]-timer"', own):
yield own
def check_dts(root):
problems, seen = [], 0
for path in sorted(root.glob(DTS_GLOB)):
text = strip_comments(path.read_text(errors="replace"))
for own in timer_nodes(text):
seen += 1
has_virt = re.search(r"GIC_PPI\s+11\b", own) is not None
has_prop = re.search(r"(^|[\s;])" + re.escape(PROPERTY) + r"\s*;", own) is not None
if not has_virt and not has_prop:
problems.append(f"{path.relative_to(root)}: timer node has no virtual-timer "
f"PPI and no {PROPERTY}")
if not seen:
problems.append(f"no arm,armv7-timer node found under {DTS_GLOB}")
return problems
def check_timer_c(root):
path = root / TIMER_C
if not path.is_file():
return [f"{TIMER_C} missing"]
text = strip_comments(path.read_text(errors="replace"))
m = re.search(r"static void __init arch_counter_register\(void\)\s*\{", text)
if not m:
return [f"{TIMER_C}: arch_counter_register() not found"]
depth, i = 1, m.end()
while depth and i < len(text):
depth += {"{": 1, "}": -1}.get(text[i], 0)
i += 1
body = text[m.end():i - 1]
guard = re.search(
r"if\s*\(\s*IS_ENABLED\(CONFIG_ARM\)\s*&&\s*"
r"arch_timer_uses_ppi\s*!=\s*ARCH_TIMER_VIRT_PPI\s*&&\s*"
r"!\s*is_hyp_mode_available\(\)[^{]*\{([^}]*)\}", body)
if not guard or not re.search(
r"clocksource_counter\.vdso_clock_mode\s*=\s*VDSO_CLOCKMODE_NONE\s*;", guard.group(1)):
return [f"{TIMER_C}: arch_counter_register() lacks the arm32 physical-counter "
"vDSO fallback (vdso_clock_mode = VDSO_CLOCKMODE_NONE)"]
default_at = body.find("clocksource_counter.vdso_clock_mode = vdso_default;")
if default_at < 0 or default_at > guard.start():
return [f"{TIMER_C}: the vDSO fallback must come after the vdso_default assignment"]
return []
def main(argv):
if len(argv) != 2 or not pathlib.Path(argv[1]).is_dir():
print("usage: check-vdso-counter.py <patched kernel source dir>", file=sys.stderr)
return 2
root = pathlib.Path(argv[1])
problems = check_dts(root) + check_timer_c(root)
for p in problems:
print(f"FAIL: {p}")
if problems:
return 1
print("vdso-counter: ok (DT property and arm32 physical-counter fallback present)")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))
+109
View File
@@ -0,0 +1,109 @@
#!/bin/bash
# Regression tests for tests/arch-timer/check-vdso-counter.py (bfe-core1106-sdk#35).
#
# The checker guards the fix for the vDSO clock running 739 s ahead of the
# kernel clock on the RV1106: the DT timer property and the arm32 fallback in
# arm_arch_timer.c. Each case builds a small fake kernel tree and expects an
# exit status; the real patched tree is checked in CI's patches-apply job.
set -uo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
CHECK="$HERE/check-vdso-counter.py"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
TIMER_NODE_GOOD=' timer {
compatible = "arm,armv7-timer";
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
clock-frequency = <24000000>;
arm,cpu-registers-not-fw-configured;
};'
TIMER_NODE_BARE=' timer {
compatible = "arm,armv7-timer";
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
clock-frequency = <24000000>;
};'
TIMER_NODE_COMMENTED=' timer {
compatible = "arm,armv7-timer";
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
/* arm,cpu-registers-not-fw-configured; */
};'
TIMER_NODE_VIRT=' timer {
compatible = "arm,armv7-timer";
interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>, <GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>,
<GIC_PPI 11 IRQ_TYPE_LEVEL_LOW>, <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>;
};'
TIMER_NODE_CHILD=' timer {
compatible = "arm,armv7-timer";
interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>, <GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>;
sub {
arm,cpu-registers-not-fw-configured;
};
};'
GUARD=' if (IS_ENABLED(CONFIG_ARM) && arch_timer_uses_ppi != ARCH_TIMER_VIRT_PPI &&
!is_hyp_mode_available() &&
clocksource_counter.vdso_clock_mode != VDSO_CLOCKMODE_NONE) {
clocksource_counter.vdso_clock_mode = VDSO_CLOCKMODE_NONE;
pr_info("physical counter without HYP: vDSO clock disabled\n");
}'
GUARD_WRONG=' if (IS_ENABLED(CONFIG_ARM) && arch_timer_uses_ppi != ARCH_TIMER_VIRT_PPI &&
!is_hyp_mode_available()) {
pr_info("physical counter without HYP\n");
}'
DEFAULT=' clocksource_counter.vdso_clock_mode = vdso_default;'
mk_tree() { # mk_tree <name> <dtsi timer node> <timer.c body before> <body after>
local d="$TMP/$1"
mkdir -p "$d/arch/arm/boot/dts/rockchip" "$d/drivers/clocksource"
printf '/ {\n\tcpus { cpu@0 { reg = <0>; }; };\n%s\n};\n' "$2" \
> "$d/arch/arm/boot/dts/rockchip/rv1106.dtsi"
printf '#include "rv1106.dtsi"\n/ { model = "x"; };\n' \
> "$d/arch/arm/boot/dts/rockchip/rv1106-warden.dts"
printf 'static void __init arch_counter_register(void)\n{\n\tu64 (*rd)(void);\n%s\n\n%s\n\twidth = 56;\n}\n' \
"$3" "$4" > "$d/drivers/clocksource/arm_arch_timer.c"
echo "$d"
}
fails=0 n=0
expect() { # expect <name> <exit> <tree>
local got out
out="$(python3 "$CHECK" "$3" 2>&1)"; got=$?
n=$((n + 1))
if [ "$got" = "$2" ]; then
echo "PASS: $1"
else
echo "FAIL: $1 (wanted exit $2, got $got)"
while IFS= read -r line; do echo " $line"; done <<< "$out"
fails=$((fails + 1))
fi
}
expect "fixed tree passes" 0 "$(mk_tree good "$TIMER_NODE_GOOD" "$DEFAULT" "$GUARD")"
expect "timer node without the property fails" 1 "$(mk_tree bare "$TIMER_NODE_BARE" "$DEFAULT" "$GUARD")"
expect "property only inside a comment fails" 1 "$(mk_tree comm "$TIMER_NODE_COMMENTED" "$DEFAULT" "$GUARD")"
expect "property only in a child node fails" 1 "$(mk_tree child "$TIMER_NODE_CHILD" "$DEFAULT" "$GUARD")"
expect "timer node with a virtual PPI needs no property" 0 "$(mk_tree virt "$TIMER_NODE_VIRT" "$DEFAULT" "$GUARD")"
expect "missing arm32 fallback fails" 1 "$(mk_tree noguard "$TIMER_NODE_GOOD" "$DEFAULT" "")"
expect "fallback that does not set VDSO_CLOCKMODE_NONE fails" 1 "$(mk_tree wrong "$TIMER_NODE_GOOD" "$DEFAULT" "$GUARD_WRONG")"
expect "fallback before the vdso_default assignment fails" 1 "$(mk_tree order "$TIMER_NODE_GOOD" "$GUARD" "$DEFAULT")"
expect "no timer node at all fails" 1 "$(mk_tree none "" "$DEFAULT" "$GUARD")"
d="$(mk_tree m2 "$TIMER_NODE_GOOD" "$DEFAULT" "$GUARD")"
printf '/ {\n%s\n};\n' "$TIMER_NODE_BARE" > "$d/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts"
expect "a second board DTS without the property fails" 1 "$d"
rm -f "$d/drivers/clocksource/arm_arch_timer.c"
expect "missing arm_arch_timer.c fails" 1 "$d"
n=$((n + 1))
if python3 "$CHECK" >/dev/null 2>&1; [ $? = 2 ]; then echo "PASS: no argument is a usage error"
else echo "FAIL: no argument is a usage error"; fails=$((fails + 1)); fi
if [ "$fails" -ne 0 ]; then
echo "check-vdso-counter: $fails of $n FAILED"; exit 1
fi
echo "check-vdso-counter: all $n passed"