Commit 0eb7c33c authored by Christoffer Dall's avatar Christoffer Dall

KVM: arm/arm64: Fix timer enable flow

When enabling the timer on the first run, we fail to ever restore the
state and mark it as loaded.  That means, that in the initial entry to
the VCPU ioctl, unless we exit to userspace for some reason such as a
pending signal, if the guest programs a timer and blocks, we will wait
forever, because we never read back the hardware state (the loaded flag
is not set), and so we think the timer is disabled, and we never
schedule a background soft timer.

The end result?  The VCPU blocks forever, and the only solution is to
kill the thread.

Fixes: 4a2c4da1 ("arm/arm64: KVM: Load the timer state when enabling the timer")
Reported-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Reviewed-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Tested-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
parent 36e5cfd4
...@@ -846,10 +846,7 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) ...@@ -846,10 +846,7 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu)
no_vgic: no_vgic:
preempt_disable(); preempt_disable();
timer->enabled = 1; timer->enabled = 1;
if (!irqchip_in_kernel(vcpu->kvm)) kvm_timer_vcpu_load(vcpu);
kvm_timer_vcpu_load_user(vcpu);
else
kvm_timer_vcpu_load_vgic(vcpu);
preempt_enable(); preempt_enable();
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment