Skip to content

Commit d6800af

Browse files
Nicolas Saenz Juliennesean-jc
authored andcommitted
KVM: x86: hyper-v: Don't auto-enable stimer on write from user-space
Don't apply the stimer's counter side effects when modifying its value from user-space, as this may trigger spurious interrupts. For example: - 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. - The VM is live migrated. - 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. Cc: [email protected] Fixes: 1f4b34f ("kvm/x86: Hyper-V SynIC timers") Signed-off-by: Nicolas Saenz Julienne <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 5a989bb commit d6800af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/x86/kvm/hyperv.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,12 @@ static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count,
727727

728728
stimer_cleanup(stimer);
729729
stimer->count = count;
730-
if (stimer->count == 0)
731-
stimer->config.enable = 0;
732-
else if (stimer->config.auto_enable)
733-
stimer->config.enable = 1;
730+
if (!host) {
731+
if (stimer->count == 0)
732+
stimer->config.enable = 0;
733+
else if (stimer->config.auto_enable)
734+
stimer->config.enable = 1;
735+
}
734736

735737
if (stimer->config.enable)
736738
stimer_mark_pending(stimer, false);

0 commit comments

Comments
 (0)