On bench a the vDSO CLOCK_MONOTONIC runs 738.9 s ahead of the kernel clock. The skew is a fixed offset: it moved -0.1 ppm over 30 s (flare-edge tools/bench/clock-skew, image 9462). Every absolute deadline taken from the vDSO, such as std's Condvar::wait_timeout or pthread_cond_timedwait, therefore expires minutes late (flare-edge#2319 and the #2311 reset loop).
Cause: the RV1106 timer node lists only the secure and non-secure physical PPIs (13, 14) and has no virtual-timer PPI. The firmware does not enter the kernel in HYP mode, so arch_timer_select_ppi() puts the kernel on the physical counter, and nothing zeroes CNTVOFF. The arm32 vDSO always reads the virtual counter.
Change
New patch patches/82-arch-timer-vdso-phys-counter.patch. It applies after 20, because it edits two DTS files that patch 20 adds.
rv1106.dtsi and rv1106-warden-m2.dts: the timer node now carries arm,cpu-registers-not-fw-configured. This is the upstream binding for firmware that leaves the timer registers unset.
The arch timer stays on ARCH_TIMER_PHYS_SECURE_PPI, as it is today.
arch/arm/kernel/vdso.ccntvct_functional() now returns false, so the vDSO drops __vdso_clock_gettime, __vdso_clock_gettime64, __vdso_gettimeofday and __vdso_clock_getres. libc then goes straight to the syscall, which costs about 1 us per call.
drivers/clocksource/arm_arch_timer.carch_counter_register(): this is the safety net for a device tree without the property. On arm32, a kernel on the physical counter that was not entered in HYP mode sets vdso_clock_mode = VDSO_CLOCKMODE_NONE and logs arch_timer: physical counter without HYP: vDSO clock disabled.
With HYP mode, the hyp stub zeroes CNTVOFF (hyp-stub.S), so nothing changes there.
QEMU -M virt has a virtual PPI, so it is unchanged too.
tests/arch-timer/check-vdso-counter.py checks both guards in the patched tree. CI's patches-apply job runs it on the real tree, together with its 12 regression cases (run-check-vdso-counter-tests.sh).
patches/README.md: a series table row, and the "applies in order" wording.
Option 2 of #35 (the boot firmware zeroes CNTVOFF, which keeps the fast vDSO) is not part of this PR. It is optional once this lands.
Local gate
Regression cases on bfe-mpc-0056 (lane-remote LN <worktree> -- bash tests/arch-timer/run-check-vdso-counter-tests.sh):
PASS: fixed tree passes
PASS: timer node without the property fails
PASS: property only inside a comment fails
PASS: property only in a child node fails
PASS: timer node with a virtual PPI needs no property
PASS: missing arm32 fallback fails
PASS: fallback that does not set VDSO_CLOCKMODE_NONE fails
PASS: fallback before the vdso_default assignment fails
PASS: no timer node at all fails
PASS: a second board DTS without the property fails
PASS: missing arm_arch_timer.c fails
PASS: no argument is a usage error
check-vdso-counter: all 12 passed
The checker on the real tree (pristine 6.18.46 plus the series), with and without patch 82:
vdso-counter: ok (DT property and arm32 physical-counter fallback present)
after rc=0
FAIL: arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts: timer node has no virtual-timer PPI and no arm,cpu-registers-not-fw-configured
FAIL: arch/arm/boot/dts/rockchip/rv1106.dtsi: timer node has no virtual-timer PPI and no arm,cpu-registers-not-fw-configured
FAIL: drivers/clocksource/arm_arch_timer.c: arch_counter_register() lacks the arm32 physical-counter vDSO fallback (vdso_clock_mode = VDSO_CLOCKMODE_NONE)
before rc=1
Full kernel build: build/build-kernel.sh, CROSS_COMPILE=arm-linux-gnueabihf-, JOBS=4, aic8800 modules collected, run under the SDK build lock.
== collected 3 module(s) from drivers/net/wireless/aic8800
final.config sha256: d06991e697282228c7583a20438634f89582a2818b79abc93951a9933561e6cd
== build OK
.config has CONFIG_VDSO=y CONFIG_ARM_ARCH_TIMER=y CONFIG_ARM_VIRT_EXT=y.
shellcheck is clean, and the prose scan reports 0 findings.
Bench acceptance (follows)
A kernel-only boot.img cannot be packed on the workstation, because resource_tool comes from the vendor SDK. The bench proof therefore runs from a flare-edge firmware image built with this SDK. The flare-edge branch rb/w31-sdk-vdso-pin (c3dbb2fa) pins vendor/warden-sdk to this branch's head b4596ed.
The acceptance check is flare-edge tools/bench/clock-skew/run.sh --rate-s 30 on that image. It expects vdso_skew_ms under 1, wait_abs_vdso ok and verdict=PASS. Before this change, image 9462 gave vdso_skew_ms=738925.463, wait_abs_vdso=5010 hang and verdict=FAIL. The result will be posted here and on flare-edge#2319.
Fixes #35. Refs flare-edge#2319.
## What was wrong
On bench a the vDSO `CLOCK_MONOTONIC` runs 738.9 s ahead of the kernel clock. The skew is a fixed offset: it moved -0.1 ppm over 30 s (flare-edge `tools/bench/clock-skew`, image 9462). Every absolute deadline taken from the vDSO, such as std's `Condvar::wait_timeout` or `pthread_cond_timedwait`, therefore expires minutes late (flare-edge#2319 and the #2311 reset loop).
Cause: the RV1106 timer node lists only the secure and non-secure physical PPIs (13, 14) and has no virtual-timer PPI. The firmware does not enter the kernel in HYP mode, so `arch_timer_select_ppi()` puts the kernel on the physical counter, and nothing zeroes CNTVOFF. The arm32 vDSO always reads the virtual counter.
## Change
New patch `patches/82-arch-timer-vdso-phys-counter.patch`. It applies after 20, because it edits two DTS files that patch 20 adds.
- `rv1106.dtsi` and `rv1106-warden-m2.dts`: the timer node now carries `arm,cpu-registers-not-fw-configured`. This is the upstream binding for firmware that leaves the timer registers unset.
- The arch timer stays on `ARCH_TIMER_PHYS_SECURE_PPI`, as it is today.
- `arch/arm/kernel/vdso.c` `cntvct_functional()` now returns false, so the vDSO drops `__vdso_clock_gettime`, `__vdso_clock_gettime64`, `__vdso_gettimeofday` and `__vdso_clock_getres`. libc then goes straight to the syscall, which costs about 1 us per call.
- `drivers/clocksource/arm_arch_timer.c` `arch_counter_register()`: this is the safety net for a device tree without the property. On arm32, a kernel on the physical counter that was not entered in HYP mode sets `vdso_clock_mode = VDSO_CLOCKMODE_NONE` and logs `arch_timer: physical counter without HYP: vDSO clock disabled`.
- With HYP mode, the hyp stub zeroes CNTVOFF (`hyp-stub.S`), so nothing changes there.
- QEMU `-M virt` has a virtual PPI, so it is unchanged too.
- `tests/arch-timer/check-vdso-counter.py` checks both guards in the patched tree. CI's patches-apply job runs it on the real tree, together with its 12 regression cases (`run-check-vdso-counter-tests.sh`).
- `patches/README.md`: a series table row, and the "applies in order" wording.
Option 2 of #35 (the boot firmware zeroes CNTVOFF, which keeps the fast vDSO) is not part of this PR. It is optional once this lands.
## Local gate
Regression cases on bfe-mpc-0056 (`lane-remote LN <worktree> -- bash tests/arch-timer/run-check-vdso-counter-tests.sh`):
```
PASS: fixed tree passes
PASS: timer node without the property fails
PASS: property only inside a comment fails
PASS: property only in a child node fails
PASS: timer node with a virtual PPI needs no property
PASS: missing arm32 fallback fails
PASS: fallback that does not set VDSO_CLOCKMODE_NONE fails
PASS: fallback before the vdso_default assignment fails
PASS: no timer node at all fails
PASS: a second board DTS without the property fails
PASS: missing arm_arch_timer.c fails
PASS: no argument is a usage error
check-vdso-counter: all 12 passed
```
The checker on the real tree (pristine 6.18.46 plus the series), with and without patch 82:
```
vdso-counter: ok (DT property and arm32 physical-counter fallback present)
after rc=0
FAIL: arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts: timer node has no virtual-timer PPI and no arm,cpu-registers-not-fw-configured
FAIL: arch/arm/boot/dts/rockchip/rv1106.dtsi: timer node has no virtual-timer PPI and no arm,cpu-registers-not-fw-configured
FAIL: drivers/clocksource/arm_arch_timer.c: arch_counter_register() lacks the arm32 physical-counter vDSO fallback (vdso_clock_mode = VDSO_CLOCKMODE_NONE)
before rc=1
```
Full kernel build: `build/build-kernel.sh`, `CROSS_COMPILE=arm-linux-gnueabihf-`, `JOBS=4`, aic8800 modules collected, run under the SDK build lock.
```
== collected 3 module(s) from drivers/net/wireless/aic8800
final.config sha256: d06991e697282228c7583a20438634f89582a2818b79abc93951a9933561e6cd
== build OK
```
The built tree was checked as follows:
- `fdtget -p rv1106-warden.dtb /timer` lists `compatible interrupts clock-frequency arm,cpu-registers-not-fw-configured`.
- `vmlinux` contains the fallback message.
- `.config` has `CONFIG_VDSO=y CONFIG_ARM_ARCH_TIMER=y CONFIG_ARM_VIRT_EXT=y`.
`shellcheck` is clean, and the prose scan reports 0 findings.
## Bench acceptance (follows)
A kernel-only `boot.img` cannot be packed on the workstation, because `resource_tool` comes from the vendor SDK. The bench proof therefore runs from a flare-edge firmware image built with this SDK. The flare-edge branch `rb/w31-sdk-vdso-pin` (c3dbb2fa) pins `vendor/warden-sdk` to this branch's head b4596ed.
The acceptance check is flare-edge `tools/bench/clock-skew/run.sh --rate-s 30` on that image. It expects `vdso_skew_ms` under 1, `wait_abs_vdso` ok and `verdict=PASS`. Before this change, image 9462 gave `vdso_skew_ms=738925.463`, `wait_abs_vdso=5010 hang` and `verdict=FAIL`. The result will be posted here and on flare-edge#2319.
Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
On the RV1106 the boot firmware does not enter the kernel in HYP mode and
leaves CNTVOFF non-zero. The DT timer node lists no virtual-timer PPI, so
the kernel keeps time on the physical counter, while the arm32 vDSO always
reads the virtual one: on bench a clock_gettime() ran 738.9 s ahead of the
kernel clock (pure offset, -0.1 ppm over 30 s) and every absolute deadline
taken from it expired minutes late (flare-edge#2319, the #2311 reset loop).
New patch 82-arch-timer-vdso-phys-counter.patch:
- rv1106.dtsi and rv1106-warden-m2.dts: the timer node carries
arm,cpu-registers-not-fw-configured. The kernel keeps the physical
timer it uses today, and arch/arm/kernel/vdso.c drops the vDSO clock
symbols, so libc goes straight to the syscall.
- arm_arch_timer.c: on arm32, a kernel on the physical counter without
HYP mode sets the counter's vdso_clock_mode to VDSO_CLOCKMODE_NONE, the
safety net for a device tree without the property. QEMU -M virt (virtual
PPI present) is unchanged.
tests/arch-timer/check-vdso-counter.py checks both guards in the patched
tree; CI's patches-apply job runs it and its 12 regression cases.
Fixes#35
Refs flare-edge#2319
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
Bench result for the arm32 vDSO counter fix (lane LN, 2026-10-29 11:33-12:02Z, under a FLASH lock on bench a).
Image: run 9545 firmware-rv1106-test-dev-insecure (flare-edge rb/w31-sdk-vdso-pin c3dbb2f, SDK b4596ed), written with tools/bench-flash-slot.sh to the inactive slot _a (read-back sha256 matched for boot, oem, rootfs), armed with 3 tries, NOT marked good.
Kernel log on _a:
arch_timer: cp15 timer running at 24.00MHz (phys).
arch_timer: physical counter without HYP: vDSO clock disabled
clocksource: Switched to clocksource arch_sys_counter
clock-skew (tools/bench/clock-skew/run.sh, clockskew from 15620f47, --rate-s 30), 33 s after boot:
image: VERSION=0.17.79-rc BUILD_DATE=2026-10-29 GIT_COMMIT=c3dbb2f FLAVOR=test WIFI_EAP=0 KERNEL=6.18.46 KCONFIG_SHA256=7de6e4896da603e0993db36a261796abbb040fd6ac3733a39d163762e4fda27f SDK=/home/noah/projects/flare-edge/sdk
clockskew: vdso_symbol=absent
clockskew: kernel_ns=32973263139
clockskew: vdso_ns=absent
clockskew: libc_ns=32973267222
clockskew: uptime_s=32.97
clockskew: vdso_rate_ppm=skipped no vdso clock
clockskew: libc_skew_ms=0.000
clockskew: wait_relative=1006 ok
clockskew: wait_abs_kernel=1008 ok
clockskew: wait_abs_vdso=skipped no vdso clock
clockskew: verdict=PASS
Before the fix (same panel, image 9462 on _b): vdso_skew_ms=738925.463, wait_abs_vdso=5010 hang, verdict FAIL. With the fix the vDSO clock_gettime symbol is gone (arm32 vdso_nullpatch when the clock mode is NONE), libc falls back to the syscall, libc_skew_ms is 0 and every timed wait returns on time: verdict PASS.
The panel was then put back on _b (9d03840, B pri 15 confirmed; A pri 14, 2 tries left, not successful), rebooted, and checked healthy: slot _b, uptime 796 s with no reset, mosquitto, warden-io, warden-modbus, appd, warden-automation, warden-flared, warden-ui and warden-telemetry running with unchanged PIDs. Lock released 12:03Z.
Bench result for the arm32 vDSO counter fix (lane LN, 2026-10-29 11:33-12:02Z, under a FLASH lock on bench a).
Image: run 9545 firmware-rv1106-test-dev-insecure (flare-edge rb/w31-sdk-vdso-pin c3dbb2f, SDK b4596ed), written with tools/bench-flash-slot.sh to the inactive slot _a (read-back sha256 matched for boot, oem, rootfs), armed with 3 tries, NOT marked good.
Kernel log on _a:
```
arch_timer: cp15 timer running at 24.00MHz (phys).
arch_timer: physical counter without HYP: vDSO clock disabled
clocksource: Switched to clocksource arch_sys_counter
```
clock-skew (tools/bench/clock-skew/run.sh, clockskew from 15620f47, --rate-s 30), 33 s after boot:
```
image: VERSION=0.17.79-rc BUILD_DATE=2026-10-29 GIT_COMMIT=c3dbb2f FLAVOR=test WIFI_EAP=0 KERNEL=6.18.46 KCONFIG_SHA256=7de6e4896da603e0993db36a261796abbb040fd6ac3733a39d163762e4fda27f SDK=/home/noah/projects/flare-edge/sdk
clockskew: vdso_symbol=absent
clockskew: kernel_ns=32973263139
clockskew: vdso_ns=absent
clockskew: libc_ns=32973267222
clockskew: uptime_s=32.97
clockskew: vdso_rate_ppm=skipped no vdso clock
clockskew: libc_skew_ms=0.000
clockskew: wait_relative=1006 ok
clockskew: wait_abs_kernel=1008 ok
clockskew: wait_abs_vdso=skipped no vdso clock
clockskew: verdict=PASS
```
Again at 699 s uptime:
```
clockskew: uptime_s=698.57
clockskew: libc_skew_ms=-0.000
clockskew: verdict=PASS
```
Before the fix (same panel, image 9462 on _b): vdso_skew_ms=738925.463, wait_abs_vdso=5010 hang, verdict FAIL. With the fix the vDSO clock_gettime symbol is gone (arm32 vdso_nullpatch when the clock mode is NONE), libc falls back to the syscall, libc_skew_ms is 0 and every timed wait returns on time: verdict PASS.
The panel was then put back on _b (9d03840, B pri 15 confirmed; A pri 14, 2 tries left, not successful), rebooted, and checked healthy: slot _b, uptime 796 s with no reset, mosquitto, warden-io, warden-modbus, appd, warden-automation, warden-flared, warden-ui and warden-telemetry running with unchanged PIDs. Lock released 12:03Z.
noah
merged commit 4d30c3083b into rebuild2026-10-29 06:05:11 -06:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #35. Refs flare-edge#2319.
What was wrong
On bench a the vDSO
CLOCK_MONOTONICruns 738.9 s ahead of the kernel clock. The skew is a fixed offset: it moved -0.1 ppm over 30 s (flare-edgetools/bench/clock-skew, image 9462). Every absolute deadline taken from the vDSO, such as std'sCondvar::wait_timeoutorpthread_cond_timedwait, therefore expires minutes late (flare-edge#2319 and the #2311 reset loop).Cause: the RV1106 timer node lists only the secure and non-secure physical PPIs (13, 14) and has no virtual-timer PPI. The firmware does not enter the kernel in HYP mode, so
arch_timer_select_ppi()puts the kernel on the physical counter, and nothing zeroes CNTVOFF. The arm32 vDSO always reads the virtual counter.Change
New patch
patches/82-arch-timer-vdso-phys-counter.patch. It applies after 20, because it edits two DTS files that patch 20 adds.rv1106.dtsiandrv1106-warden-m2.dts: the timer node now carriesarm,cpu-registers-not-fw-configured. This is the upstream binding for firmware that leaves the timer registers unset.ARCH_TIMER_PHYS_SECURE_PPI, as it is today.arch/arm/kernel/vdso.ccntvct_functional()now returns false, so the vDSO drops__vdso_clock_gettime,__vdso_clock_gettime64,__vdso_gettimeofdayand__vdso_clock_getres. libc then goes straight to the syscall, which costs about 1 us per call.drivers/clocksource/arm_arch_timer.carch_counter_register(): this is the safety net for a device tree without the property. On arm32, a kernel on the physical counter that was not entered in HYP mode setsvdso_clock_mode = VDSO_CLOCKMODE_NONEand logsarch_timer: physical counter without HYP: vDSO clock disabled.hyp-stub.S), so nothing changes there.-M virthas a virtual PPI, so it is unchanged too.tests/arch-timer/check-vdso-counter.pychecks both guards in the patched tree. CI's patches-apply job runs it on the real tree, together with its 12 regression cases (run-check-vdso-counter-tests.sh).patches/README.md: a series table row, and the "applies in order" wording.Option 2 of #35 (the boot firmware zeroes CNTVOFF, which keeps the fast vDSO) is not part of this PR. It is optional once this lands.
Local gate
Regression cases on bfe-mpc-0056 (
lane-remote LN <worktree> -- bash tests/arch-timer/run-check-vdso-counter-tests.sh):The checker on the real tree (pristine 6.18.46 plus the series), with and without patch 82:
Full kernel build:
build/build-kernel.sh,CROSS_COMPILE=arm-linux-gnueabihf-,JOBS=4, aic8800 modules collected, run under the SDK build lock.The built tree was checked as follows:
fdtget -p rv1106-warden.dtb /timerlistscompatible interrupts clock-frequency arm,cpu-registers-not-fw-configured.vmlinuxcontains the fallback message..confighasCONFIG_VDSO=y CONFIG_ARM_ARCH_TIMER=y CONFIG_ARM_VIRT_EXT=y.shellcheckis clean, and the prose scan reports 0 findings.Bench acceptance (follows)
A kernel-only
boot.imgcannot be packed on the workstation, becauseresource_toolcomes from the vendor SDK. The bench proof therefore runs from a flare-edge firmware image built with this SDK. The flare-edge branchrb/w31-sdk-vdso-pin(c3dbb2fa) pinsvendor/warden-sdkto this branch's headb4596ed.The acceptance check is flare-edge
tools/bench/clock-skew/run.sh --rate-s 30on that image. It expectsvdso_skew_msunder 1,wait_abs_vdsook andverdict=PASS. Before this change, image 9462 gavevdso_skew_ms=738925.463,wait_abs_vdso=5010 hangandverdict=FAIL. The result will be posted here and on flare-edge#2319.Generated with Claude Code
https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
Bench result for the arm32 vDSO counter fix (lane LN, 2026-10-29 11:33-12:02Z, under a FLASH lock on bench a).
Image: run 9545 firmware-rv1106-test-dev-insecure (flare-edge rb/w31-sdk-vdso-pin c3dbb2f, SDK
b4596ed), written with tools/bench-flash-slot.sh to the inactive slot _a (read-back sha256 matched for boot, oem, rootfs), armed with 3 tries, NOT marked good.Kernel log on _a:
clock-skew (tools/bench/clock-skew/run.sh, clockskew from 15620f47, --rate-s 30), 33 s after boot:
Again at 699 s uptime:
Before the fix (same panel, image 9462 on _b): vdso_skew_ms=738925.463, wait_abs_vdso=5010 hang, verdict FAIL. With the fix the vDSO clock_gettime symbol is gone (arm32 vdso_nullpatch when the clock mode is NONE), libc falls back to the syscall, libc_skew_ms is 0 and every timed wait returns on time: verdict PASS.
The panel was then put back on _b (9d03840, B pri 15 confirmed; A pri 14, 2 tries left, not successful), rebooted, and checked healthy: slot _b, uptime 796 s with no reset, mosquitto, warden-io, warden-modbus, appd, warden-automation, warden-flared, warden-ui and warden-telemetry running with unchanged PIDs. Lock released 12:03Z.