KVM: PIT: fix kpit_elapsed division by zero

Fix division by zero triggered by latch count command on uninitialized
counter.

Cc: stable@kernel.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>

authored by Marcelo Tosatti and committed by Avi Kivity 0ff77873 e125e7b6

+3
+3
arch/x86/kvm/i8254.c
··· 104 ktime_t remaining; 105 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; 106 107 /* 108 * The Counter does not stop when it reaches zero. In 109 * Modes 0, 1, 4, and 5 the Counter ``wraps around'' to
··· 104 ktime_t remaining; 105 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; 106 107 + if (!ps->pit_timer.period) 108 + return 0; 109 + 110 /* 111 * The Counter does not stop when it reaches zero. In 112 * Modes 0, 1, 4, and 5 the Counter ``wraps around'' to