Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8d9d541fe | ||
|
|
1e182a44e4 | ||
|
|
bbc91618f8 | ||
|
|
579ac260ca | ||
|
|
0232823855 | ||
|
|
61ecfac844 | ||
|
|
ff3d1de088 | ||
|
|
8fc32976a5 | ||
|
|
0c98a6018f | ||
|
|
820af4baaa | ||
|
|
37037926df | ||
|
|
4d30c3083b | ||
|
|
b4596ed737 | ||
|
|
4ff7c19537 |
@@ -170,6 +170,14 @@ jobs:
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/ctl-bridge-test.sh
|
||||
fi
|
||||
- name: rig agent runs framed scripts under a deadline (flare-edge M9 soak-lite)
|
||||
# warden_agent against request lines on stdin; once more under
|
||||
# busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/agent-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/agent-test.sh
|
||||
fi
|
||||
- name: rig init boots through the shipped init chain (flare-edge#2210)
|
||||
# warden_init_chain against stub scripts and the warden.initchain
|
||||
# wiring in sbin/init; once more under busybox sh, the rig's own shell.
|
||||
@@ -178,6 +186,18 @@ jobs:
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-chain-test.sh
|
||||
fi
|
||||
- name: rig debug shell works without cttyhack (flare-edge#2210)
|
||||
# The panel's BusyBox has no cttyhack; warden.shell then opens the
|
||||
# console tty itself. Once more under busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/console-shell-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/console-shell-test.sh
|
||||
fi
|
||||
- name: panel BusyBox config and build helpers (flare-edge#2210)
|
||||
# panel.config carries the image's applet patch, the rig fragment only
|
||||
# changes linking, Kconfig rewrites and applet drift are caught: offline.
|
||||
run: bash qemu/tests/busybox-panel-test.sh
|
||||
- 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
|
||||
@@ -247,6 +267,24 @@ jobs:
|
||||
run: bash qemu/mkinitramfs.sh
|
||||
- name: build A/B disk image
|
||||
run: bash qemu/mkimage.sh
|
||||
- name: cache panel BusyBox source
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: qemu/out/busybox-1.37.0.tar.bz2
|
||||
key: busybox-src-1.37.0
|
||||
- name: build the panel BusyBox and check it against the bench capture (flare-edge#2210)
|
||||
# The image's BusyBox version, applet config and Buildroot patches,
|
||||
# linked static (qemu/build-busybox.sh). Its applet list and every
|
||||
# applet's --help must equal the panel's own binary's (captured on
|
||||
# bench a), run here through qemu-user. Then an initramfs with it.
|
||||
run: |
|
||||
sudo apt-get install -y -qq gcc-arm-linux-gnueabihf qemu-user
|
||||
bash qemu/build-busybox.sh
|
||||
QEMU_USER="qemu-arm" bash qemu/tests/busybox-panel-help.sh
|
||||
RIG_BUSYBOX=panel bash qemu/mkinitramfs.sh
|
||||
# A job without the cross compiler takes the binary as BUSYBOX,
|
||||
# checked by its .inputs (flare-edge flow jobs).
|
||||
RIG_BUSYBOX=panel BUSYBOX=qemu/out/busybox-armv7l-panel bash qemu/mkinitramfs.sh
|
||||
|
||||
kernel-symbols:
|
||||
# The symbol gate (rebuild M0, kernel_symbols_exist): expand the real
|
||||
@@ -328,6 +366,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
|
||||
@@ -426,6 +471,11 @@ jobs:
|
||||
bash qemu/mkinitramfs.sh
|
||||
bash qemu/tests/boot-smoke.sh \
|
||||
"$RUNNER_TEMP/kbuild-out/linux-6.18.46/arch/arm/boot/zImage"
|
||||
# Once more with the panel's BusyBox (RIG_BUSYBOX=panel, flare-edge#2210).
|
||||
OUT="$RUNNER_TEMP/panel-rig" RIG_BUSYBOX=panel bash qemu/mkinitramfs.sh
|
||||
bash qemu/tests/boot-smoke.sh \
|
||||
"$RUNNER_TEMP/kbuild-out/linux-6.18.46/arch/arm/boot/zImage" \
|
||||
"$RUNNER_TEMP/panel-rig/initramfs.cpio.gz"
|
||||
# Best-effort: the build IS the gate. Uploading the zImage/dtb to GitHub
|
||||
# artifact storage can fail on an account-wide storage-quota hit (recalculated
|
||||
# every 6-12h) that has nothing to do with this build. Don't red-X a good
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
+11
-2
@@ -54,7 +54,8 @@ screenshot from here is not evidence about a 5.10 panel's Wi-Fi page.
|
||||
WORK=$HOME/kbuild-out CROSS_COMPILE=arm-linux-gnueabihf- \
|
||||
WARDEN_KCONFIG_FRAGMENT=qemu/configs/virt.fragment bash build/build-kernel.sh
|
||||
|
||||
# 2. initramfs (sha256-pinned static busybox + qemu/rootfs/) and A/B disk
|
||||
# 2. initramfs (sha256-pinned static busybox + qemu/rootfs/) and A/B disk;
|
||||
# RIG_BUSYBOX=panel builds the image's own BusyBox instead (qemu/busybox/)
|
||||
bash qemu/mkinitramfs.sh
|
||||
bash qemu/mkimage.sh # options: --portal-url --state K=V --fw-version
|
||||
|
||||
@@ -81,7 +82,11 @@ With a test-flavor `warden-ui` and `wthctl` (flare-edge `tools/wthctl.c`, the
|
||||
test hook client) in the payload as well, a flow's `override` step pins a
|
||||
state document inside the UI: qmp.py hands the request to the control bridge
|
||||
(`@hookdoc` pieces, then `@hook override`), which sends it to `test/req/ui`
|
||||
as bus user `testhook` and answers the hook's reply.
|
||||
as bus user `testhook` and answers the hook's reply. The run's first hook
|
||||
request waits until the hook answers a `ping` (retried while the bridge
|
||||
reports no answer, up to `HOOK_READY_S`): right after boot the UI is still
|
||||
taking the broker's retained replay, and an override sent then was lost
|
||||
(flare-edge #2602).
|
||||
|
||||
The VT cursor is kept off (`vt.global_cursor_default=0`): fbcon shares the
|
||||
virtio-gpu framebuffer with warden-ui and its blinking cursor would otherwise
|
||||
@@ -136,8 +141,12 @@ All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
|
||||
| `rootfs-overlay.sh` | - | offline, no VM: `mkimage.sh`'s `ROOTFS_OVERLAY` hook lays a directory of panel files (flare-edge's S03warden-accounts, S99lvgl, warden-ui-run) over the rootfs of both slots with their modes kept, beside the skeleton's own files; without it there is no `/etc/init.d`; an overlay that is not a directory, names anything but `etc/` and `usr/` at its top, or holds a symlink fails closed and writes no image; `ui-drive.sh --init-chain` refuses a missing directory or one without `etc/init.d/S99lvgl` before boot |
|
||||
| `init-chain-test.sh` | - | offline, no VM: `warden_init_chain` (rootfs/etc/warden-lib.sh) starts the executable `S<NN>*` scripts of a number range in name order, names a failing one and goes on, and counts them; `warden_rig_bus_owners` hands a bus credential to its account only when the rootfs has it; sbin/init runs S00-S09 before the bus and S10-S99 instead of the direct UI start on a `warden.initchain` boot (flare-edge #2210) |
|
||||
| `run-sh-args-test.sh` | - | offline, no VM: a fake `qemu-system-arm` captures run.sh's own argv and pins the ctl/rs485 pci-serial ordering contract rootfs/sbin/init's ttyS0-vs-ttyS1 alias depends on -- the ctl device always enumerates before rs485, warden.ctl only lands on the cmdline when --ctl is given, and an rs485 pci-serial device (real or null-backed) is always present so the port count never shifts |
|
||||
| `busybox-panel-test.sh` | - | offline, no VM: the panel BusyBox inputs (qemu/busybox/). panel.config carries every setting of the image's applet patch, rig.fragment changes only STATIC, USE_BB_PWD_GRP and USE_BB_SHADOW, a Kconfig rewrite of any setting and an applet the panel lacks fail the build, applets.txt and help.txt agree, and RIG_BUSYBOX refuses an unknown value, and accepts a prebuilt panel `BUSYBOX` only when its `.inputs` match this tree (flare-edge#2210) |
|
||||
| `busybox-panel-help.sh [BIN]` | an ARM runner (binfmt or `QEMU_USER=qemu-arm`) | the built panel BusyBox against the bench capture: its applet list and every applet's `--help` equal the panel's own binary's. CI runs it in qemu-tools after `build-busybox.sh` |
|
||||
| `console-shell-test.sh` | - | offline, no VM: `warden_console_shell` (warden.shell) runs `setsid cttyhack sh` where cttyhack exists, else `setsid -c sh` on the console tty read from sysfs (the panel BusyBox has no cttyhack), else a plain sh. CI runs it under bash's `sh` and busybox `sh` |
|
||||
| `ctl-bridge-test.sh` | - | offline, no VM: runs the control bridge (`warden_ctl_bridge` in rootfs/etc/warden-lib.sh) against a fake warden-ui that answers some commands late. A reply slower than the old 5 s bound still arrives (the bound is now 30 s, `WARDEN_CTL_WAIT_S`), a timeout answers `bridge: no reply from warden-ui ...` (qmp.py raises it as a rig fault), and a timed-out command's late reply is drained instead of being read as the next command's answer (flare-edge #1448). A fake `wthctl` stands in for the hook client behind `@hookdoc`/`@hook` (flare-edge #2054): the pieces join into one request whose args are used once, only plain words reach the client, and a missing client or a request with no reply answers a `bridge:` line. CI runs it under bash's `sh` and busybox `sh` |
|
||||
| `init-rig-bus-test.sh` | - | offline, no VM: `warden_rig_bus` in rootfs/etc/warden-lib.sh against stub brokers. No broker in the payload creates nothing; a broker that listens gets the panel's layout (the `bus.sock` link, a 0400 64-hex credential per bus user, a config without password file, ACL or plugin); a broker that exits or never listens is reported within the bound; init starts the bus before the payload daemons. `WARDEN_TEST_MOSQUITTO_DIR` adds a real mosquitto carrying one message between two users logged in by credential file (flare-edge #1754) |
|
||||
| `agent-test.sh` | - | offline, no VM: the rig agent (`warden_agent` in rootfs/etc/warden-lib.sh, armed by `run.sh --agent` and `warden.agent`) answers `@run ID SECS B64` with `<<BEGIN ID>>`, the base64 of the script's output and `<<END ID RC>>`; `@chunk` pieces join into one script used once; a script past its deadline is killed with its process group and answers 124; a malformed request answers one `<<ERR ...>>` line and runs nothing; init puts the agent's port after ctl and RS485. It is the guest shell of flare-edge `tools/soak/rig-qemu.py` (M9 soak-lite). CI runs it under bash's `sh` and busybox `sh` |
|
||||
| watchdog (`run.sh --watchdog`) | - | arm `/dev/watchdog`, don't pet: the VM resets ~30 s later (verified) |
|
||||
|
||||
Scenario fine print:
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the rig's panel BusyBox: the image's BusyBox version with the image's
|
||||
# applet config, linked static for the rig's initramfs (flare-edge#2210).
|
||||
#
|
||||
# build-busybox.sh
|
||||
#
|
||||
# Env:
|
||||
# OUT output dir (default qemu/out); the binary lands at
|
||||
# $OUT/busybox-armv7l-panel, its rebuild key (.key) and its
|
||||
# source inputs (.inputs, see qemu_busybox_panel_inputs in
|
||||
# lib.sh) next to it
|
||||
# CROSS_COMPILE cross toolchain prefix (default arm-linux-gnueabihf-)
|
||||
# BB_SRC_TARBALL a local busybox-$BB_SRC_VER.tar.bz2 (skips the download;
|
||||
# still verified against BB_SRC_SHA256)
|
||||
# JOBS make -j (default: nproc, at most 4)
|
||||
#
|
||||
# The inputs are pinned, not the output: the source tarball by sha256 and the
|
||||
# configuration by the committed files in qemu/busybox/. Compilers differ
|
||||
# between hosts, so one host's binary hash means nothing on another; the
|
||||
# output is checked by its applet list instead (qemu/busybox/applets.txt, the
|
||||
# same list as flare-edge tests/fixtures/panel-busybox-applets.txt). A rebuild
|
||||
# is skipped when the input key (tarball, config files, compiler version)
|
||||
# matches the cached binary's.
|
||||
#
|
||||
# FAILS CLOSED: no cross compiler, a bad tarball, a configuration that the
|
||||
# BusyBox Kconfig rewrites (a symbol the version does not know), an applet
|
||||
# list that differs, or a dynamically linked result is an error, never a
|
||||
# fallback to the multiarch binary.
|
||||
set -euo pipefail
|
||||
|
||||
QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BB_DIR="$QEMU_DIR/busybox"
|
||||
|
||||
# The source pin (BB_SRC_VER, BB_SRC_URL, BB_SRC_SHA256) lives in lib.sh,
|
||||
# beside qemu_busybox_panel_inputs, which a prebuilt binary is checked by.
|
||||
# shellcheck source=qemu/lib.sh disable=SC1091
|
||||
. "$QEMU_DIR/lib.sh"
|
||||
|
||||
# Write the panel config with every fragment line applied: the symbol's old
|
||||
# setting (set or "is not set") is dropped and the fragment's line appended.
|
||||
# Usage: bb_apply_fragment PANEL_CONFIG FRAGMENT > .config
|
||||
bb_apply_fragment() {
|
||||
local panel="$1" frag="$2" line sym pat=""
|
||||
while IFS= read -r line; do
|
||||
case "$line" in ''|'#'*) continue ;; esac
|
||||
sym="${line%%=*}"
|
||||
case "$sym" in
|
||||
CONFIG_*) ;;
|
||||
*) echo "FATAL: bad fragment line: '$line'" >&2; return 1 ;;
|
||||
esac
|
||||
pat="${pat}|^${sym}=|^# ${sym} is not set\$"
|
||||
done < "$frag"
|
||||
if [ -n "$pat" ]; then
|
||||
grep -Ev "${pat#|}" "$panel" || true
|
||||
else
|
||||
cat "$panel"
|
||||
fi
|
||||
grep -Ev '^(#|$)' "$frag"
|
||||
}
|
||||
|
||||
# The settings of a config file, one per line, sorted: "SYM=value" for a set
|
||||
# symbol and "SYM is not set" for an unset one. Comments and the header are
|
||||
# dropped, so two configs compare by what they configure.
|
||||
bb_settings() {
|
||||
sed -n -e 's/^\(CONFIG_[A-Za-z0-9_]*=.*\)$/\1/p' \
|
||||
-e 's/^# \(CONFIG_[A-Za-z0-9_]*\) is not set$/\1 is not set/p' "$1" | LC_ALL=C sort
|
||||
}
|
||||
|
||||
# Fail when Kconfig changed any setting of the config it was given (WANT)
|
||||
# while writing GOT: a symbol this BusyBox version does not know, or one whose
|
||||
# dependencies are unmet, would otherwise be dropped without a word.
|
||||
bb_check_config() {
|
||||
local want="$1" got="$2" d
|
||||
if ! d="$(diff <(bb_settings "$want") <(bb_settings "$got"))"; then
|
||||
echo "FATAL: the BusyBox $BB_SRC_VER Kconfig rewrote the panel config (< given, > written):" >&2
|
||||
printf '%s\n' "$d" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Compare the applet names in a busybox.links file (one install path per line)
|
||||
# with the committed list. Usage: bb_check_applets LINKS APPLETS_TXT
|
||||
bb_check_applets() {
|
||||
local links="$1" want="$2" d
|
||||
if ! d="$(diff <(LC_ALL=C sort -u "$want") <(sed 's|.*/||' "$links" | LC_ALL=C sort -u))"; then
|
||||
echo "FATAL: the built BusyBox applet list differs from $want (< want, > built):" >&2
|
||||
printf '%s\n' "$d" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# The cache key: everything the binary is built from.
|
||||
bb_input_key() {
|
||||
local cc="$1"
|
||||
{
|
||||
qemu_busybox_panel_inputs
|
||||
echo "$cc"
|
||||
"${cc}gcc" --version | head -n 1
|
||||
} | sha256sum | awk '{print $1}'
|
||||
}
|
||||
|
||||
bb_main() {
|
||||
local out="${OUT:-$QEMU_DIR/out}" cc="${CROSS_COMPILE:-arm-linux-gnueabihf-}"
|
||||
local jobs="${JOBS:-}" bin key src scratch tar
|
||||
bin="$out/busybox-armv7l-panel"
|
||||
command -v "${cc}gcc" >/dev/null || {
|
||||
echo "FATAL: no ${cc}gcc on PATH (apt-get install gcc-arm-linux-gnueabihf, or set CROSS_COMPILE)" >&2
|
||||
exit 1
|
||||
}
|
||||
if [ -z "$jobs" ]; then
|
||||
jobs="$(nproc)"; [ "$jobs" -le 4 ] || jobs=4
|
||||
fi
|
||||
mkdir -p "$out"
|
||||
key="$(bb_input_key "$cc")"
|
||||
if [ -f "$bin" ] && [ "$(cat "$bin.key" 2>/dev/null)" = "$key" ]; then
|
||||
qemu_busybox_panel_inputs > "$bin.inputs"
|
||||
qemu_log "panel busybox up to date ($bin)"
|
||||
return
|
||||
fi
|
||||
# A stale .inputs must never vouch for a binary while it is rebuilt.
|
||||
rm -f "$bin.inputs"
|
||||
|
||||
tar="${BB_SRC_TARBALL:-$out/busybox-${BB_SRC_VER}.tar.bz2}"
|
||||
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source"
|
||||
|
||||
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
|
||||
# Expanded now on purpose: the trap must remove this run's directory.
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$scratch'" EXIT
|
||||
tar -xjf "$tar" -C "$scratch"
|
||||
src="$scratch/busybox-${BB_SRC_VER}"
|
||||
[ -d "$src" ] || { echo "FATAL: $tar has no busybox-${BB_SRC_VER}/" >&2; exit 1; }
|
||||
# Buildroot's patches for this version, as the image applies them.
|
||||
local p
|
||||
for p in "$BB_DIR"/patches/*.patch; do
|
||||
patch -d "$src" -p1 -s --no-backup-if-mismatch < "$p" || {
|
||||
echo "FATAL: $p does not apply to busybox $BB_SRC_VER" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
bb_apply_fragment "$BB_DIR/panel.config" "$BB_DIR/rig.fragment" > "$scratch/want.config"
|
||||
cp "$scratch/want.config" "$src/.config"
|
||||
# Fixed time stamps so two builds with one compiler give one binary.
|
||||
export SOURCE_DATE_EPOCH=0 KCONFIG_NOTIMESTAMP=1 KBUILD_BUILD_TIMESTAMP="1970-01-01"
|
||||
export KBUILD_BUILD_USER=warden KBUILD_BUILD_HOST=rig
|
||||
# oldconfig with no terminal: a symbol missing from the config would stop
|
||||
# at a prompt and read EOF; the settings check below names it either way.
|
||||
make -C "$src" -s CROSS_COMPILE="$cc" oldconfig </dev/null >"$scratch/oldconfig.log" 2>&1 || {
|
||||
cat "$scratch/oldconfig.log" >&2
|
||||
echo "FATAL: make oldconfig failed" >&2
|
||||
exit 1
|
||||
}
|
||||
bb_check_config "$scratch/want.config" "$src/.config"
|
||||
qemu_log "building busybox $BB_SRC_VER (panel config, static, ${cc}gcc, -j$jobs)"
|
||||
make -C "$src" -s -j"$jobs" CROSS_COMPILE="$cc" busybox busybox.links >"$scratch/make.log" 2>&1 || {
|
||||
tail -n 40 "$scratch/make.log" >&2
|
||||
echo "FATAL: busybox build failed" >&2
|
||||
exit 1
|
||||
}
|
||||
bb_check_applets "$src/busybox.links" "$BB_DIR/applets.txt"
|
||||
if "${cc}readelf" -l "$src/busybox" | grep -q 'INTERP'; then
|
||||
echo "FATAL: the built busybox is dynamically linked (CONFIG_STATIC not applied)" >&2
|
||||
exit 1
|
||||
fi
|
||||
"${cc}readelf" -h "$src/busybox" | grep -q 'Machine:.*ARM' || {
|
||||
echo "FATAL: the built busybox is not an ARM binary" >&2
|
||||
exit 1
|
||||
}
|
||||
install -m 0755 "$src/busybox" "$bin.tmp"
|
||||
mv -f "$bin.tmp" "$bin"
|
||||
printf '%s\n' "$key" > "$bin.key"
|
||||
# For a job without the cross compiler: qemu_get_busybox accepts this
|
||||
# binary as BUSYBOX under RIG_BUSYBOX=panel when the inputs match its tree.
|
||||
qemu_busybox_panel_inputs > "$bin.inputs"
|
||||
qemu_log "panel busybox: $bin ($(sha256sum "$bin" | awk '{print $1}'))"
|
||||
}
|
||||
|
||||
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
||||
bb_main "$@"
|
||||
fi
|
||||
@@ -0,0 +1,36 @@
|
||||
# The panel's BusyBox, for the rig
|
||||
|
||||
`RIG_BUSYBOX=panel` (qemu/lib.sh) makes the rig run the image's own BusyBox
|
||||
instead of the busybox.net 1.31.0 multiarch binary, so a script that calls an
|
||||
applet or option the panel lacks fails in the rig as it fails on a panel
|
||||
(flare-edge#2210; #1903 `setpriv --reuid`, #2002 `stat`, #1349 `flock -w`).
|
||||
`qemu/build-busybox.sh` builds it; the default stays `multiarch` until the
|
||||
flare-edge QEMU jobs switch over.
|
||||
|
||||
| File | What it is |
|
||||
|---|---|
|
||||
| `panel.config` | The image's BusyBox 1.37.0 configuration. Made from Buildroot 2025.02.8 `package/busybox/busybox.config` (the vendor SDK's base; its header matches the `a/` side of the applet patch), with `luckfox-sdk-patches/buildroot/patches/0001-busybox-applets.patch` applied and then `yes "" \| make oldconfig` in busybox-1.37.0, as Buildroot does for a config written for an older version (it adds TIME64, GETFATTR, FIND_EXEC_OK, IP_LINK_CAN and UDHCPD_BOOTP at their defaults and drops ASH_SLEEP). The time stamp line is dropped. |
|
||||
| `rig.fragment` | The rig's only differences: a static link, and BusyBox's own passwd, group and shadow readers (a static glibc binary cannot load NSS modules). Neither adds or removes an applet or option. |
|
||||
| `patches/` | Buildroot 2025.02.8's `package/busybox/*.patch`, applied in order like the image build does (one of them is what makes `tc` build with current kernel headers). Commit-message text was changed to ASCII; the diffs are unchanged. |
|
||||
| `applets.txt` | `busybox --list` of the panel (bench a, image 417a66b), the same as flare-edge `tests/fixtures/panel-busybox-applets.txt`. The build fails when its applet list differs. |
|
||||
| `help.txt` | `busybox <applet> --help` of every applet of the panel, the same as flare-edge `tests/fixtures/panel-busybox-help.txt` (flare-edge `tools/bench/busybox-help/capture.sh`). `qemu/tests/busybox-panel-help.sh` compares the built binary with it. |
|
||||
|
||||
The Buildroot fixups in `busybox.mk` that depend on the image's Buildroot
|
||||
options (mdev, init, watchdog, less flags, crypt SHA) are not applied here;
|
||||
the applet list and the per-applet help check would show any of them that
|
||||
changed an applet or an option. When the image's BusyBox changes, update
|
||||
`panel.config` and `patches/` the same way and re-capture `applets.txt` and
|
||||
`help.txt` from a panel.
|
||||
|
||||
The inputs are pinned (source tarball sha256, these files); the output is not,
|
||||
because each host's compiler gives a different binary. The cache key in
|
||||
`$OUT/busybox-armv7l-panel.key` covers the tarball, these files and the
|
||||
compiler version.
|
||||
|
||||
A job without the cross compiler (a flare-edge flow job, given the binary its
|
||||
image build job made) sets `RIG_BUSYBOX=panel BUSYBOX=<binary>`. The build
|
||||
writes `<binary>.inputs` next to it: one sha256 over the source pin and these
|
||||
files, without the compiler (`qemu_busybox_panel_inputs` in qemu/lib.sh).
|
||||
`qemu_get_busybox` takes the prebuilt binary only when that file equals the
|
||||
value for its own tree, so a binary built from another config is refused
|
||||
rather than booted.
|
||||
@@ -0,0 +1,282 @@
|
||||
[
|
||||
[[
|
||||
addgroup
|
||||
adduser
|
||||
ar
|
||||
arch
|
||||
arp
|
||||
arping
|
||||
ascii
|
||||
ash
|
||||
awk
|
||||
base32
|
||||
base64
|
||||
basename
|
||||
bc
|
||||
blkid
|
||||
bunzip2
|
||||
bzcat
|
||||
cat
|
||||
chattr
|
||||
chgrp
|
||||
chmod
|
||||
chown
|
||||
chroot
|
||||
chrt
|
||||
chvt
|
||||
cksum
|
||||
clear
|
||||
cmp
|
||||
cp
|
||||
cpio
|
||||
crc32
|
||||
crond
|
||||
crontab
|
||||
cut
|
||||
date
|
||||
dc
|
||||
dd
|
||||
deallocvt
|
||||
delgroup
|
||||
deluser
|
||||
devmem
|
||||
df
|
||||
diff
|
||||
dirname
|
||||
dmesg
|
||||
dnsd
|
||||
dnsdomainname
|
||||
dos2unix
|
||||
du
|
||||
dumpkmap
|
||||
echo
|
||||
egrep
|
||||
eject
|
||||
env
|
||||
ether-wake
|
||||
expr
|
||||
factor
|
||||
fallocate
|
||||
false
|
||||
fbset
|
||||
fdflush
|
||||
fdformat
|
||||
fdisk
|
||||
fgrep
|
||||
find
|
||||
flock
|
||||
fold
|
||||
free
|
||||
freeramdisk
|
||||
fsck
|
||||
fsfreeze
|
||||
fstrim
|
||||
fuser
|
||||
getfattr
|
||||
getopt
|
||||
getty
|
||||
grep
|
||||
gunzip
|
||||
gzip
|
||||
halt
|
||||
hdparm
|
||||
head
|
||||
hexdump
|
||||
hexedit
|
||||
hostid
|
||||
hostname
|
||||
hwclock
|
||||
i2cdetect
|
||||
i2cdump
|
||||
i2cget
|
||||
i2cset
|
||||
i2ctransfer
|
||||
id
|
||||
ifconfig
|
||||
ifdown
|
||||
ifup
|
||||
inetd
|
||||
init
|
||||
insmod
|
||||
install
|
||||
ip
|
||||
ipaddr
|
||||
ipcrm
|
||||
ipcs
|
||||
iplink
|
||||
ipneigh
|
||||
iproute
|
||||
iprule
|
||||
iptunnel
|
||||
kill
|
||||
killall
|
||||
killall5
|
||||
klogd
|
||||
last
|
||||
less
|
||||
link
|
||||
linux32
|
||||
linux64
|
||||
linuxrc
|
||||
ln
|
||||
loadfont
|
||||
loadkmap
|
||||
logger
|
||||
login
|
||||
logname
|
||||
losetup
|
||||
ls
|
||||
lsattr
|
||||
lsmod
|
||||
lsof
|
||||
lspci
|
||||
lsscsi
|
||||
lsusb
|
||||
lzcat
|
||||
lzma
|
||||
lzopcat
|
||||
makedevs
|
||||
md5sum
|
||||
mdev
|
||||
mesg
|
||||
microcom
|
||||
mim
|
||||
mkdir
|
||||
mkdosfs
|
||||
mke2fs
|
||||
mkfifo
|
||||
mknod
|
||||
mkpasswd
|
||||
mkswap
|
||||
mktemp
|
||||
modprobe
|
||||
more
|
||||
mount
|
||||
mountpoint
|
||||
mt
|
||||
mv
|
||||
nameif
|
||||
netstat
|
||||
nice
|
||||
nl
|
||||
nohup
|
||||
nologin
|
||||
nproc
|
||||
nslookup
|
||||
nuke
|
||||
od
|
||||
openvt
|
||||
partprobe
|
||||
passwd
|
||||
paste
|
||||
patch
|
||||
pidof
|
||||
ping
|
||||
pipe_progress
|
||||
pivot_root
|
||||
poweroff
|
||||
printenv
|
||||
printf
|
||||
ps
|
||||
pwd
|
||||
rdate
|
||||
readlink
|
||||
readprofile
|
||||
realpath
|
||||
reboot
|
||||
renice
|
||||
reset
|
||||
resize
|
||||
resume
|
||||
rfkill
|
||||
rm
|
||||
rmdir
|
||||
rmmod
|
||||
route
|
||||
run-init
|
||||
run-parts
|
||||
runlevel
|
||||
sed
|
||||
seedrng
|
||||
seq
|
||||
setarch
|
||||
setconsole
|
||||
setfattr
|
||||
setkeycodes
|
||||
setlogcons
|
||||
setpriv
|
||||
setserial
|
||||
setsid
|
||||
sh
|
||||
sha1sum
|
||||
sha256sum
|
||||
sha3sum
|
||||
sha512sum
|
||||
shred
|
||||
sleep
|
||||
sort
|
||||
start-stop-daemon
|
||||
strings
|
||||
stty
|
||||
su
|
||||
sulogin
|
||||
svc
|
||||
svok
|
||||
swapoff
|
||||
swapon
|
||||
switch_root
|
||||
sync
|
||||
sysctl
|
||||
syslogd
|
||||
tail
|
||||
tar
|
||||
tc
|
||||
tee
|
||||
telnet
|
||||
telnetd
|
||||
test
|
||||
tftp
|
||||
time
|
||||
top
|
||||
touch
|
||||
tr
|
||||
traceroute
|
||||
tree
|
||||
true
|
||||
truncate
|
||||
ts
|
||||
tsort
|
||||
tty
|
||||
ubirename
|
||||
udhcpc
|
||||
uevent
|
||||
umount
|
||||
uname
|
||||
uniq
|
||||
unix2dos
|
||||
unlink
|
||||
unlzma
|
||||
unlzop
|
||||
unxz
|
||||
unzip
|
||||
uptime
|
||||
usleep
|
||||
uudecode
|
||||
uuencode
|
||||
vconfig
|
||||
vi
|
||||
vlock
|
||||
w
|
||||
watch
|
||||
watchdog
|
||||
wc
|
||||
wget
|
||||
which
|
||||
who
|
||||
whoami
|
||||
xargs
|
||||
xxd
|
||||
xz
|
||||
xzcat
|
||||
yes
|
||||
zcat
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
From e1690453cd84c798ca88cc4370710f65da86d986 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
Date: Sat, 5 Oct 2013 15:55:06 +0200
|
||||
Subject: [PATCH] networking/libiproute: use <linux/if_packet.h> instead of
|
||||
<net/if_packet.h>
|
||||
|
||||
The musl C library doesn't provide the <net/if_packet.h> since the
|
||||
corresponding kernel headers <linux/if_packet.h> already provides the
|
||||
necessary definitions. Replacing <net/if_packet.h> by
|
||||
<linux/if_packet.h> also removes the need to include
|
||||
<netpacket/packet.h>
|
||||
|
||||
This commit fixes the build of iplink with the musl C library.
|
||||
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
[Gustavo: update for busybox 1.22.0]
|
||||
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
|
||||
---
|
||||
networking/libiproute/iplink.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
|
||||
index 37ed114bc..bc526d89c 100644
|
||||
--- a/networking/libiproute/iplink.c
|
||||
+++ b/networking/libiproute/iplink.c
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
#include <net/if.h>
|
||||
/*#include <net/if_packet.h> - not needed? */
|
||||
-#include <netpacket/packet.h>
|
||||
+#include <linux/if_packet.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
||||
#include <linux/if_vlan.h>
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From df20ae1280a2601a4c233ec12372d1e17db21e96 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
Date: Mon, 25 Nov 2013 22:51:53 +0100
|
||||
Subject: [PATCH] Makefile.flags: strip non -l arguments returned by pkg-config
|
||||
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
[yann.morin.1998@free.fr: refresh for 1.29.0]
|
||||
[petr.vorel@gmail.com: refresh for 1.32.0]
|
||||
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
|
||||
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
|
||||
---
|
||||
Makefile.flags | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile.flags b/Makefile.flags
|
||||
index 97cb4dca2..92a9063d9 100644
|
||||
--- a/Makefile.flags
|
||||
+++ b/Makefile.flags
|
||||
@@ -181,7 +181,9 @@ ifeq ($(CONFIG_SELINUX),y)
|
||||
SELINUX_PC_MODULES = libselinux libsepol
|
||||
$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
|
||||
CPPFLAGS += $(SELINUX_CFLAGS)
|
||||
-LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
|
||||
+LDLIBS += $(if $(SELINUX_LIBS),\
|
||||
+ $(patsubst -l%,%,$(filter -l%,$(SELINUX_LIBS))),\
|
||||
+ $(SELINUX_PC_MODULES:lib%=%))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y)
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
From 68eaf20d86d4fe0f16a914817217f386155157cc Mon Sep 17 00:00:00 2001
|
||||
From: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Date: Mon, 19 Sep 2022 14:15:12 +0200
|
||||
Subject: [PATCH] libbb: sockaddr2str: ensure only printable characters are
|
||||
returned for the hostname part
|
||||
|
||||
CVE: CVE-2022-28391
|
||||
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Tested-by: Radoslav Kolev <radoslav.kolev@suse.com>
|
||||
Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089796.html
|
||||
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
|
||||
---
|
||||
libbb/xconnect.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
|
||||
index 0e0b247b8..02c061e67 100644
|
||||
--- a/libbb/xconnect.c
|
||||
+++ b/libbb/xconnect.c
|
||||
@@ -497,8 +497,9 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
|
||||
);
|
||||
if (rc)
|
||||
return NULL;
|
||||
+ /* ensure host contains only printable characters */
|
||||
if (flags & IGNORE_PORT)
|
||||
- return xstrdup(host);
|
||||
+ return xstrdup(printable_string(host));
|
||||
#if ENABLE_FEATURE_IPV6
|
||||
if (sa->sa_family == AF_INET6) {
|
||||
if (strchr(host, ':')) /* heh, it's not a resolved hostname */
|
||||
@@ -509,7 +510,7 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
|
||||
#endif
|
||||
/* For now we don't support anything else, so it has to be INET */
|
||||
/*if (sa->sa_family == AF_INET)*/
|
||||
- return xasprintf("%s:%s", host, serv);
|
||||
+ return xasprintf("%s:%s", printable_string(host), serv);
|
||||
/*return xstrdup(host);*/
|
||||
}
|
||||
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
From 56b84c6efb9a06ae294eb92cf9634f70af443b0a Mon Sep 17 00:00:00 2001
|
||||
From: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Date: Mon, 19 Sep 2022 14:15:12 +0200
|
||||
Subject: [PATCH] nslookup: sanitize all printed strings with printable_string
|
||||
|
||||
Otherwise, terminal sequences can be injected, which enables various terminal injection
|
||||
attacks from DNS results.
|
||||
|
||||
CVE: CVE-2022-28391
|
||||
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Tested-by: Radoslav Kolev <radoslav.kolev@suse.com>
|
||||
Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089795.html
|
||||
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
|
||||
---
|
||||
networking/nslookup.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/networking/nslookup.c b/networking/nslookup.c
|
||||
index b67d354f7..79412477c 100644
|
||||
--- a/networking/nslookup.c
|
||||
+++ b/networking/nslookup.c
|
||||
@@ -784,7 +784,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
//printf("Unable to uncompress domain: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
- printf(format, ns_rr_name(rr), dname);
|
||||
+ printf(format, ns_rr_name(rr), printable_string(dname));
|
||||
break;
|
||||
|
||||
case ns_t_mx:
|
||||
@@ -799,7 +799,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
//printf("Cannot uncompress MX domain: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
- printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, dname);
|
||||
+ printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, printable_string(dname));
|
||||
break;
|
||||
|
||||
case ns_t_txt:
|
||||
@@ -811,7 +811,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
if (n > 0) {
|
||||
memset(dname, 0, sizeof(dname));
|
||||
memcpy(dname, ns_rr_rdata(rr) + 1, n);
|
||||
- printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), dname);
|
||||
+ printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), printable_string(dname));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -831,7 +831,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
}
|
||||
|
||||
printf("%s\tservice = %u %u %u %s\n", ns_rr_name(rr),
|
||||
- ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), dname);
|
||||
+ ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), printable_string(dname));
|
||||
break;
|
||||
|
||||
case ns_t_soa:
|
||||
@@ -860,7 +860,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- printf("\tmail addr = %s\n", dname);
|
||||
+ printf("\tmail addr = %s\n", printable_string(dname));
|
||||
cp += n;
|
||||
|
||||
printf("\tserial = %lu\n", ns_get32(cp));
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
From 9fed109be1f811069cb2f727e04c6996cd44b017 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= <raphael.melotte@mind.be>
|
||||
Date: Tue, 18 Apr 2023 15:54:43 +0200
|
||||
Subject: [PATCH] seedrng: fix getrandom() detection for non-glibc libc
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
glibc <= 2.24 does not provide getrandom(). A check for it has been
|
||||
added in 200a9669fbf6f06894e4243cccc9fc11a1a6073a and fixed in
|
||||
cb57abb46f06f4ede8d9ccbdaac67377fdf416cf.
|
||||
|
||||
However, building with a libc other than glibc can lead to the same
|
||||
problem as not every other libc has getrandom() either:
|
||||
|
||||
- uClibc provides it from v1.0.2 onwards, but requires to define
|
||||
_GNU_SOURCE (all versions - we already define it by default), and
|
||||
stddef to be included first (when using uClibc < 1.0.35 - we already
|
||||
include it through libbb.h).
|
||||
|
||||
- musl libc has getrandom(), but only from version 1.1.20 onwards. As
|
||||
musl does not provide __MUSL__ or version information, it's not
|
||||
possible to check for it like we did for glibc.
|
||||
|
||||
All of this makes it difficult (or impossible in case of musl) to
|
||||
check what we need to do to have getrandom() based on each libc
|
||||
versions.
|
||||
|
||||
On top of that, getrandom() is also not available on older kernels. As
|
||||
an example, when using a 3.10 kernel with uClibc 1.0.26, getrandom()
|
||||
is declared so compiling works, but it fails at link time because
|
||||
getrandom() is not defined.
|
||||
|
||||
To make it easier, take a similar approach to what was done for the
|
||||
crypt library: try to build a sample program to see if we have
|
||||
getrandom(). To keep it compatible with different versions of
|
||||
make (for reference see [1]), a variable for '#' is also introduced.
|
||||
|
||||
Based on the new Makefile variable, we now either use the
|
||||
libc-provided getrandom() when it's available, or use our own
|
||||
implementation when it's not (like it was the case already for glibc <
|
||||
2.25).
|
||||
|
||||
This should fix compiling with many libc/kernel combinations.
|
||||
|
||||
[1]: https://git.savannah.gnu.org/cgit/make.git/commit/?id=c6966b323811c37acedff05b576b907b06aea5f4
|
||||
|
||||
Signed-off-by: Raphael Melotte <raphael.melotte@mind.be>
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2023-May/090317.html
|
||||
---
|
||||
Makefile.flags | 12 ++++++++++++
|
||||
miscutils/seedrng.c | 8 ++++----
|
||||
2 files changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Makefile.flags b/Makefile.flags
|
||||
index 92a9063d9..c8f601308 100644
|
||||
--- a/Makefile.flags
|
||||
+++ b/Makefile.flags
|
||||
@@ -162,6 +162,18 @@ ifeq ($(RT_AVAILABLE),y)
|
||||
LDLIBS += rt
|
||||
endif
|
||||
|
||||
+# GNU Make version 4.2.1 and earlier require number signs ('#')
|
||||
+# inside function invocations to be escaped, while versions 4.3+
|
||||
+# require them to be unescaped. Use a variable for it so that it works
|
||||
+# for both versions:
|
||||
+C := \#
|
||||
+# Not all libc versions have getrandom, so check for it:
|
||||
+HAVE_GETRANDOM := $(shell printf '$Cdefine _GNU_SOURCE\n$Cinclude <stddef.h>\n$Cinclude <sys/random.h>\nint main(void){char buf[256];\ngetrandom(buf,sizeof(buf),0);}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c)
|
||||
+
|
||||
+ifeq ($(HAVE_GETRANDOM),y)
|
||||
+CFLAGS += -DHAVE_GETRANDOM
|
||||
+endif
|
||||
+
|
||||
# libpam may use libpthread, libdl and/or libaudit.
|
||||
# On some platforms that requires an explicit -lpthread, -ldl, -laudit.
|
||||
# However, on *other platforms* it fails when some of those flags
|
||||
diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
|
||||
index 7a2331cb1..ba98f4d19 100644
|
||||
--- a/miscutils/seedrng.c
|
||||
+++ b/miscutils/seedrng.c
|
||||
@@ -44,8 +44,10 @@
|
||||
#include <linux/random.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
-/* Fix up glibc <= 2.24 not having getrandom() */
|
||||
-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24
|
||||
+/* Fix up some libc (e.g. glibc <= 2.24) not having getrandom() */
|
||||
+#if defined HAVE_GETRANDOM
|
||||
+#include <sys/random.h>
|
||||
+#else /* No getrandom */
|
||||
#include <sys/syscall.h>
|
||||
static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
|
||||
{
|
||||
@@ -56,8 +58,6 @@ static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
|
||||
return -1;
|
||||
# endif
|
||||
}
|
||||
-#else
|
||||
-#include <sys/random.h>
|
||||
#endif
|
||||
|
||||
/* Apparently some headers don't ship with this yet. */
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
From 7f0bb7f69f38298971aa8153d3fbe9b1fdda8ae7 Mon Sep 17 00:00:00 2001
|
||||
From: ctxnop <ctxnop@gmail.com>
|
||||
Date: Sun, 26 Jan 2025 20:59:20 +0100
|
||||
Subject: [PATCH] menuconfig: GCC failing saying ncurses is not found
|
||||
|
||||
Newer GCC increased diagnostics levels resulting in considering the
|
||||
test code to be invalid. The resulting message was misleading, saying
|
||||
that ncurses was not found, while the check failed for an unrelated
|
||||
reason which was hidden because GCC stderr was redirected to
|
||||
/dev/null.
|
||||
|
||||
Signed-off-by: ctxnop <ctxnop@gmail.com>
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2024-July/090840.html
|
||||
[Fiona: rephrased commit message for clarity]
|
||||
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
|
||||
---
|
||||
scripts/kconfig/lxdialog/check-lxdialog.sh | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
|
||||
index 5075ebf2d..08e4da3de 100755
|
||||
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
|
||||
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
|
||||
@@ -45,9 +45,9 @@ trap "rm -f $tmp" 0 1 2 3 15
|
||||
|
||||
# Check if we can link to ncurses
|
||||
check() {
|
||||
- $cc -x c - -o $tmp 2>/dev/null <<'EOF'
|
||||
+ $cc -x c - -o $tmp <<'EOF'
|
||||
#include CURSES_LOC
|
||||
-main() {}
|
||||
+int main() { return 0; }
|
||||
EOF
|
||||
if [ $? != 0 ]; then
|
||||
echo " *** Unable to find the ncurses libraries or the" 1>&2
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
From 1dbb3073a3a8856b9446b882f797be1bb2e21a26 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
|
||||
Date: Mon, 23 Sep 2024 18:56:00 +0200
|
||||
Subject: [PATCH] tc: Fix compilation with Linux v6.8-rc1
|
||||
|
||||
Linux v6.8-rc1 removed the definitions related to CBQ:
|
||||
https://github.com/torvalds/linux/commit/33241dca486264193ed68167c8eeae1fb197f3df
|
||||
making tc fail to build.
|
||||
Add some #ifdefs to handle this missing support.
|
||||
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2024-March/090678.html
|
||||
Bug report: https://bugs.busybox.net/show_bug.cgi?id=15931
|
||||
|
||||
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
|
||||
---
|
||||
networking/tc.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/networking/tc.c b/networking/tc.c
|
||||
index 3a79fd2d9..d08fd1359 100644
|
||||
--- a/networking/tc.c
|
||||
+++ b/networking/tc.c
|
||||
@@ -231,6 +231,13 @@ static int cbq_parse_opt(int argc, char **argv, struct nlmsghdr *n)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+#ifndef TCA_CBQ_MAX
|
||||
+/*
|
||||
+ * Linux v6.8-rc1~131^2~60^2^2 removed the uapi definitions for CBQ.
|
||||
+ * See https://git.kernel.org/linus/33241dca48626
|
||||
+ */
|
||||
+#else
|
||||
static int cbq_print_opt(struct rtattr *opt)
|
||||
{
|
||||
struct rtattr *tb[TCA_CBQ_MAX+1];
|
||||
@@ -322,6 +329,7 @@ static int cbq_print_opt(struct rtattr *opt)
|
||||
done:
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static FAST_FUNC int print_qdisc(
|
||||
const struct sockaddr_nl *who UNUSED_PARAM,
|
||||
@@ -372,8 +380,10 @@ static FAST_FUNC int print_qdisc(
|
||||
int qqq = index_in_strings(_q_, name);
|
||||
if (qqq == 0) { /* pfifo_fast aka prio */
|
||||
prio_print_opt(tb[TCA_OPTIONS]);
|
||||
+#ifdef TCA_CBQ_MAX
|
||||
} else if (qqq == 1) { /* class based queuing */
|
||||
cbq_print_opt(tb[TCA_OPTIONS]);
|
||||
+#endif
|
||||
} else {
|
||||
/* don't know how to print options for this qdisc */
|
||||
printf("(options for %s)", name);
|
||||
@@ -442,9 +452,11 @@ static FAST_FUNC int print_class(
|
||||
int qqq = index_in_strings(_q_, name);
|
||||
if (qqq == 0) { /* pfifo_fast aka prio */
|
||||
/* nothing. */ /*prio_print_opt(tb[TCA_OPTIONS]);*/
|
||||
+#ifdef TCA_CBQ_MAX
|
||||
} else if (qqq == 1) { /* class based queuing */
|
||||
/* cbq_print_copt() is identical to cbq_print_opt(). */
|
||||
cbq_print_opt(tb[TCA_OPTIONS]);
|
||||
+#endif
|
||||
} else {
|
||||
/* don't know how to print options for this class */
|
||||
printf("(options for %s)", name);
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From 88f8a046f27cb81ccc30d038465e963b8300cf1b Mon Sep 17 00:00:00 2001
|
||||
From: Valery Ushakov <uwe@stderr.spb.ru>
|
||||
Date: Wed, 24 Jan 2024 22:24:41 +0300
|
||||
Subject: [PATCH] awk.c: fix CVE-2023-42366 (bug #15874)
|
||||
|
||||
Make sure we don't read past the end of the string in next_token()
|
||||
when backslash is the last character in an (invalid) regexp.
|
||||
a fix and issue reported in bugzilla
|
||||
|
||||
https://bugs.busybox.net/show_bug.cgi?id=15874
|
||||
|
||||
Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2024-May/090766.html]
|
||||
|
||||
CVE: CVE-2023-42366
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
[Thomas: https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/busybox/busybox/0001-awk.c-fix-CVE-2023-42366-bug-15874.patch?id=e0ff4813b1cf4df0d851c857d57fb88d7db51bdd]
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2024-May/090766.html
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||||
---
|
||||
editors/awk.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/editors/awk.c b/editors/awk.c
|
||||
index 64e752f4b..222e6298d 100644
|
||||
--- a/editors/awk.c
|
||||
+++ b/editors/awk.c
|
||||
@@ -1234,9 +1234,11 @@ static uint32_t next_token(uint32_t expected)
|
||||
s[-1] = bb_process_escape_sequence((const char **)&pp);
|
||||
if (*p == '\\')
|
||||
*s++ = '\\';
|
||||
- if (pp == p)
|
||||
+ if (pp == p) {
|
||||
+ if (*p == '\0')
|
||||
+ syntax_error(EMSG_UNEXP_EOS);
|
||||
*s++ = *p++;
|
||||
- else
|
||||
+ } else
|
||||
p = pp;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From 0583f8eda94f97e15e371e12458877b738439e8c Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Sun, 7 Mar 2021 17:30:24 -0800
|
||||
Subject: [PATCH] hwclock: Check for SYS_settimeofday before calling syscall
|
||||
|
||||
Some newer architectures e.g. RISCV32 have 64bit time_t from get go and
|
||||
thusly do not have gettimeofday_time64/settimeofday_time64 implemented
|
||||
therefore check for SYS_settimeofday definition before making the
|
||||
syscall. Fixes build for riscv32 and it will bail out at runtime.
|
||||
|
||||
Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2021-March/088583.html]
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2021-March/088583.html
|
||||
[Thomas: this issue has been discussed on the musl mailing list, and
|
||||
the musl developers' opinion is that Busybox is wrong:
|
||||
https://www.openwall.com/lists/musl/2024/03/03/2
|
||||
https://www.openwall.com/lists/musl/2024/04/07/2. The correct fix
|
||||
isn't clear, and in the mean time, the patch from Khem turns the build
|
||||
issue into a runtime error only on the problematic architecture, which
|
||||
seems like a reasonable trade-off]
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||||
---
|
||||
util-linux/hwclock.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
|
||||
index c3fd0eb57..dea9c9a55 100644
|
||||
--- a/util-linux/hwclock.c
|
||||
+++ b/util-linux/hwclock.c
|
||||
@@ -132,6 +132,7 @@ static void show_clock(const char **pp_rtcname, int utc)
|
||||
|
||||
static void set_kernel_tz(const struct timezone *tz)
|
||||
{
|
||||
+ int ret = 1;
|
||||
#if LIBC_IS_MUSL
|
||||
/* musl libc does not pass tz argument to syscall
|
||||
* because "it's deprecated by POSIX, therefore it's fine
|
||||
@@ -140,9 +141,11 @@ static void set_kernel_tz(const struct timezone *tz)
|
||||
#if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32)
|
||||
# define SYS_settimeofday SYS_settimeofday_time32
|
||||
#endif
|
||||
- int ret = syscall(SYS_settimeofday, NULL, tz);
|
||||
+#if defined(SYS_settimeofday)
|
||||
+ ret = syscall(SYS_settimeofday, NULL, tz);
|
||||
+#endif
|
||||
#else
|
||||
- int ret = settimeofday(NULL, tz);
|
||||
+ ret = settimeofday(NULL, tz);
|
||||
#endif
|
||||
if (ret)
|
||||
bb_simple_perror_msg_and_die("settimeofday");
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From bba9e99026a3dafe75f608459533e0b6d8cf3874 Mon Sep 17 00:00:00 2001
|
||||
From: Andre Przywara <andre.przywara@arm.com>
|
||||
Date: Tue, 10 Sep 2024 14:32:46 +0100
|
||||
Subject: [PATCH] libbb/sha: add missing sha-NI guard
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The ENABLE_SHA1_HWACCEL Kconfig symbol is meant to be archicture
|
||||
agnostic, so can be enabled regardless of whether your build
|
||||
architecture provides hardware acceleration or not. At the moment only
|
||||
x86 implements this, so every piece of optimised code should be guarded
|
||||
by both ENABLE_SHA1_HWACCEL and (__x86_64__ || __i386__). This is missing
|
||||
at one place, so compiling for arm64 breaks when ENABLE_SHA1_HWACCEL is
|
||||
enabled:
|
||||
================================
|
||||
libbb/hash_md5_sha.c: In function 'sha1_end':
|
||||
libbb/hash_md5_sha.c:1316:28: error: 'sha1_process_block64_shaNI' undeclared (first use in this function); did you mean 'sha1_process_block64'?
|
||||
1316 | || ctx->process_block == sha1_process_block64_shaNI
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
| sha1_process_block64
|
||||
libbb/hash_md5_sha.c:1316:28: note: each undeclared identifier is reported only once for each function it appears in
|
||||
make[1]: *** [scripts/Makefile.build:197: libbb/hash_md5_sha.o] Error 1
|
||||
make: *** [Makefile:744: libbb] Error 2
|
||||
================================
|
||||
|
||||
Add the missing guards around the call to sha1_process_block64_shaNI to
|
||||
fix the build on other architectures with ENABLE_SHA1_HWACCEL enabled.
|
||||
|
||||
Change-Id: I40bba388422625f4230abf15a5de23e1fdc654fc
|
||||
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
|
||||
Upstream: https://lists.busybox.net/pipermail/busybox/2024-September/090899.html
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||||
---
|
||||
libbb/hash_md5_sha.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
|
||||
index 57a801459..75a61c32c 100644
|
||||
--- a/libbb/hash_md5_sha.c
|
||||
+++ b/libbb/hash_md5_sha.c
|
||||
@@ -1313,7 +1313,9 @@ unsigned FAST_FUNC sha1_end(sha1_ctx_t *ctx, void *resbuf)
|
||||
hash_size = 8;
|
||||
if (ctx->process_block == sha1_process_block64
|
||||
#if ENABLE_SHA1_HWACCEL
|
||||
+# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
|| ctx->process_block == sha1_process_block64_shaNI
|
||||
+# endif
|
||||
#endif
|
||||
) {
|
||||
hash_size = 5;
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From 34d331d642c3312e1c04e4650f547f1a67abee24 Mon Sep 17 00:00:00 2001
|
||||
From: Andrej Valek <andrej.v@skyrain.eu>
|
||||
Date: Wed, 16 Oct 2024 10:15:08 +0200
|
||||
Subject: [PATCH] syslogd: fix wrong OPT_locallog flag detection
|
||||
|
||||
The OPT_locallog was set on "option_mask32" but checked on local
|
||||
"opts" variable. While this flag it's used on multiple places can't be
|
||||
has to be used with "option_mask32". Without this change syslogd
|
||||
is more-less unusable while no messages are logged locally.
|
||||
|
||||
Signed-off-by: Andrej Valek <andrej.v@skyrain.eu>
|
||||
Upstream: https://lists.busybox.net/pipermail/busybox/2024-October/090969.html
|
||||
[Thomas: this was reported as beeing needed by Bernd Kuhls at
|
||||
https://lore.kernel.org/buildroot/pan$de0bb$35c5a64$ca9b6f21$2408ff40@ID-313208.user.individual.net/,
|
||||
but also on the Busybox mailing list at
|
||||
https://lists.busybox.net/pipermail/busybox/2023-September/090499.html]
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||||
---
|
||||
sysklogd/syslogd.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
|
||||
index 7558051f0..fa03aa280 100644
|
||||
--- a/sysklogd/syslogd.c
|
||||
+++ b/sysklogd/syslogd.c
|
||||
@@ -1179,7 +1179,7 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
- if (!ENABLE_FEATURE_REMOTE_LOG || (opts & OPT_locallog)) {
|
||||
+ if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) {
|
||||
recvbuf[sz] = '\0'; /* ensure it *is* NUL terminated */
|
||||
split_escape_and_log(recvbuf, sz);
|
||||
}
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# The rig's only differences from the panel's BusyBox config (panel.config).
|
||||
# Each line replaces the panel's setting for the same symbol. They change how
|
||||
# the binary links and looks up names, not which applets or options exist:
|
||||
# STATIC: the rig's initramfs has no shared libc, the panel's rootfs does.
|
||||
# USE_BB_PWD_GRP, USE_BB_SHADOW: a static glibc binary cannot load the NSS
|
||||
# modules getpwnam() needs, so BusyBox reads /etc/passwd, /etc/group and
|
||||
# /etc/shadow itself (the panel's uClibc-ng reads the same files).
|
||||
# qemu/tests/busybox-panel-test.sh refuses any other symbol here.
|
||||
CONFIG_STATIC=y
|
||||
CONFIG_USE_BB_PWD_GRP=y
|
||||
CONFIG_USE_BB_SHADOW=y
|
||||
+95
-28
@@ -4,33 +4,30 @@
|
||||
|
||||
BB_VER=1.31.0
|
||||
BB_URL="https://busybox.net/downloads/binaries/${BB_VER}-defconfig-multiarch-musl/busybox-armv7l"
|
||||
# The panel BusyBox source (RIG_BUSYBOX=panel, qemu/build-busybox.sh). From
|
||||
# https://busybox.net/downloads/busybox-1.37.0.tar.bz2.sha256, the same pin as
|
||||
# Buildroot 2025.02.8 package/busybox/busybox.hash.
|
||||
BB_SRC_VER=1.37.0
|
||||
# Read by build-busybox.sh, which sources this file.
|
||||
# shellcheck disable=SC2034
|
||||
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
|
||||
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
|
||||
|
||||
qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
|
||||
# Fetch (or accept via $BUSYBOX) the pinned static armv7 busybox and verify it
|
||||
# against qemu/busybox.sha256. FAILS CLOSED: a missing pin refuses to build,
|
||||
# never silently skips verification, mirroring build/build-kernel.sh's
|
||||
# tarball handling. Sets $BB to the verified binary's path.
|
||||
qemu_get_busybox() {
|
||||
local sha_file="$QEMU_DIR/busybox.sha256"
|
||||
local out="${OUT:-$QEMU_DIR/out}"
|
||||
mkdir -p "$out"
|
||||
BB="${BUSYBOX:-$out/busybox-armv7l}"
|
||||
# Pin first: a missing pin refuses BEFORE downloading, same ordering as
|
||||
# build/fetch-kernel-tarball.sh.
|
||||
[ -f "$sha_file" ] || {
|
||||
echo "FATAL: no pinned sha256 for busybox (expected $sha_file): refusing to build from an unverified binary" >&2
|
||||
exit 1
|
||||
}
|
||||
local want got
|
||||
want="$(cat "$sha_file")"
|
||||
if [ -f "$BB" ]; then
|
||||
got="$(sha256sum "$BB" | awk '{print $1}')"
|
||||
# Download URL to DEST and verify it against the sha256 WANT. A DEST that
|
||||
# already matches is kept. FAILS CLOSED: three bounded attempts, then exit 1;
|
||||
# a mismatching download never lands at DEST.
|
||||
# Usage: qemu_fetch_verified URL WANT DEST LABEL
|
||||
qemu_fetch_verified() {
|
||||
local url="$1" want="$2" dest="$3" label="$4" got
|
||||
if [ -f "$dest" ]; then
|
||||
got="$(sha256sum "$dest" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
qemu_log "busybox sha256 verified"
|
||||
qemu_log "$label sha256 verified"
|
||||
return
|
||||
fi
|
||||
qemu_log "cached busybox failed verification; fetching a clean copy"
|
||||
qemu_log "cached $label failed verification; fetching a clean copy"
|
||||
fi
|
||||
|
||||
# Every attempt is bounded: a server that answers and then stalls would
|
||||
@@ -40,27 +37,97 @@ qemu_get_busybox() {
|
||||
# shorten them through the environment.
|
||||
local stall="${BB_FETCH_STALL_SECS:-20}" max="${BB_FETCH_MAX_SECS:-60}"
|
||||
local delay="${BB_FETCH_RETRY_DELAY:-5}"
|
||||
local attempt tmp="${BB}.download.$$"
|
||||
local attempt tmp="${dest}.download.$$"
|
||||
rm -f "$tmp"
|
||||
for attempt in 1 2 3; do
|
||||
qemu_log "downloading $BB_URL (attempt $attempt/3)"
|
||||
qemu_log "downloading $url (attempt $attempt/3)"
|
||||
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
|
||||
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
|
||||
--max-time "$max" -fSL "$BB_URL" -o "$tmp"; then
|
||||
--max-time "$max" -fSL "$url" -o "$tmp"; then
|
||||
got="$(sha256sum "$tmp" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
mv -f "$tmp" "$BB"
|
||||
qemu_log "busybox sha256 verified"
|
||||
mv -f "$tmp" "$dest"
|
||||
qemu_log "$label sha256 verified"
|
||||
return
|
||||
fi
|
||||
echo "busybox sha256 mismatch on attempt $attempt: want $want got $got" >&2
|
||||
echo "$label sha256 mismatch on attempt $attempt: want $want got $got" >&2
|
||||
fi
|
||||
rm -f "$tmp"
|
||||
done
|
||||
echo "FATAL: could not fetch pinned busybox after 3 verified attempts" >&2
|
||||
echo "FATAL: could not fetch pinned $label after 3 verified attempts" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# The source inputs of the panel BusyBox, as one sha256: the pinned source
|
||||
# tarball and every committed file under qemu/busybox/ the build reads. The
|
||||
# compiler is not part of it (build-busybox.sh keys its rebuild on that too),
|
||||
# so a job without the cross compiler can check a binary another job built.
|
||||
# build-busybox.sh writes it next to the binary as <binary>.inputs.
|
||||
qemu_busybox_panel_inputs() {
|
||||
local d="$QEMU_DIR/busybox"
|
||||
{
|
||||
echo "busybox $BB_SRC_VER $BB_SRC_SHA256"
|
||||
(cd "$d" && sha256sum panel.config rig.fragment applets.txt patches/*.patch)
|
||||
} | sha256sum | awk '{print $1}'
|
||||
}
|
||||
|
||||
# Provide the rig's static armv7 busybox and set $BB to its path.
|
||||
#
|
||||
# RIG_BUSYBOX picks which one (flare-edge#2210):
|
||||
# multiarch (default) the busybox.net $BB_VER defconfig-multiarch-musl
|
||||
# binary, fetched (or accepted via $BUSYBOX) and
|
||||
# verified against qemu/busybox.sha256
|
||||
# panel the image's BusyBox version and applet config, built
|
||||
# from source by qemu/build-busybox.sh (needs a cross
|
||||
# compiler; checked by its applet list, see there).
|
||||
# With $BUSYBOX set, that prebuilt panel binary is used
|
||||
# instead (a job without the cross compiler, given the
|
||||
# binary an earlier build job made): it is accepted only
|
||||
# when its $BUSYBOX.inputs, written by build-busybox.sh,
|
||||
# equals qemu_busybox_panel_inputs of this tree, so a
|
||||
# binary built from other config files is refused.
|
||||
# FAILS CLOSED: a missing pin refuses to build, never silently skips
|
||||
# verification, mirroring build/build-kernel.sh's tarball handling; an
|
||||
# unknown RIG_BUSYBOX, or a prebuilt panel binary without matching inputs,
|
||||
# is refused.
|
||||
qemu_get_busybox() {
|
||||
local out="${OUT:-$QEMU_DIR/out}"
|
||||
mkdir -p "$out"
|
||||
case "${RIG_BUSYBOX:-multiarch}" in
|
||||
multiarch) ;;
|
||||
panel)
|
||||
if [ -n "${BUSYBOX:-}" ]; then
|
||||
local want got
|
||||
want="$(qemu_busybox_panel_inputs)"
|
||||
got="$(cat "$BUSYBOX.inputs" 2>/dev/null || true)"
|
||||
if [ ! -f "$BUSYBOX" ] || [ "$got" != "$want" ]; then
|
||||
echo "FATAL: BUSYBOX=$BUSYBOX is not a panel BusyBox built from this tree's qemu/busybox/ ($BUSYBOX.inputs '${got:-missing}', want '$want'): run qemu/build-busybox.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
BB="$BUSYBOX"
|
||||
qemu_log "panel busybox: prebuilt $BB (inputs $want)"
|
||||
return
|
||||
fi
|
||||
OUT="$out" bash "$QEMU_DIR/build-busybox.sh"
|
||||
BB="$out/busybox-armv7l-panel"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo "FATAL: RIG_BUSYBOX must be multiarch or panel, not '${RIG_BUSYBOX}'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
local sha_file="$QEMU_DIR/busybox.sha256"
|
||||
BB="${BUSYBOX:-$out/busybox-armv7l}"
|
||||
# Pin first: a missing pin refuses BEFORE downloading, same ordering as
|
||||
# build/fetch-kernel-tarball.sh.
|
||||
[ -f "$sha_file" ] || {
|
||||
echo "FATAL: no pinned sha256 for busybox (expected $sha_file): refusing to build from an unverified binary" >&2
|
||||
exit 1
|
||||
}
|
||||
qemu_fetch_verified "$BB_URL" "$(cat "$sha_file")" "$BB" busybox
|
||||
}
|
||||
|
||||
# Stage the shared rootfs skeleton (qemu/rootfs/ + busybox) into $1.
|
||||
# Requires qemu_get_busybox to have run (uses $BB).
|
||||
qemu_stage_rootfs() {
|
||||
|
||||
+4
-1
@@ -15,7 +15,10 @@
|
||||
# flare-edge build's rootfs.img/oem.img matched pair) into slot A instead of
|
||||
# the busybox skeleton; slot B keeps the skeleton as a known-good fallback.
|
||||
# Env:
|
||||
# BUSYBOX path to a local busybox binary (skips the download; still verified)
|
||||
# BUSYBOX path to a local busybox binary (skips the download; still verified;
|
||||
# with RIG_BUSYBOX=panel a prebuilt panel binary, checked by its .inputs)
|
||||
# RIG_BUSYBOX multiarch (default) or panel: the image's own BusyBox, built by
|
||||
# qemu/build-busybox.sh (see qemu/busybox/README.md)
|
||||
# OUT output dir (default: qemu/out); image at $OUT/disk.img
|
||||
# PAYLOAD_DIR the directory whose binaries land in /usr/bin of both slots
|
||||
# (default qemu/payload). Lets one run boot its own payload set
|
||||
|
||||
+4
-1
@@ -4,7 +4,10 @@
|
||||
# see qemu/lib.sh).
|
||||
#
|
||||
# Env:
|
||||
# BUSYBOX path to a local busybox binary (skips the download; still verified)
|
||||
# BUSYBOX path to a local busybox binary (skips the download; still verified;
|
||||
# with RIG_BUSYBOX=panel a prebuilt panel binary, checked by its .inputs)
|
||||
# RIG_BUSYBOX multiarch (default) or panel: the image's own BusyBox, built by
|
||||
# qemu/build-busybox.sh (see qemu/busybox/README.md)
|
||||
# OUT output dir (default: qemu/out); initramfs at $OUT/initramfs.cpio.gz
|
||||
# EXTRA_DIR a directory merged into the initramfs root (a test's scripts and
|
||||
# static binaries; init runs one on warden.run=<path>)
|
||||
|
||||
@@ -54,6 +54,27 @@ warden_trap_power_signals() {
|
||||
trap 'echo "init: halt requested"; sync; ${WARDEN_POWEROFF_CMD:-poweroff -f}' USR1
|
||||
}
|
||||
|
||||
# The warden.shell interactive shell, on the console's real tty so it gets
|
||||
# job control. BusyBox's cttyhack does that where it is built in; the panel's
|
||||
# BusyBox (qemu/build-busybox.sh, RIG_BUSYBOX=panel) has no cttyhack, so the
|
||||
# tty is read from sysfs (the last console listed is /dev/console's) and
|
||||
# setsid -c makes it the controlling terminal (flare-edge#2210).
|
||||
# WARDEN_CONSOLE_ACTIVE and WARDEN_DEV_DIR point the host test at stand-ins.
|
||||
warden_console_shell() {
|
||||
if command -v cttyhack >/dev/null 2>&1; then
|
||||
setsid cttyhack sh
|
||||
return
|
||||
fi
|
||||
_wcs_tty="$(cat "${WARDEN_CONSOLE_ACTIVE:-/sys/class/tty/console/active}" 2>/dev/null)"
|
||||
_wcs_tty="${_wcs_tty##* }"
|
||||
if [ -n "$_wcs_tty" ] && [ -c "${WARDEN_DEV_DIR:-/dev}/$_wcs_tty" ]; then
|
||||
setsid -c sh <>"${WARDEN_DEV_DIR:-/dev}/$_wcs_tty" >&0 2>&1
|
||||
else
|
||||
echo "warden.shell: no console tty found; shell without job control"
|
||||
sh
|
||||
fi
|
||||
}
|
||||
|
||||
# Idle forever in a way a trapped signal interrupts at once: a foreground
|
||||
# `sleep` would hold the trap until it returned, up to an hour later.
|
||||
warden_idle_forever() {
|
||||
@@ -366,3 +387,113 @@ warden_init_chain() {
|
||||
done
|
||||
echo "$_wic_ran"
|
||||
}
|
||||
|
||||
# The rig agent (flare-edge M9 soak-lite, d10 6.5): a shell inside the guest
|
||||
# for a host-side rig that must read state and change it (tools/soak/rig-qemu.py:
|
||||
# bus reads and writes, the clock, /proc for metrics). /sbin/init runs it on
|
||||
# its own pci-serial port, only on a boot with warden.agent on the command
|
||||
# line (run.sh --agent). It is part of the rig rootfs, which no panel image
|
||||
# carries; the flow channels (ctl bridge, test hook) are untouched by it.
|
||||
#
|
||||
# One request per line on stdin, every answer framed so the host never needs
|
||||
# a timeout to know a reply is complete:
|
||||
#
|
||||
# @ping -> <<PONG>>
|
||||
# @chunk ID B64 -> <<OK ID BYTES>> appends B64 to ID's script text
|
||||
# @run ID SECS [B64] -> <<BEGIN ID>>, the base64 of the script's stdout
|
||||
# and stderr, <<END ID RC>>
|
||||
# anything else -> <<ERR reason>>
|
||||
#
|
||||
# The script is the base64 text of the @chunk lines for ID, then the @run
|
||||
# line's own B64, decoded and run by sh with stdin from /dev/null. The agent
|
||||
# port is a tty in cooked mode, which cuts a line at 4095 bytes, hence the
|
||||
# chunks. ID is [A-Za-z0-9_-] (1 to 32 characters), SECS 1 to 3600. A script
|
||||
# still running after SECS seconds is killed with its whole process group and
|
||||
# answers RC 124, as timeout(1) does; the panel BusyBox has no timeout applet.
|
||||
# WARDEN_AGENT_DIR exists for the host test only.
|
||||
warden_agent() {
|
||||
_wa_dir="${WARDEN_AGENT_DIR:-/tmp/warden-agent}"
|
||||
mkdir -p "$_wa_dir"
|
||||
while IFS= read -r _wa_line; do
|
||||
# A cooked tty may hand the line over with a trailing CR.
|
||||
_wa_line="${_wa_line%"$(printf '\r')"}"
|
||||
[ -n "$_wa_line" ] || continue
|
||||
set -f
|
||||
# shellcheck disable=SC2086 # split into words on purpose, globbing off
|
||||
set -- $_wa_line
|
||||
set +f
|
||||
case "$1" in
|
||||
@ping) echo "<<PONG>>" ;;
|
||||
@chunk)
|
||||
if [ "$#" -ne 3 ] || ! _wa_id_ok "$2" || ! _wa_b64_ok "$3"; then
|
||||
echo "<<ERR bad chunk>>"
|
||||
continue
|
||||
fi
|
||||
printf '%s' "$3" >> "$_wa_dir/$2.b64"
|
||||
echo "<<OK $2 $(wc -c < "$_wa_dir/$2.b64" | tr -d ' ')>>"
|
||||
;;
|
||||
@run)
|
||||
if [ "$#" -lt 3 ] || [ "$#" -gt 4 ] || ! _wa_id_ok "$2" ||
|
||||
! _wa_secs_ok "$3" || { [ "$#" -eq 4 ] && ! _wa_b64_ok "$4"; }; then
|
||||
echo "<<ERR bad run>>"
|
||||
continue
|
||||
fi
|
||||
[ "$#" -eq 4 ] && printf '%s' "$4" >> "$_wa_dir/$2.b64"
|
||||
_wa_run "$2" "$3"
|
||||
;;
|
||||
*) echo "<<ERR unknown request>>" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
_wa_id_ok() {
|
||||
case "$1" in ""|*[!A-Za-z0-9_-]*) return 1 ;; esac
|
||||
[ "${#1}" -le 32 ]
|
||||
}
|
||||
|
||||
_wa_b64_ok() {
|
||||
case "$1" in ""|*[!A-Za-z0-9+/=]*) return 1 ;; esac
|
||||
return 0
|
||||
}
|
||||
|
||||
_wa_secs_ok() {
|
||||
case "$1" in ""|*[!0-9]*) return 1 ;; esac
|
||||
[ "${#1}" -le 4 ] && [ "$1" -ge 1 ] && [ "$1" -le 3600 ]
|
||||
}
|
||||
|
||||
# _wa_run ID SECS: decode, run under the deadline, answer, forget ID.
|
||||
_wa_run() {
|
||||
_wr_b64="$_wa_dir/$1.b64"
|
||||
_wr_sh="$_wa_dir/$1.sh"
|
||||
_wr_out="$_wa_dir/$1.out"
|
||||
if [ ! -s "$_wr_b64" ] || ! base64 -d < "$_wr_b64" > "$_wr_sh" 2>/dev/null ||
|
||||
[ ! -s "$_wr_sh" ]; then
|
||||
rm -f "$_wr_b64" "$_wr_sh"
|
||||
echo "<<ERR bad script $1>>"
|
||||
return 0
|
||||
fi
|
||||
rm -f "$_wr_b64"
|
||||
# setsid: the script leads its own process group, so a timeout kills
|
||||
# every process it started, not only its shell.
|
||||
setsid sh "$_wr_sh" < /dev/null > "$_wr_out" 2>&1 &
|
||||
_wr_pid=$!
|
||||
_wr_n=0
|
||||
_wr_limit=$(($2 * 10))
|
||||
_wr_late=0
|
||||
while kill -0 "$_wr_pid" 2>/dev/null; do
|
||||
if [ "$_wr_n" -ge "$_wr_limit" ]; then
|
||||
kill -KILL "-$_wr_pid" 2>/dev/null || kill -KILL "$_wr_pid" 2>/dev/null
|
||||
_wr_late=1
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
_wr_n=$((_wr_n + 1))
|
||||
done
|
||||
wait "$_wr_pid" 2>/dev/null
|
||||
_wr_rc=$?
|
||||
[ "$_wr_late" = 1 ] && _wr_rc=124
|
||||
echo "<<BEGIN $1>>"
|
||||
[ -s "$_wr_out" ] && base64 < "$_wr_out"
|
||||
echo "<<END $1 $_wr_rc>>"
|
||||
rm -f "$_wr_sh" "$_wr_out"
|
||||
}
|
||||
|
||||
+3
-1
@@ -75,7 +75,9 @@ fi
|
||||
|
||||
if grep -qw warden.shell /proc/cmdline; then
|
||||
echo "warden.shell: interactive shell (exit to power off)"
|
||||
setsid cttyhack sh
|
||||
# shellcheck source=qemu/rootfs/etc/warden-lib.sh disable=SC1091
|
||||
. /etc/warden-lib.sh
|
||||
warden_console_shell
|
||||
fi
|
||||
|
||||
poweroff -f
|
||||
|
||||
+24
-2
@@ -48,7 +48,7 @@ mount_fatal() {
|
||||
echo "WARDEN-QEMU-MOUNT-FAILED $1"
|
||||
if grep -qw warden.shell /proc/cmdline; then
|
||||
echo "warden.shell: post-mortem shell (exit powers off)"
|
||||
setsid cttyhack sh
|
||||
warden_console_shell
|
||||
fi
|
||||
poweroff -f
|
||||
fi
|
||||
@@ -229,9 +229,31 @@ if grep -qw warden.ctl /proc/cmdline && [ -c /dev/ttyS0 ]; then
|
||||
) &
|
||||
fi
|
||||
|
||||
# Rig agent (run.sh --agent, warden.agent on the command line): a shell for a
|
||||
# host-side rig that reads and changes guest state, such as the QEMU soak rig
|
||||
# (flare-edge tools/soak/rig-qemu.py). Its pci-serial port comes after the
|
||||
# ctl port (when there is one) and the always-present RS485 port, so it is
|
||||
# ttyS2 with warden.ctl and ttyS1 without; the ctl/RS485 order above is
|
||||
# unchanged. Echo is turned off so the host reads only the agent's frames.
|
||||
# The protocol is warden_agent (/etc/warden-lib.sh). Rig rootfs only: no
|
||||
# panel image carries it.
|
||||
if grep -qw warden.agent /proc/cmdline; then
|
||||
if grep -qw warden.ctl /proc/cmdline; then agent=/dev/ttyS2; else agent=/dev/ttyS1; fi
|
||||
if [ -c "$agent" ]; then
|
||||
echo "init: rig agent on $agent"
|
||||
(
|
||||
exec 4<> "$agent"
|
||||
stty -echo <&4 2>/dev/null || echo "init: rig agent: stty -echo failed"
|
||||
warden_agent <&4 >&4 2>/dev/null
|
||||
) &
|
||||
else
|
||||
echo "init: rig agent: $agent missing (needs the virt.fragment kernel)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep -qw warden.shell /proc/cmdline; then
|
||||
echo "warden.shell: interactive shell (exit powers off)"
|
||||
setsid cttyhack sh
|
||||
warden_console_shell
|
||||
poweroff -f
|
||||
fi
|
||||
|
||||
|
||||
+14
-1
@@ -17,6 +17,10 @@
|
||||
# --ctl SOCK unix socket to warden-ui's debug channel (nav/page/hit),
|
||||
# bridged by init from a pci-serial port; the rig-side
|
||||
# twin of tools/warden-ctl over SSH on a real panel
|
||||
# --agent SOCK unix socket to the rig agent (warden_agent in
|
||||
# rootfs/etc/warden-lib.sh): a guest shell for host-side
|
||||
# rigs such as flare-edge tools/soak/rig-qemu.py; a third
|
||||
# pci-serial after ctl and rs485, so their order holds
|
||||
# --watchdog add i6300esb watchdog, reset on expiry (fragment kernel)
|
||||
# --qmp SOCK QMP unix socket (screendump, input-send-event, quit)
|
||||
# --display MODE off (default, -nographic) | on (gtk window) | headless
|
||||
@@ -38,7 +42,7 @@ QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
OUT="${OUT:-$QEMU_DIR/out}"
|
||||
|
||||
KERNEL="" INITRD="$OUT/initramfs.cpio.gz" DISK="" NO_DISK=0 SLOT="_a"
|
||||
RTC="" RS485="" CTL="" WATCHDOG=0 QMP="" DISPLAY_MODE="off" SHELL_FLAG=0 ALLOW_APPLY=0
|
||||
RTC="" RS485="" CTL="" AGENT="" WATCHDOG=0 QMP="" DISPLAY_MODE="off" SHELL_FLAG=0 ALLOW_APPLY=0
|
||||
SSH_PORT=2222 HTTP_PORT=8080 API_PORT=28443
|
||||
EXTRA=()
|
||||
EXTRA_APPEND=""
|
||||
@@ -53,6 +57,7 @@ while [ $# -gt 0 ]; do
|
||||
--rtc) RTC="${2:?}"; shift 2 ;;
|
||||
--rs485) RS485="${2:?}"; shift 2 ;;
|
||||
--ctl) CTL="${2:?}"; shift 2 ;;
|
||||
--agent) AGENT="${2:?}"; shift 2 ;;
|
||||
--watchdog) WATCHDOG=1; shift ;;
|
||||
--qmp) QMP="${2:?}"; shift 2 ;;
|
||||
--display) DISPLAY_MODE="${2:?}"; shift 2 ;;
|
||||
@@ -143,6 +148,14 @@ if [ -n "$RS485" ]; then
|
||||
else
|
||||
ARGS+=( -chardev "null,id=rs485" -device "pci-serial,chardev=rs485" )
|
||||
fi
|
||||
# The rig agent comes LAST of the pci-serial ports, so ctl stays ttyS0 and
|
||||
# rs485 stays where init looks for it; init finds the agent at ttyS1 (no
|
||||
# ctl) or ttyS2 (with ctl), and only with warden.agent on the cmdline.
|
||||
if [ -n "$AGENT" ]; then
|
||||
APPEND="$APPEND warden.agent"
|
||||
ARGS+=( -chardev "socket,id=agent,path=$AGENT,server=on,wait=off"
|
||||
-device "pci-serial,chardev=agent" )
|
||||
fi
|
||||
[ -n "$QMP" ] && ARGS+=( -qmp "unix:$QMP,server=on,wait=off" )
|
||||
|
||||
case "$DISPLAY_MODE" in
|
||||
|
||||
Executable
+121
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env bash
|
||||
# Host test for the rig agent, warden_agent in qemu/rootfs/etc/warden-lib.sh
|
||||
# (flare-edge M9 soak-lite). Feeds request lines on stdin, as the host rig
|
||||
# does over the agent's serial port, and checks the framed answers: a script
|
||||
# runs and answers its output in base64 with its exit code, chunks join into
|
||||
# one script, a script past its deadline is killed with its children and
|
||||
# answers 124, and malformed requests answer one <<ERR ...>> line and run
|
||||
# nothing.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
LIB="$HERE/../rootfs/etc/warden-lib.sh"
|
||||
# Unquoted where it runs: WARDEN_TEST_SH may be "busybox sh", the rig's shell.
|
||||
SH="${WARDEN_TEST_SH:-sh}"
|
||||
WORK="$(mktemp -d)" || exit 1
|
||||
trap 'rm -rf "$WORK"' 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
|
||||
}
|
||||
|
||||
b64() { printf '%s' "$1" | base64 -w0; }
|
||||
|
||||
agent() { # agent <name> <lines...>: run the agent over the lines
|
||||
local name="$1"
|
||||
shift
|
||||
# $SH unquoted (it may be "busybox sh"); the quoted script is meant literally.
|
||||
# shellcheck disable=SC2086,SC2016
|
||||
printf '%s\n' "$@" |
|
||||
env WARDEN_AGENT_DIR="$WORK/agent-$name" \
|
||||
$SH -c '. "$1"; warden_agent' sh "$LIB" > "$WORK/$name.out" 2> "$WORK/$name.err"
|
||||
}
|
||||
|
||||
same() { # same <file> <expected lines...>
|
||||
local file="$1"
|
||||
shift
|
||||
diff <(printf '%s\n' "$@") "$file" > "$WORK/diff" || { cat "$WORK/diff"; return 1; }
|
||||
}
|
||||
|
||||
# The body between <<BEGIN ID>> and <<END ID ...>>, decoded.
|
||||
body() { # body <file> <id>
|
||||
awk -v b="<<BEGIN $2>>" -v e="<<END $2 " '$0 == b {on = 1; next} index($0, e) == 1 {on = 0} on' "$1" |
|
||||
base64 -d
|
||||
}
|
||||
|
||||
agent basic @ping "@run a1 10 $(b64 'echo hello; echo oops >&2; exit 3')"
|
||||
check "ping and a run answer framed lines" \
|
||||
grep -qx '<<PONG>>' "$WORK/basic.out"
|
||||
check "the run ends with its exit code" grep -qx '<<END a1 3>>' "$WORK/basic.out"
|
||||
check "stdout and stderr come back in base64" \
|
||||
same <(body "$WORK/basic.out" a1) hello oops
|
||||
|
||||
# Chunks: the script text arrives in pieces, then @run with no B64 of its own
|
||||
# and once more with a last piece on the run line.
|
||||
# shellcheck disable=SC2016 # the guest's shell expands it, not this one
|
||||
script='i=0; while [ $i -lt 3 ]; do echo line$i; i=$((i + 1)); done'
|
||||
whole="$(b64 "$script")"
|
||||
agent chunks "@chunk c1 ${whole:0:20}" "@chunk c1 ${whole:20}" "@run c1 10" \
|
||||
"@chunk c2 ${whole:0:12}" "@run c2 10 ${whole:12}"
|
||||
check "chunks acknowledge the bytes so far" \
|
||||
grep -qx "<<OK c1 20>>" "$WORK/chunks.out"
|
||||
check "chunked script runs whole" same <(body "$WORK/chunks.out" c1) line0 line1 line2
|
||||
check "a last piece on the run line joins the chunks" \
|
||||
same <(body "$WORK/chunks.out" c2) line0 line1 line2
|
||||
check "a script's text is used once" \
|
||||
test -z "$(ls -A "$WORK/agent-chunks" 2>/dev/null)"
|
||||
|
||||
# Deadline: the script and the child it started both die; RC 124.
|
||||
start=$(date +%s)
|
||||
agent late "@run t1 1 $(b64 "sleep 30 & echo \$! > $WORK/child.pid; sleep 30")" @ping
|
||||
took=$(( $(date +%s) - start ))
|
||||
check "a script past its deadline answers 124" grep -qx '<<END t1 124>>' "$WORK/late.out"
|
||||
check "the deadline holds (took ${took}s)" test "$took" -le 5
|
||||
child="$(cat "$WORK/child.pid" 2>/dev/null)"
|
||||
# Gone or a zombie: in a CI job container PID 1 reaps nothing, so a killed
|
||||
# orphan stays a zombie that kill -0 still finds.
|
||||
gone() { [ ! -r "/proc/$1/stat" ] || [ "$(sed 's/.*) //' "/proc/$1/stat" | cut -d' ' -f1)" = Z ]; }
|
||||
check "the script's child is killed too" bash -c "[ -n '$child' ] && $(declare -f gone); sleep 0.5; gone '$child'"
|
||||
check "the agent answers after a timeout" grep -qx '<<PONG>>' "$WORK/late.out"
|
||||
|
||||
# Malformed requests: one error line each, nothing runs.
|
||||
touch_b64="$(b64 "touch $WORK/ran")"
|
||||
agent bad "@run bad/id 10 $touch_b64" "@run b1 0 $touch_b64" "@run b1 99999 $touch_b64" \
|
||||
"@run b1 10 not*base64" "@chunk b2" "@run b3 10" "frobnicate" "@run b4 10 $(b64 'x') extra" \
|
||||
"@run b5 10 ===="
|
||||
check "malformed requests answer one error line each" \
|
||||
same "$WORK/bad.out" '<<ERR bad run>>' '<<ERR bad run>>' '<<ERR bad run>>' '<<ERR bad run>>' \
|
||||
'<<ERR bad chunk>>' '<<ERR bad script b3>>' '<<ERR unknown request>>' '<<ERR bad run>>' \
|
||||
'<<ERR bad script b5>>'
|
||||
check "no malformed request ran anything" test ! -e "$WORK/ran"
|
||||
|
||||
# A trailing CR (a cooked tty line) is not part of the last word.
|
||||
agent cr "$(printf '@ping\r')" "$(printf '@run r1 10 %s\r' "$(b64 'echo ok')")"
|
||||
check "a trailing CR is ignored" bash -c "grep -qx '<<PONG>>' '$WORK/cr.out' && grep -qx '<<END r1 0>>' '$WORK/cr.out'"
|
||||
|
||||
# A request with glob characters in a word does not expand them.
|
||||
agent glob "@run * 10 $(b64 'echo no')"
|
||||
check "a glob word is not expanded" same "$WORK/glob.out" '<<ERR bad run>>'
|
||||
|
||||
# sbin/init arms the agent only on warden.agent, on the port after ctl and
|
||||
# RS485 (ttyS2 with warden.ctl, ttyS1 without), with echo off.
|
||||
INIT="$HERE/../rootfs/sbin/init"
|
||||
check "init arms the agent only with warden.agent" grep -q 'grep -qw warden.agent /proc/cmdline' "$INIT"
|
||||
check "init picks ttyS2 with ctl and ttyS1 without" \
|
||||
grep -q 'if grep -qw warden.ctl /proc/cmdline; then agent=/dev/ttyS2; else agent=/dev/ttyS1; fi' "$INIT"
|
||||
check "init turns echo off on the agent port" grep -q 'stty -echo <&4' "$INIT"
|
||||
|
||||
if [ "$FAIL" = 0 ]; then
|
||||
echo "agent tests: OK ($CHECKS checks)"
|
||||
else
|
||||
echo "agent tests: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Check a built panel BusyBox against the bench capture (flare-edge#2210):
|
||||
# its applet list must equal qemu/busybox/applets.txt and every applet's
|
||||
# --help text must equal qemu/busybox/help.txt, which lists the options each
|
||||
# applet of the panel's own binary accepts. The binary is ARM: the host runs
|
||||
# it through binfmt, or through $QEMU_USER (e.g. qemu-arm) when set.
|
||||
#
|
||||
# bash qemu/tests/busybox-panel-help.sh [BIN] (default qemu/out/busybox-armv7l-panel)
|
||||
set -euo pipefail
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BB_DIR="$HERE/../busybox"
|
||||
BIN="${1:-$HERE/../out/busybox-armv7l-panel}"
|
||||
[ -x "$BIN" ] || { echo "FATAL: no busybox binary at $BIN (run qemu/build-busybox.sh)" >&2; exit 1; }
|
||||
export LC_ALL=C
|
||||
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/bb-panel-help.XXXXXX")"
|
||||
trap 'rm -rf "$SCRATCH"' EXIT
|
||||
# Word splitting is wanted: QEMU_USER may carry arguments.
|
||||
# shellcheck disable=SC2206
|
||||
RUN=(${QEMU_USER:-} "$BIN")
|
||||
|
||||
"${RUN[@]}" --list | sort > "$SCRATCH/list.txt" || {
|
||||
echo "FATAL: $BIN does not run here (no binfmt for ARM? set QEMU_USER=qemu-arm)" >&2
|
||||
exit 1
|
||||
}
|
||||
if ! diff -u <(sort "$BB_DIR/applets.txt") "$SCRATCH/list.txt"; then
|
||||
echo "FAIL: the applet list differs from qemu/busybox/applets.txt (- panel, + built)" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Same shape as flare-edge tools/bench/busybox-help/capture.sh: the banner
|
||||
# line (version and build date) and blank lines dropped.
|
||||
while IFS= read -r a; do
|
||||
echo "== $a"
|
||||
"${RUN[@]}" "$a" --help 2>&1 | sed 1d | sed '/^$/d' || true
|
||||
done < "$SCRATCH/list.txt" > "$SCRATCH/help.txt"
|
||||
if ! diff -u <(grep -v '^#' "$BB_DIR/help.txt") "$SCRATCH/help.txt"; then
|
||||
echo "FAIL: --help differs from the panel's (qemu/busybox/help.txt; - panel, + built)" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "busybox-panel-help: $(wc -l < "$SCRATCH/list.txt") applets, list and --help equal to the panel's"
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env bash
|
||||
# Offline checks for the rig's panel BusyBox inputs (qemu/busybox/,
|
||||
# qemu/build-busybox.sh, RIG_BUSYBOX in qemu/lib.sh), flare-edge#2210. No
|
||||
# compiler, network or VM: the build helpers run against small stand-in files.
|
||||
#
|
||||
# bash qemu/tests/busybox-panel-test.sh
|
||||
set -uo pipefail
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
QEMU_DIR="$(cd "$HERE/.." && pwd)"
|
||||
REPO="$(cd "$QEMU_DIR/.." && pwd)"
|
||||
BB_DIR="$QEMU_DIR/busybox"
|
||||
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/bb-panel-test.XXXXXX")"
|
||||
trap 'rm -rf "$SCRATCH"' EXIT
|
||||
FAIL=0
|
||||
pass() { printf '[PASS] %s\n' "$1"; }
|
||||
fail() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||
export LC_ALL=C
|
||||
|
||||
# shellcheck source=qemu/build-busybox.sh disable=SC1091
|
||||
. "$QEMU_DIR/build-busybox.sh"
|
||||
# The sourced script sets -e for its own run; these checks report each failure.
|
||||
set +e
|
||||
|
||||
# 1. Every setting the image's applet patch makes is in the panel config.
|
||||
PATCH="$REPO/luckfox-sdk-patches/buildroot/patches/0001-busybox-applets.patch"
|
||||
missing="$(sed -n -e 's/^+\(CONFIG_[A-Za-z0-9_]*=.*\)$/\1/p' \
|
||||
-e 's/^+\(# CONFIG_[A-Za-z0-9_]* is not set\)$/\1/p' "$PATCH" |
|
||||
while IFS= read -r l; do grep -qxF -- "$l" "$BB_DIR/panel.config" || printf '%s\n' "$l"; done)"
|
||||
n="$(grep -cE '^\+(CONFIG_|# CONFIG_)' "$PATCH")"
|
||||
if [ "$n" -gt 0 ] && [ -z "$missing" ]; then
|
||||
pass "panel.config carries all $n settings of the image's applet patch"
|
||||
else
|
||||
fail "panel.config lacks settings of $PATCH: ${missing:-none read}"
|
||||
fi
|
||||
|
||||
# 2. The rig differs from the panel only in linking and name lookup.
|
||||
got="$(grep -Ev '^(#|$)' "$BB_DIR/rig.fragment" | sed 's/=.*//' | sort | tr '\n' ' ')"
|
||||
if [ "$got" = "CONFIG_STATIC CONFIG_USE_BB_PWD_GRP CONFIG_USE_BB_SHADOW " ]; then
|
||||
pass "rig.fragment sets only STATIC, USE_BB_PWD_GRP and USE_BB_SHADOW"
|
||||
else
|
||||
fail "rig.fragment sets symbols beyond linking and name lookup: $got"
|
||||
fi
|
||||
|
||||
# 3. Applying the fragment replaces exactly its symbols.
|
||||
bb_apply_fragment "$BB_DIR/panel.config" "$BB_DIR/rig.fragment" > "$SCRATCH/rig.config"
|
||||
d="$(diff <(bb_settings "$BB_DIR/panel.config") <(bb_settings "$SCRATCH/rig.config"))"
|
||||
want_d="$(printf '%s\n' '< CONFIG_STATIC is not set' '< CONFIG_USE_BB_PWD_GRP is not set' \
|
||||
'< CONFIG_USE_BB_SHADOW is not set' '> CONFIG_STATIC=y' '> CONFIG_USE_BB_PWD_GRP=y' \
|
||||
'> CONFIG_USE_BB_SHADOW=y')"
|
||||
if [ "$(grep -E '^[<>]' <<<"$d" | sort)" = "$want_d" ]; then
|
||||
pass "the rig config is the panel config with the three fragment lines"
|
||||
else
|
||||
fail "the rig config differs from the panel config by: $d"
|
||||
fi
|
||||
printf 'CONFIG_A=y\n# CONFIG_B is not set\nCONFIG_C="x"\n' > "$SCRATCH/p.config"
|
||||
printf '# note\nNOT_A_SYMBOL=y\n' > "$SCRATCH/bad.fragment"
|
||||
if ! bb_apply_fragment "$SCRATCH/p.config" "$SCRATCH/bad.fragment" >/dev/null 2>"$SCRATCH/frag.err" &&
|
||||
grep -q 'bad fragment line' "$SCRATCH/frag.err"; then
|
||||
pass "a fragment line that is not CONFIG_* is refused"
|
||||
else
|
||||
fail "a bad fragment line was accepted"
|
||||
fi
|
||||
|
||||
# 4. A Kconfig rewrite of any setting fails and names it.
|
||||
cp "$SCRATCH/p.config" "$SCRATCH/same.config"
|
||||
printf '#\n# a header\n' >> "$SCRATCH/same.config"
|
||||
if bb_check_config "$SCRATCH/p.config" "$SCRATCH/same.config" 2>/dev/null; then
|
||||
pass "a config that only gained comments passes the rewrite check"
|
||||
else
|
||||
fail "the rewrite check failed a config with the same settings"
|
||||
fi
|
||||
printf 'CONFIG_A=y\nCONFIG_C="x"\n' > "$SCRATCH/dropped.config"
|
||||
if ! bb_check_config "$SCRATCH/p.config" "$SCRATCH/dropped.config" 2>"$SCRATCH/cfg.err" &&
|
||||
grep -q 'CONFIG_B is not set' "$SCRATCH/cfg.err"; then
|
||||
pass "a setting Kconfig dropped fails the rewrite check, named"
|
||||
else
|
||||
fail "a dropped setting passed the rewrite check"
|
||||
fi
|
||||
|
||||
# 5. The applet check compares names, not install paths.
|
||||
printf 'b\na\n' > "$SCRATCH/applets.txt"
|
||||
printf '/bin/a\n/usr/sbin/b\n' > "$SCRATCH/ok.links"
|
||||
printf '/bin/a\n/usr/sbin/b\n/usr/bin/timeout\n' > "$SCRATCH/extra.links"
|
||||
if bb_check_applets "$SCRATCH/ok.links" "$SCRATCH/applets.txt" 2>/dev/null; then
|
||||
pass "the same applets under install paths pass"
|
||||
else
|
||||
fail "matching applets failed the applet check"
|
||||
fi
|
||||
if ! bb_check_applets "$SCRATCH/extra.links" "$SCRATCH/applets.txt" 2>"$SCRATCH/app.err" &&
|
||||
grep -q '> timeout' "$SCRATCH/app.err"; then
|
||||
pass "an applet the panel lacks fails the applet check, named"
|
||||
else
|
||||
fail "an extra applet passed the applet check"
|
||||
fi
|
||||
|
||||
# 6. The two bench fixtures agree: applets.txt is help.txt's applet list.
|
||||
if [ -s "$BB_DIR/applets.txt" ] && [ -z "$(sort "$BB_DIR/applets.txt" | uniq -d)" ] &&
|
||||
[ "$(sort "$BB_DIR/applets.txt")" = "$(sed -n 's/^== //p' "$BB_DIR/help.txt" | sort)" ]; then
|
||||
pass "applets.txt ($(wc -l < "$BB_DIR/applets.txt") applets) matches help.txt"
|
||||
else
|
||||
fail "applets.txt and help.txt list different applets (or duplicates)"
|
||||
fi
|
||||
|
||||
# 7. RIG_BUSYBOX refusals, before any download or build.
|
||||
run_get() { (QEMU_DIR="$QEMU_DIR" OUT="$SCRATCH/out" qemu_get_busybox) >/dev/null 2>"$SCRATCH/get.err"; }
|
||||
if ! RIG_BUSYBOX=bogus run_get && grep -q 'RIG_BUSYBOX must be multiarch or panel' "$SCRATCH/get.err"; then
|
||||
pass "an unknown RIG_BUSYBOX is refused"
|
||||
else
|
||||
fail "an unknown RIG_BUSYBOX was accepted"
|
||||
fi
|
||||
|
||||
# 7b. A prebuilt panel binary (a flow job without the cross compiler) is taken
|
||||
# only with a .inputs equal to this tree's qemu_busybox_panel_inputs.
|
||||
inputs="$(QEMU_DIR="$QEMU_DIR" qemu_busybox_panel_inputs)"
|
||||
if [[ "$inputs" =~ ^[0-9a-f]{64}$ ]]; then
|
||||
pass "qemu_busybox_panel_inputs is one sha256"
|
||||
else
|
||||
fail "qemu_busybox_panel_inputs gave '$inputs'"
|
||||
fi
|
||||
mkdir -p "$SCRATCH/pre"
|
||||
printf 'stand-in\n' > "$SCRATCH/pre/bb"
|
||||
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err" &&
|
||||
grep -q "inputs 'missing'" "$SCRATCH/get.err"; then
|
||||
pass "a prebuilt panel BUSYBOX without .inputs is refused"
|
||||
else
|
||||
fail "a prebuilt panel BUSYBOX without .inputs was accepted"
|
||||
fi
|
||||
printf '%s\n' "$(printf '%s' "$inputs" | tr '0-9a-f' '1-9a-f0')" > "$SCRATCH/pre/bb.inputs"
|
||||
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err"; then
|
||||
pass "a prebuilt panel BUSYBOX built from other inputs is refused"
|
||||
else
|
||||
fail "a prebuilt panel BUSYBOX with other inputs was accepted"
|
||||
fi
|
||||
printf '%s\n' "$inputs" > "$SCRATCH/pre/bb.inputs"
|
||||
got_bb="$(RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" QEMU_DIR="$QEMU_DIR" OUT="$SCRATCH/out" \
|
||||
bash -c '. "$QEMU_DIR/lib.sh"; set -euo pipefail; qemu_get_busybox >/dev/null; printf %s "$BB"' 2>"$SCRATCH/get.err")"
|
||||
if [ "$got_bb" = "$SCRATCH/pre/bb" ] && [ ! -e "$SCRATCH/out/busybox-armv7l-panel" ]; then
|
||||
pass "a prebuilt panel BUSYBOX with matching .inputs is used as is, nothing built"
|
||||
else
|
||||
fail "a prebuilt panel BUSYBOX with matching .inputs was not used (BB='$got_bb': $(cat "$SCRATCH/get.err"))"
|
||||
fi
|
||||
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/none" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err"; then
|
||||
pass "a prebuilt panel BUSYBOX that does not exist is refused"
|
||||
else
|
||||
fail "a missing prebuilt panel BUSYBOX was accepted"
|
||||
fi
|
||||
# Every committed input file is in the inputs hash: a config edit changes it.
|
||||
mkdir -p "$SCRATCH/qcopy"
|
||||
cp -a "$QEMU_DIR/busybox" "$SCRATCH/qcopy/"
|
||||
printf '# CONFIG_TIMEOUT is not set\n' >> "$SCRATCH/qcopy/busybox/panel.config"
|
||||
other="$(QEMU_DIR="$SCRATCH/qcopy" qemu_busybox_panel_inputs)"
|
||||
first_patch="$(find "$SCRATCH/qcopy/busybox/patches" -maxdepth 1 -type f -name '*.patch' | sort | head -n 1)"
|
||||
printf 'x\n' >> "$first_patch"
|
||||
other2="$(QEMU_DIR="$SCRATCH/qcopy" qemu_busybox_panel_inputs)"
|
||||
if [ "$other" != "$inputs" ] && [ "$other2" != "$other" ]; then
|
||||
pass "a panel.config or patch edit changes qemu_busybox_panel_inputs"
|
||||
else
|
||||
fail "qemu_busybox_panel_inputs ignored a panel.config or patch edit"
|
||||
fi
|
||||
|
||||
# 8. No cross compiler: the build fails closed, it never falls back.
|
||||
if ! CROSS_COMPILE=no-such-cross- OUT="$SCRATCH/out" bash "$QEMU_DIR/build-busybox.sh" >/dev/null 2>"$SCRATCH/cc.err" &&
|
||||
grep -q 'no no-such-cross-gcc on PATH' "$SCRATCH/cc.err" && [ ! -e "$SCRATCH/out/busybox-armv7l-panel" ]; then
|
||||
pass "a missing cross compiler fails the build with no binary"
|
||||
else
|
||||
fail "the build did not fail closed without a cross compiler"
|
||||
fi
|
||||
|
||||
# 9. The Buildroot patches are there and every one is a patch.
|
||||
np=0
|
||||
for p in "$BB_DIR"/patches/*.patch; do
|
||||
grep -q '^+++ ' "$p" || fail "$p has no diff"
|
||||
np=$((np + 1))
|
||||
done
|
||||
if [ "$np" -eq 11 ]; then
|
||||
pass "the 11 Buildroot 2025.02.8 busybox patches are present"
|
||||
else
|
||||
fail "expected 11 Buildroot busybox patches, found $np"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -ne 0 ]; then
|
||||
echo "busybox-panel: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "busybox-panel: all checks passed"
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
# Offline test for warden_console_shell (qemu/rootfs/etc/warden-lib.sh), the
|
||||
# warden.shell debug shell: with cttyhack it runs `setsid cttyhack sh` as
|
||||
# before; without it (the panel's BusyBox, RIG_BUSYBOX=panel) it opens the
|
||||
# console's tty from sysfs and runs `setsid -c sh` on it; with no tty it says
|
||||
# so and runs a plain sh (flare-edge#2210). Stub commands record each call.
|
||||
#
|
||||
# bash qemu/tests/console-shell-test.sh (WARDEN_TEST_SH="busybox sh" for the rig's shell)
|
||||
set -uo pipefail
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
LIB="$HERE/../rootfs/etc/warden-lib.sh"
|
||||
SH="${WARDEN_TEST_SH:-sh}"
|
||||
WORK="$(mktemp -d "${TMPDIR:-/tmp}/console-shell.XXXXXX")" || exit 1
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
FAIL=0
|
||||
pass() { printf '[PASS] %s\n' "$1"; }
|
||||
fail() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||
|
||||
# Stubs: setsid and sh record their argv and where stdin points.
|
||||
mkdir -p "$WORK/bin" "$WORK/bin-ctty"
|
||||
for c in setsid sh; do
|
||||
# The single-quoted text is the stub's own source.
|
||||
# shellcheck disable=SC2016
|
||||
printf '#!/bin/sh\necho "%s $*" >> "$CALLS"\nreadlink /proc/self/fd/0 >> "$CALLS"\n' "$c" > "$WORK/bin/$c"
|
||||
chmod 0755 "$WORK/bin/$c"
|
||||
done
|
||||
cp "$WORK/bin/setsid" "$WORK/bin/sh" "$WORK/bin-ctty/"
|
||||
printf '#!/bin/sh\nexit 0\n' > "$WORK/bin-ctty/cttyhack"
|
||||
chmod 0755 "$WORK/bin-ctty/cttyhack"
|
||||
|
||||
# run_case <stub dir> <console active file>: the calls the helper made.
|
||||
# The helper runs with only the stub dir and the host's basic tools on PATH,
|
||||
# so a host cttyhack (none expected) cannot leak in.
|
||||
run_case() {
|
||||
local calls="$WORK/calls.$RANDOM"
|
||||
: > "$calls"
|
||||
# $SH may carry arguments ("busybox sh"): split on purpose.
|
||||
# shellcheck disable=SC2086
|
||||
CALLS="$calls" WARDEN_CONSOLE_ACTIVE="$2" WARDEN_DEV_DIR=/dev \
|
||||
$SH -c ". '$LIB'; PATH='$1':/usr/bin:/bin; warden_console_shell" < /dev/zero > "$WORK/out" 2>&1
|
||||
cat "$calls"
|
||||
}
|
||||
|
||||
printf 'tty1 null\n' > "$WORK/active"
|
||||
got="$(run_case "$WORK/bin-ctty" "$WORK/active")"
|
||||
if [ "$(head -n 1 <<<"$got")" = "setsid cttyhack sh" ]; then
|
||||
pass "with cttyhack: setsid cttyhack sh"
|
||||
else
|
||||
fail "with cttyhack the helper ran: $got"
|
||||
fi
|
||||
|
||||
got="$(run_case "$WORK/bin" "$WORK/active")"
|
||||
if [ "$got" = "$(printf 'setsid -c sh\n/dev/null')" ]; then
|
||||
pass "without cttyhack: setsid -c sh on the last console tty (/dev/null stand-in)"
|
||||
else
|
||||
fail "without cttyhack the helper ran: $got"
|
||||
fi
|
||||
|
||||
got="$(run_case "$WORK/bin" "$WORK/no-such-active")"
|
||||
if [ "$(head -n 1 <<<"$got")" = "sh " ] && grep -q 'no console tty found' "$WORK/out"; then
|
||||
pass "no console tty: says so and runs a plain sh"
|
||||
else
|
||||
fail "with no console tty the helper ran: $got ($(cat "$WORK/out"))"
|
||||
fi
|
||||
|
||||
printf 'ttyNOPE\n' > "$WORK/active-bad"
|
||||
got="$(run_case "$WORK/bin" "$WORK/active-bad")"
|
||||
if [ "$(head -n 1 <<<"$got")" = "sh " ]; then
|
||||
pass "a console name with no device node: plain sh, no setsid -c"
|
||||
else
|
||||
fail "a missing tty node ran: $got"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -ne 0 ]; then
|
||||
echo "console-shell: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "console-shell: all checks passed"
|
||||
@@ -969,6 +969,8 @@ class Ctx:
|
||||
self.input_wait_s = 0.0
|
||||
# Stall probes run so far (STALL_REPORTS_MAX bounds them).
|
||||
self.stall_reports = 0
|
||||
# The UI's test hook answered a ping (hook_wait_ready).
|
||||
self.hook_ready = False
|
||||
|
||||
def need_ctl(self, lineno, cmd):
|
||||
if self.ctl is None:
|
||||
@@ -1200,6 +1202,49 @@ def hook_request(ctl, words, args):
|
||||
return ctl.send(f"@hook {words}")
|
||||
|
||||
|
||||
# The bridge's line for a hook request whose client got no reply (_wcb_hook
|
||||
# in rootfs/etc/warden-lib.sh).
|
||||
HOOK_NO_ANSWER = "bridge: hook request got no answer"
|
||||
# How long the run's first hook request waits for the UI's hook to answer a
|
||||
# ping, and the pause between two pings. Each ping is bounded by the hook
|
||||
# client itself (wthctl: 5 s for the UI).
|
||||
HOOK_READY_S = 90.0
|
||||
HOOK_READY_POLL_S = 1.0
|
||||
|
||||
|
||||
def hook_wait_ready(ctx):
|
||||
"""Wait, once per run, until the UI's test hook answers a `ping` -> None,
|
||||
or the fatal detail when it never did.
|
||||
|
||||
The hook takes requests from the device bus, which the UI drains under a
|
||||
per-tick budget (libwardenbus WBUS_TICK_PACKETS / WBUS_TICK_BUDGET_US).
|
||||
Right after boot it is still taking the broker's retained replay, and a
|
||||
request queued behind it misses both the client's 5 s bound and its own
|
||||
5 s message expiry: an override sent then was lost, or applied with its
|
||||
reply lost (flare-edge #2602). ping changes nothing, so it is the one
|
||||
request that is safe to repeat; the step's own request is sent once,
|
||||
after a ping came back. Replies come back in request order, so a late
|
||||
answer to an earlier ping is gone before that request goes out.
|
||||
|
||||
Anything other than "no answer" ends the wait: a missing client or a
|
||||
reply that is not JSON is reported by the step's own request."""
|
||||
if ctx.hook_ready:
|
||||
return None
|
||||
deadline = time.monotonic() + HOOK_READY_S
|
||||
pings = 0
|
||||
while True:
|
||||
pings += 1
|
||||
reply = hook_request(ctx.ctl, "ping", {})
|
||||
if not reply.startswith(HOOK_NO_ANSWER):
|
||||
break
|
||||
if time.monotonic() >= deadline:
|
||||
return (f"the UI test hook answered no ping in {HOOK_READY_S:.0f} s "
|
||||
f"({pings} sent): {reply}")
|
||||
time.sleep(HOOK_READY_POLL_S)
|
||||
ctx.hook_ready = judge_hook_reply(reply)[0] == "ok"
|
||||
return None
|
||||
|
||||
|
||||
def judge_hook_reply(reply):
|
||||
"""(status, detail) for a hook reply: ok:true passes, ok:false fails with
|
||||
the hook's err, and anything else (a bridge line, no JSON) is fatal: the
|
||||
@@ -1230,6 +1275,9 @@ def verb_override(ctx, lineno, cmd, args, line):
|
||||
return "fatal", f"override document is not JSON: {doc_text!r}"
|
||||
if doc is not None and not isinstance(doc, (dict, list)):
|
||||
return "fatal", "override document must be an object, an array or null"
|
||||
not_ready = hook_wait_ready(ctx)
|
||||
if not_ready:
|
||||
return "fatal", not_ready
|
||||
return judge_hook_reply(hook_request(ctx.ctl, "override", {"topic": topic, "doc": doc}))
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +140,36 @@ if run_case "$argv" --ctl "$SCRATCH/ctl.sock" --rs485 "$SCRATCH/rs.sock"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- case: --agent (the rig agent, flare-edge M9 soak-lite) -> its
|
||||
# pci-serial comes LAST, after ctl and rs485, so neither moves, and
|
||||
# warden.agent lands on the cmdline only with the flag -------------------
|
||||
if ! grep -qw 'warden.agent' "$SCRATCH/argv-both.txt" && ! grep -qF 'id=agent' "$SCRATCH/argv-both.txt"; then
|
||||
pass "no --agent: no agent chardev and no warden.agent"
|
||||
else
|
||||
fail "no --agent: an agent chardev or warden.agent appeared unrequested"
|
||||
fi
|
||||
for combo in "agent-ctl:--ctl $SCRATCH/ctl.sock" "agent-alone:"; do
|
||||
name="${combo%%:*}" extra="${combo#*:}"
|
||||
argv="$SCRATCH/argv-$name.txt"
|
||||
# shellcheck disable=SC2086 # extra is a word list on purpose
|
||||
if run_case "$argv" $extra --rs485 "$SCRATCH/rs.sock" --agent "$SCRATCH/agent.sock"; then
|
||||
ag_ln="$(chardev_line "$argv" "socket,id=agent,path=$SCRATCH/agent.sock,")"
|
||||
rs_ln="$(chardev_line "$argv" "socket,id=rs485,path=$SCRATCH/rs.sock,")"
|
||||
ctl_ln="$(chardev_line "$argv" "socket,id=ctl,")"
|
||||
if [ -n "$ag_ln" ] && [ -n "$rs_ln" ] && [ "$rs_ln" -lt "$ag_ln" ] &&
|
||||
{ [ -z "$ctl_ln" ] || [ "$ctl_ln" -lt "$rs_ln" ]; }; then
|
||||
pass "$name: agent chardev (line $ag_ln) comes after rs485 (line $rs_ln) and ctl (${ctl_ln:-none})"
|
||||
else
|
||||
fail "$name: expected ctl < rs485 < agent, got ctl=$ctl_ln rs485=$rs_ln agent=$ag_ln"
|
||||
fi
|
||||
if grep -qF 'pci-serial,chardev=agent' "$argv" && grep -qw 'warden.agent' "$argv"; then
|
||||
pass "$name: agent pci-serial device and warden.agent present"
|
||||
else
|
||||
fail "$name: agent pci-serial device or warden.agent missing"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
echo "ALL RUN.SH ARGV TESTS PASSED"
|
||||
exit 0
|
||||
|
||||
@@ -892,6 +892,11 @@ class OverrideVerb(unittest.TestCase):
|
||||
HookCtl.sent = []
|
||||
HookCtl.answer = staticmethod(lambda words, args: '{"v":1,"ok":true,"data":{}}')
|
||||
HookCtl.refuse_pieces = False
|
||||
self.ready = (qmp.HOOK_READY_S, qmp.HOOK_READY_POLL_S)
|
||||
qmp.HOOK_READY_S, qmp.HOOK_READY_POLL_S = 0.0, 0.0
|
||||
|
||||
def tearDown(self):
|
||||
qmp.HOOK_READY_S, qmp.HOOK_READY_POLL_S = self.ready
|
||||
|
||||
def test_pin_and_unpin_reach_the_hook_as_one_request_each(self):
|
||||
seen = []
|
||||
@@ -906,6 +911,7 @@ class OverrideVerb(unittest.TestCase):
|
||||
self.assertIsNone(rc, rows)
|
||||
self.assertEqual([r["status"] for r in rows], ["ok", "ok"])
|
||||
self.assertEqual(seen, [
|
||||
("ping", {}),
|
||||
("override", {"topic": "io/state/failsafe",
|
||||
"doc": {"last_trip": {"why": "two words"}, "ack": False}}),
|
||||
("override", {"topic": "io/state/failsafe", "doc": None}),
|
||||
@@ -915,7 +921,8 @@ class OverrideVerb(unittest.TestCase):
|
||||
seen = []
|
||||
|
||||
def answer(words, args):
|
||||
seen.append(args)
|
||||
if words != "ping":
|
||||
seen.append(args)
|
||||
return '{"v":1,"ok":true}'
|
||||
HookCtl.answer = staticmethod(answer)
|
||||
doc = {"rows": ["x" * 100] * 120}
|
||||
@@ -924,7 +931,9 @@ class OverrideVerb(unittest.TestCase):
|
||||
ctl_cls=HookCtl)
|
||||
self.assertEqual(rows[0]["status"], "ok", rows)
|
||||
self.assertEqual(seen, [{"topic": "cfg/state/big", "doc": doc}])
|
||||
pieces = [c for c in HookCtl.sent if c.startswith("@hookdoc")]
|
||||
# The pieces after the readiness ping (which sends {} in one piece).
|
||||
after_ping = HookCtl.sent[HookCtl.sent.index("@hook ping") + 1:]
|
||||
pieces = [c for c in after_ping if c.startswith("@hookdoc")]
|
||||
self.assertGreater(len(pieces), 5)
|
||||
self.assertTrue(pieces[0].startswith("@hookdoc {"))
|
||||
self.assertTrue(all(c.startswith("@hookdoc+ ") for c in pieces[1:]))
|
||||
@@ -947,6 +956,53 @@ class OverrideVerb(unittest.TestCase):
|
||||
rc, by, rows = run_script('override io/state/x {"a":1}\n', ctl_cls=HookCtl)
|
||||
self.assertEqual(rows[0]["status"], "fatal", reply)
|
||||
|
||||
def test_the_first_override_waits_for_the_hook_to_answer_a_ping(self):
|
||||
# flare-edge #2602: right after boot the UI's hook answered nothing
|
||||
# for a while; the override must be sent once, after a ping came back.
|
||||
qmp.HOOK_READY_S = 60.0
|
||||
seen = []
|
||||
lost = [2]
|
||||
|
||||
def answer(words, args):
|
||||
seen.append(words)
|
||||
if words == "ping" and lost[0]:
|
||||
lost[0] -= 1
|
||||
return "bridge: hook request got no answer (client exit 2): wthctl: no reply (-5)"
|
||||
return '{"v":1,"ok":true,"data":{}}'
|
||||
HookCtl.answer = staticmethod(answer)
|
||||
rc, by, rows = run_script(
|
||||
'override io/state/failsafe {"a":1}\n'
|
||||
"override io/state/failsafe null\n", ctl_cls=HookCtl)
|
||||
self.assertIsNone(rc, rows)
|
||||
self.assertEqual([r["status"] for r in rows], ["ok", "ok"])
|
||||
self.assertEqual(seen, ["ping", "ping", "ping", "override", "override"])
|
||||
|
||||
def test_a_hook_that_never_answers_a_ping_is_fatal_and_gets_no_override(self):
|
||||
HookCtl.answer = staticmethod(lambda words, args: (
|
||||
"bridge: hook request got no answer (client exit 2): wthctl: no reply (-5)"))
|
||||
rc, by, rows = run_script('override io/state/x {"a":1}\nwake\n', ctl_cls=HookCtl)
|
||||
self.assertEqual([r["status"] for r in rows], ["fatal", "ok"])
|
||||
self.assertIn("answered no ping", rows[0]["detail"])
|
||||
self.assertIn("@hook ping", HookCtl.sent)
|
||||
self.assertNotIn("@hook override", HookCtl.sent)
|
||||
|
||||
def test_a_ping_that_is_not_ok_leaves_the_verdict_to_the_override(self):
|
||||
# A hook that answers but refuses ping (an older hook) is still a
|
||||
# hook: the override goes out and its own reply is judged, and the
|
||||
# next override pings again rather than trusting it.
|
||||
seen = []
|
||||
|
||||
def answer(words, args):
|
||||
seen.append(words)
|
||||
if words == "ping":
|
||||
return '{"v":1,"ok":false,"err":{"code":"E_UNKNOWN_VERB"}}'
|
||||
return '{"v":1,"ok":true}'
|
||||
HookCtl.answer = staticmethod(answer)
|
||||
rc, by, rows = run_script(
|
||||
'override io/state/x {"a":1}\noverride io/state/x null\n', ctl_cls=HookCtl)
|
||||
self.assertEqual([r["status"] for r in rows], ["ok", "ok"])
|
||||
self.assertEqual(seen, ["ping", "override", "ping", "override"])
|
||||
|
||||
def test_a_refused_piece_is_fatal_for_the_step_only(self):
|
||||
HookCtl.refuse_pieces = True
|
||||
rc, by, rows = run_script('override io/state/x {"a":1}\nwake\n', ctl_cls=HookCtl)
|
||||
|
||||
Executable
+109
@@ -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
@@ -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"
|
||||
@@ -41,6 +41,9 @@ scripts=(
|
||||
"tests/mk-bootimg/run-boot-img-validate-tests.sh"
|
||||
"tests/mk-bootimg/run-help-tests.sh"
|
||||
"tests/mk-bootimg/run-ci-wiring-tests.sh"
|
||||
"qemu/tests/busybox-panel-test.sh"
|
||||
"qemu/tests/busybox-panel-help.sh"
|
||||
"qemu/tests/console-shell-test.sh"
|
||||
)
|
||||
|
||||
fail=0
|
||||
|
||||
Reference in New Issue
Block a user