From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: KVM: PIT: fix kpit_elapsed division by zero Date: Thu, 2 Jul 2009 20:02:15 -0300 Message-ID: <20090702230215.GA25347@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: kvm Return-path: Received: from mx2.redhat.com ([66.187.237.31]:36681 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752380AbZGBXCz (ORCPT ); Thu, 2 Jul 2009 19:02:55 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n62N2w1j013369 for ; Thu, 2 Jul 2009 19:02:58 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n62N2d7B025950 for ; Thu, 2 Jul 2009 19:02:41 -0400 Received: from amt.cnet (vpn-51-32.sfbay.redhat.com [10.14.51.32]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n62N2a5Z006947 for ; Thu, 2 Jul 2009 19:02:37 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 7772E67404F for ; Thu, 2 Jul 2009 20:02:16 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n62N2Fv3025471 for kvm@vger.kernel.org; Thu, 2 Jul 2009 20:02:15 -0300 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Fix division by zero triggered by latch count command on uninitialized counter. Signed-off-by: Marcelo Tosatti diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 14bbaae..8c3ac30 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -104,6 +104,9 @@ static s64 __kpit_elapsed(struct kvm *kvm) ktime_t remaining; struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; + if (!ps->pit_timer.period) + return 0; + /* * The Counter does not stop when it reaches zero. In * Modes 0, 1, 4, and 5 the Counter ``wraps around'' to