]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: arm64: timer: Always evaluate the need for a soft timer
authorMarc Zyngier <maz@kernel.org>
Tue, 4 Feb 2025 11:00:48 +0000 (11:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Feb 2025 09:05:05 +0000 (10:05 +0100)
commitde3ffeb2122ea45c3499b339496716a295760a72
tree096f5fe43a60a9ffa3233a56b7aeff0b167af54e
parente5251ae5d3c0ad53451c53541a874b2e6396e321
KVM: arm64: timer: Always evaluate the need for a soft timer

commit b450dcce93bc2cf6d2bfaf5a0de88a94ebad8f89 upstream.

When updating the interrupt state for an emulated timer, we return
early and skip the setup of a soft timer that runs in parallel
with the guest.

While this is OK if we have set the interrupt pending, it is pretty
wrong if the guest moved CVAL into the future.  In that case,
no timer is armed and the guest can wait for a very long time
(it will take a full put/load cycle for the situation to resolve).

This is specially visible with EDK2 running at EL2, but still
using the EL1 virtual timer, which in that case is fully emulated.
Any key-press takes ages to be captured, as there is no UART
interrupt and EDK2 relies on polling from a timer...

The fix is simply to drop the early return. If the timer interrupt
is pending, we will still return early, and otherwise arm the soft
timer.

Fixes: 4d74ecfa6458b ("KVM: arm64: Don't arm a hrtimer for an already pending timer")
Cc: stable@vger.kernel.org
Tested-by: Dmytro Terletskyi <dmytro_terletskyi@epam.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20250204110050.150560-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kvm/arch_timer.c