On Mon, 2 Nov 2026 at 10:27, Lorand Marton <[email protected]> wrote: > > bcm2835_systmr_reset() cleared the match bits and the compare > registers, but a channel whose match had raised its interrupt kept the > line raised, and a compare armed before the reset still fired after > it, setting its match bit and raising the interrupt in a guest that > had not armed it. Both happen when a guest reboots with a system timer > channel in use (the firmware or a bare-metal guest's tick). > > Delete the timers and lower the interrupts in the reset, as the > register values now say. > > Test that a reset drops a raised channel and that a compare set before > it does not fire. > > Fixes: be95dffa326a ("hw/timer/bcm2835: Support the timer COMPARE registers") > Signed-off-by: Lorand Marton <[email protected]> > --- > hw/timer/bcm2835_systmr.c | 4 +++ > tests/qtest/bcm2835-systmr-test.c | 54 +++++++++++++++++++++++++++++++ > tests/qtest/meson.build | 2 +- > 3 files changed, 59 insertions(+), 1 deletion(-) > create mode 100644 tests/qtest/bcm2835-systmr-test.c > > diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c > index 06a919b1f8..3c03c98193 100644 > --- a/hw/timer/bcm2835_systmr.c > +++ b/hw/timer/bcm2835_systmr.c > @@ -123,6 +123,10 @@ static void bcm2835_systmr_reset(DeviceState *dev) > BCM2835SystemTimerState *s = BCM2835_SYSTIMER(dev); > > memset(&s->reg, 0, sizeof(s->reg)); > + for (size_t i = 0; i < ARRAY_SIZE(s->tmr); i++) { > + timer_del(&s->tmr[i].timer); > + qemu_set_irq(s->tmr[i].irq, 0); > + } > }
The timer_del() is correct, the qemu_set_irq() is not. -- PMM
