diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2014-01-06 09:00:02 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-01-15 06:43:54 -0500 |
commit | 9ed96e87c5748de4c2807ef17e81287c7304186c (patch) | |
tree | e16371f8aedac885b770d1db402b03847f519b8e /arch/x86/kvm/i8254.c | |
parent | 37f6a4e237303549c8676dfe1fd1991ceab512eb (diff) |
KVM: x86: limit PIT timer frequency
Limit PIT timer frequency similarly to the limit applied by
LAPIC timer.
Cc: stable@kernel.org
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/i8254.c')
-rw-r--r-- | arch/x86/kvm/i8254.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 412a5aa0ef94..518d86471b76 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include "irq.h" | 38 | #include "irq.h" |
39 | #include "i8254.h" | 39 | #include "i8254.h" |
40 | #include "x86.h" | ||
40 | 41 | ||
41 | #ifndef CONFIG_X86_64 | 42 | #ifndef CONFIG_X86_64 |
42 | #define mod_64(x, y) ((x) - (y) * div64_u64(x, y)) | 43 | #define mod_64(x, y) ((x) - (y) * div64_u64(x, y)) |
@@ -349,6 +350,23 @@ static void create_pit_timer(struct kvm *kvm, u32 val, int is_period) | |||
349 | atomic_set(&ps->pending, 0); | 350 | atomic_set(&ps->pending, 0); |
350 | ps->irq_ack = 1; | 351 | ps->irq_ack = 1; |
351 | 352 | ||
353 | /* | ||
354 | * Do not allow the guest to program periodic timers with small | ||
355 | * interval, since the hrtimers are not throttled by the host | ||
356 | * scheduler. | ||
357 | */ | ||
358 | if (ps->is_periodic) { | ||
359 | s64 min_period = min_timer_period_us * 1000LL; | ||
360 | |||
361 | if (ps->period < min_period) { | ||
362 | pr_info_ratelimited( | ||
363 | "kvm: requested %lld ns " | ||
364 | "i8254 timer period limited to %lld ns\n", | ||
365 | ps->period, min_period); | ||
366 | ps->period = min_period; | ||
367 | } | ||
368 | } | ||
369 | |||
352 | hrtimer_start(&ps->timer, ktime_add_ns(ktime_get(), interval), | 370 | hrtimer_start(&ps->timer, ktime_add_ns(ktime_get(), interval), |
353 | HRTIMER_MODE_ABS); | 371 | HRTIMER_MODE_ABS); |
354 | } | 372 | } |