]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: limit lapic periodic timer frequency
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 28 Jul 2009 02:41:01 +0000 (23:41 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 24 Sep 2009 15:44:10 +0000 (08:44 -0700)
commit 1444885a045fe3b1905a14ea1b52540bf556578b upstream.

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 ae99d83f81a34384d72859a69233ace1dd8fa433..bb6277d5b2c07f2785b2d618461a612d75a27234 100644 (file)
@@ -573,6 +573,15 @@ static void start_apic_timer(struct kvm_lapic *apic)
 
        if (!apic->lapic_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->lapic_timer.period < NSEC_PER_MSEC/2)
+                       apic->lapic_timer.period = NSEC_PER_MSEC/2;
+       }
 
        hrtimer_start(&apic->lapic_timer.timer,
                      ktime_add_ns(now, apic->lapic_timer.period),