Commit d6800af5 authored by Nicolas Saenz Julienne's avatar Nicolas Saenz Julienne Committed by Sean Christopherson

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: stable@vger.kernel.org
Fixes: 1f4b34f8 ("kvm/x86: Hyper-V SynIC timers")
Signed-off-by: default avatarNicolas Saenz Julienne <nsaenz@amazon.com>
Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/20231017155101.40677-1-nsaenz@amazon.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 5a989bbe
...@@ -727,10 +727,12 @@ static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count, ...@@ -727,10 +727,12 @@ static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count,
stimer_cleanup(stimer); stimer_cleanup(stimer);
stimer->count = count; stimer->count = count;
if (stimer->count == 0) if (!host) {
stimer->config.enable = 0; if (stimer->count == 0)
else if (stimer->config.auto_enable) stimer->config.enable = 0;
stimer->config.enable = 1; else if (stimer->config.auto_enable)
stimer->config.enable = 1;
}
if (stimer->config.enable) if (stimer->config.enable)
stimer_mark_pending(stimer, false); stimer_mark_pending(stimer, false);
......
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