aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-07-27 23:41:01 -0300
committerAvi Kivity <avi@redhat.com>2009-09-10 08:33:17 +0300
commit1444885a045fe3b1905a14ea1b52540bf556578b (patch)
tree204bbcfa479942245d957fd9d2dbe94ecbcfbc9d
parent5f0269f5d72f622514daec9af158c32e933800b6 (diff)
downloadmrst-s0i3-test-1444885a045fe3b1905a14ea1b52540bf556578b.tar.gz
mrst-s0i3-test-1444885a045fe3b1905a14ea1b52540bf556578b.tar.xz
mrst-s0i3-test-1444885a045fe3b1905a14ea1b52540bf556578b.zip
KVM: limit lapic periodic timer frequency
Otherwise its possible to starve the host by programming lapic timer with a very high frequency. Cc: stable@kernel.org Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/lapic.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 66122bfc74a..5b9d1ae09ca 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -670,6 +670,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),