qemu_cortex_a9: system time freezes under sustained interrupt-masked busy-wait (kernel.timer.starve hang)
priority: mediumarea: Timer
## Describe the bug
Running `kernel.timer.starve` (now enabled in normal CI by #114335, previously hidden behind `--enable-slow`) hangs on `qemu_cortex_a9/xc7z007s`: between roughly 60 s and 90 s of uptime the CPU ends up spinning inside `arch_busy_wait()` with the Cortex-A9 global timer count no longer advancing from the guest's point of view. Kernel time freezes and the harness times the test out (400 s).
The test's workload is a repeating cycle of a `k_timer` restart followed by a 100 ms busy-wait executed with interrupts masked behind a spinlock.
## Not a timer-subsystem regression
The hang reproduces identically (3/3 twister runs) with the entire generic timer core series (#112959) reverted, i.e. with the pre-conversion `arm_arch_timer` driver, so it is a long-standing platform problem that predates recent timer work.
## Reproducibility is timing-sensitive
- Under the twister harness: fails ~5/5 (both with and without the timer series).
- Same image run standalone (`qemu-system-xilinx-aarch64` with a file chardev serial): passes.
- Same image with a diagnostic probe compiled into `arch_busy_wait()`: passes, including under twister.
The platform runs the Xilinx QEMU fork (`-machine arm-generic-fdt-7series`, boot via `-device loader`, `-icount shift=3,align=off,sleep=on` — `sleep=on` couples virtual time to the wall clock, so host scheduling perturbs guest timing).
## Observations from a frozen instance
- PC samples via the QEMU monitor land exclusively in the `arch_busy_wait()` 64-bit counter read sequence (the upper/lower/upper consistency loop of the A9 global timer at PERIPHBASE+0x200).
- The counter runs at 111,111,111 Hz on this platform; 2^32 cycles is ~38.7 s and the observed freeze window (after the 60 s mark, before 91 s) brackets 2×2^32 ≈ 77.3 s.
- This is the only Zephyr platform exercising the `CONFIG_ARM_ARCH_TIMER_ERRATUM_740657` path (A9 global timer comparator erratum).
Suspect area: the A9 global timer model in the Xilinx QEMU fork interacting with the driver's comparator/control read-modify-write sequences under wall-clock-coupled icount, possibly around a 2^32 boundary of the 64-bit count.
## To reproduce
```
west twister -p qemu_cortex_a9/xc7z007s -s kernel.timer.starve
```
(remove the `platform_exclude` for `qemu_cortex_a9/xc7z007s` in `tests/kernel/timer/timer_starve/tests.yaml` first).
## Environment
- Zephyr: main (v4.4.0-91xx)
- Zephyr SDK 1.0.1 hosttools `qemu-system-xilinx-aarch64`
- Host: Linux x86_64
The exclusion in `tests/kernel/timer/timer_starve/tests.yaml` should be lifted once this is resolved.
1 条评论