diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2014-01-06 12:00:02 -0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-01-15 12:43:54 +0100 |
commit | 9ed96e87c5748de4c2807ef17e81287c7304186c (patch) | |
tree | e16371f8aedac885b770d1db402b03847f519b8e /arch/x86/kvm/i8254.c | |
parent | 37f6a4e237303549c8676dfe1fd1991ceab512eb (diff) | |
download | op-kernel-dev-9ed96e87c5748de4c2807ef17e81287c7304186c.zip op-kernel-dev-9ed96e87c5748de4c2807ef17e81287c7304186c.tar.gz |
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 412a5aa..518d864 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -37,6 +37,7 @@ #include "irq.h" #include "i8254.h" +#include "x86.h" #ifndef CONFIG_X86_64 #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) atomic_set(&ps->pending, 0); ps->irq_ack = 1; + /* + * Do not allow the guest to program periodic timers with small + * interval, since the hrtimers are not throttled by the host + * scheduler. + */ + if (ps->is_periodic) { + s64 min_period = min_timer_period_us * 1000LL; + + if (ps->period < min_period) { + pr_info_ratelimited( + "kvm: requested %lld ns " + "i8254 timer period limited to %lld ns\n", + ps->period, min_period); + ps->period = min_period; + } + } + hrtimer_start(&ps->timer, ktime_add_ns(ktime_get(), interval), HRTIMER_MODE_ABS); } |