]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
KVM: arm/arm64: Fix incorrect timer_is_pending logic
authorChristoffer Dall <christoffer.dall@linaro.org>
Thu, 25 Jan 2018 13:20:19 +0000 (14:20 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Wed, 31 Jan 2018 09:10:17 +0000 (10:10 +0100)
commit13e59ece5b30f39e4e1e1fac2b2ddc7ed527f3cc
treea64576430832223e0b152170f62dd9ef17692b47
parentb276f1b3b1eb52697f6645bb98f7d32ffb89df69
KVM: arm/arm64: Fix incorrect timer_is_pending logic

After the recently introduced support for level-triggered mapped
interrupt, I accidentally left the VCPU thread busily going back and
forward between the guest and the hypervisor whenever the guest was
blocking, because I would always incorrectly report that a timer
interrupt was pending.

This is because the timer->irq.level field is not valid for mapped
interrupts, where we offload the level state to the hardware, and as a
result this field is always true.

Luckily the problem can be relatively easily solved by not checking the
cached signal state of either timer in kvm_timer_should_fire() but
instead compute the timer state on the fly, which we do already if the
cached signal state wasn't high.  In fact, the only reason for checking
the cached signal state was a tiny optimization which would only be
potentially faster when the polling loop detects a pending timer
interrupt, which is quite unlikely.

Instead of duplicating the logic from kvm_arch_timer_handler(), we
enlighten kvm_timer_should_fire() to report something valid when the
timer state is loaded onto the hardware.  We can then call this from
kvm_arch_timer_handler() as well and avoid the call to
__timer_snapshot_state() in kvm_arch_timer_get_input_level().

Reported-by: Tomasz Nowicki <tn@semihalf.com>
Tested-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
virt/kvm/arm/arch_timer.c