ci / test (push) Successful in 31s
ci / bench (push) Successful in 14s
ci / mcdc (push) Successful in 26s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 1m18s
ci / badges (push) Skipped
ci / bench (pull_request) Successful in 10s
ci / patches-apply (push) Successful in 52s
ci / qemu-tools (push) Successful in 3m26s
ci / kernel-symbols (push) Successful in 5m12s
ci / test (pull_request) Successful in 8s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / badges (pull_request) Skipped
ci / qemu-tools (pull_request) Successful in 2m59s
ci / mcdc (pull_request) Successful in 19s
ci / patches-apply (pull_request) Successful in 52s
ci / quality (pull_request) Successful in 1m15s
ci / kernel-symbols (pull_request) Successful in 6m57s
On the RV1106 the boot firmware does not enter the kernel in HYP mode and leaves CNTVOFF non-zero. The DT timer node lists no virtual-timer PPI, so the kernel keeps time on the physical counter, while the arm32 vDSO always reads the virtual one: on bench a clock_gettime() ran 738.9 s ahead of the kernel clock (pure offset, -0.1 ppm over 30 s) and every absolute deadline taken from it expired minutes late (flare-edge#2319, the #2311 reset loop). New patch 82-arch-timer-vdso-phys-counter.patch: - rv1106.dtsi and rv1106-warden-m2.dts: the timer node carries arm,cpu-registers-not-fw-configured. The kernel keeps the physical timer it uses today, and arch/arm/kernel/vdso.c drops the vDSO clock symbols, so libc goes straight to the syscall. - arm_arch_timer.c: on arm32, a kernel on the physical counter without HYP mode sets the counter's vdso_clock_mode to VDSO_CLOCKMODE_NONE, the safety net for a device tree without the property. QEMU -M virt (virtual PPI present) is unchanged. tests/arch-timer/check-vdso-counter.py checks both guards in the patched tree; CI's patches-apply job runs it and its 12 regression cases. Fixes #35 Refs flare-edge#2319 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
63 lines
2.9 KiB
Diff
63 lines
2.9 KiB
Diff
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);
|