From: Marcelo Tosatti Date: Fri, 18 Sep 2009 23:08:05 +0000 (-0300) Subject: KVM: limit lapic periodic timer frequency X-Git-Tag: v2.6.30.9~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1dbc751eb2a4aaf628cc9dac6954e1bd1afc531;p=thirdparty%2Fkernel%2Fstable.git KVM: limit lapic periodic timer frequency (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 Signed-off-by: Avi Kivity Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index f0b67f2cdd695..dba1f4d08f2c4 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -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),