Skip to content

target/arm: Fix timer deadlines when the offset puts the count ahead

Fuad Tabba qemu-arm qemu-devel 1 version Applied

Status from this message: Applied to target-arm.next, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2target/arm: Fix next timer tick when the offset puts the count aheadtarget/arm/helper.c tests/tcg/aarch64/system/vtimer.c+33 -40 replies
2/2target/arm: Fix WFxT timeouts when the offset puts the count aheadtarget/arm/tcg/op_helper.c tests/tcg/aarch64/system/meson.build tests/tcg/aarch64/system/wfxt.c+129 -22 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] target/arm: Fix timer deadlines when the offset puts the count ahead

Hi folks,

Two fixes for the same bug in three places: the next-tick calculation for the generic timers, WFIT and WFET each treat a 64-bit overflow of cval + offset (or timeout + offset) as a deadline beyond the counter's wrap. Once CNTVOFF_EL2 (or CNTPOFF_EL2 for the physical timer) puts the timer's view of the counter ahead of the physical count, that sum overflows for every deadline still in the future and QEMU arms the timer at INT64_MAX. The first site regressed in 8.2 (8d37a1425b99). The WFxT sites have the same overflow test.

The KVM arch_timer_edge_cases selftest, which sets the guest counter to 2^59 - 1, hangs in every host mode on QEMU 11.0.0 and passes on hardware under an nVHE host. With patch 1 it completes under nVHE and pKVM hosts. Under a VHE host its physical-timer half still stops, on a KVM bug in the same arithmetic (KVM programs cval + offset where the timer compares unsigned). That fix goes to kvmarm separately.

Each patch adds a tcg system test that fails before it and passes after.

Based on master (3b5d71cc36).

Cheers,
/fuad

Fuad Tabba (2):
target/arm: Fix next timer tick when the offset puts the count ahead target/arm: Fix WFxT timeouts when the offset puts the count ahead

 target/arm/helper.c                  |   9 +-
 target/arm/tcg/op_helper.c           |   6 +-
 tests/tcg/aarch64/system/meson.build |   7 ++
 tests/tcg/aarch64/system/vtimer.c    |  28 +++++++
 tests/tcg/aarch64/system/wfxt.c      | 118 +++++++++++++++++++++++++++
 5 files changed, 162 insertions(+), 6 deletions(-)
 create mode 100644 tests/tcg/aarch64/system/wfxt.c
Signature · 1 line
2.39.5