KVM: x86: hyper-v: Don't auto-enable stimer during deserialization
Subsystems (4)
PATCH v2 1/1 KVM: x86: hyper-v: Don't auto-enable stimer during deserialization
By not honoring the 'stimer->config.enable' state during stimer deserialization we might introduce spurious timer interrupts. For example through the following events:
- The stimer is configured in auto-enable mode.
- The stimer's count is set and the timer enabled.
- The stimer expires, an interrupt is injected.
- We live migrate the VM.
- The stimer config and count are deserialized, auto-enable is ON, the stimer is re-enabled.
- The stimer expires right away, and injects an unwarranted interrupt.
So let's not change the stimer's enable state if the MSR write comes from user-space.
Fixes 1f4b34f825e8 ("kvm/x86: Hyper-V SynIC timers")
Signed-off-by Nicolas Saenz Julienne <[email protected]>
---
Changes since v1:
- Cover all 'stimer->config.enable' updates.
arch/x86/kvm/hyperv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +6 -4
@@ -727,10 +727,12 @@ static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count,stimer_cleanup (stimer); stimer->count = count; -if (stimer->count ==0 ) - stimer->config.enable =0 ; -else if (stimer->config.auto_enable) - stimer->config.enable =1 ; +if (!host) { +if (stimer->count ==0 ) + stimer->config.enable =0 ; +else if (stimer->config.auto_enable) + stimer->config.enable =1 ; + }if (stimer->config.enable)stimer_mark_pending (stimer, false);
Signature · 1 line
2.40.1