]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: limit lapic periodic timer frequency
authorMarcelo Tosatti <mtosatti@redhat.com>
Fri, 18 Sep 2009 23:08:05 +0000 (20:08 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Oct 2009 15:27:56 +0000 (08:27 -0700)
(cherry picked from commit 1444885a045fe3b1905a14ea1b52540bf556578b)

Otherwise its possible to starve the host by programming lapic timer
with a very high frequency.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/lapic.c

index f0b67f2cdd695a71c636ddfbe45b9ec9248b0748..dba1f4d08f2c4e550ac76e2e0852d2df41e933e9 100644 (file)
@@ -635,6 +635,15 @@ static void start_apic_timer(struct kvm_lapic *apic)
 
        if (!apic->timer.period)
                return;
+       /*
+        * Do not allow the guest to program periodic timers with small
+        * interval, since the hrtimers are not throttled by the host
+        * scheduler.
+        */
+       if (apic_lvtt_period(apic)) {
+               if (apic->timer.period < NSEC_PER_MSEC/2)
+                       apic->timer.period = NSEC_PER_MSEC/2;
+       }
 
        hrtimer_start(&apic->timer.dev,
                      ktime_add_ns(now, apic->timer.period),