qemu/target/arm
Peter Maydell 49727560c7 target/arm: Handle overflow in calculation of next timer tick
In commit edac4d8a16 back in 2015 when we added support for
the virtual timer offset CNTVOFF_EL2, we didn't correctly update
the timer-recalculation code that figures out when the timer
interrupt is next going to change state. We got it wrong in
two ways:
 * for the 0->1 transition, we didn't notice that gt->cval + offset
   can overflow a uint64_t
 * for the 1->0 transition, we didn't notice that the transition
   might now happen before the count rolls over, if offset > count

In the former case, we end up trying to set the next interrupt
for a time in the past, which results in QEMU hanging as the
timer fires continuously.

In the latter case, we would fail to update the interrupt
status when we are supposed to.

Fix the calculations in both cases.

The test case is Alex Bennée's from the bug report, and tests
the 0->1 transition overflow case.

Fixes: edac4d8a16 ("target-arm: Add CNTVOFF_EL2")
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/60
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20231120173506.3729884-1-peter.maydell@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 8d37a1425b9954d7e445615dcad23456515e24c0)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-12-05 12:32:36 +03:00
..
hvf
tcg target/arm: Fix SME FMOPA (16-bit), BFMOPA 2023-11-22 14:25:22 +03:00
arch_dump.c
arm-powerctl.c
arm-powerctl.h
arm-qmp-cmds.c
common-semi-target.h
cortex-regs.c
cpregs.h
cpu-param.h
cpu-qom.h
cpu.c arm: spelling fixes 2023-07-25 17:13:53 +03:00
cpu.h arm: spelling fixes 2023-07-25 17:13:53 +03:00
cpu64.c arm: spelling fixes 2023-07-25 17:13:53 +03:00
debug_helper.c target/arm: Special case M-profile in debug_helper.c code 2023-07-25 10:56:51 +01:00
gdbstub.c
gdbstub64.c
helper.c target/arm: Handle overflow in calculation of next timer tick 2023-12-05 12:32:36 +03:00
helper.h
hvf_arm.h
hyp_gdbstub.c
idau.h
internals.h target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk 2023-11-09 16:39:13 +03:00
Kconfig
kvm-consts.h
kvm-stub.c
kvm.c accel/kvm: Specify default IPA size for arm64 2023-08-24 18:45:44 +03:00
kvm64.c arm64: Restore trapless ptimer access 2023-09-21 19:35:19 +03:00
kvm_arm.h
machine.c
meson.build
op_addsub.h
ptw.c target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk 2023-11-09 16:39:13 +03:00
syndrome.h target/arm: Set IL bit for pauth, SVE access, BTI trap syndromes 2023-12-05 12:32:36 +03:00
tcg-stubs.c
trace-events
trace.h
vfp_helper.c