From d1dbc751eb2a4aaf628cc9dac6954e1bd1afc531 Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Fri, 18 Sep 2009 20:08:05 -0300 Subject: [PATCH] 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 --- arch/x86/kvm/lapic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index f0b67f2cdd69..dba1f4d08f2c 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), -- 2.43.0