From patchwork Thu Jul 2 23:02:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 33826 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n62N32tX026889 for ; Thu, 2 Jul 2009 23:03:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbZGBXC4 (ORCPT ); Thu, 2 Jul 2009 19:02:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752483AbZGBXC4 (ORCPT ); Thu, 2 Jul 2009 19:02:56 -0400 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 Date: Thu, 2 Jul 2009 20:02:15 -0300 From: Marcelo Tosatti To: kvm Subject: KVM: PIT: fix kpit_elapsed division by zero Message-ID: <20090702230215.GA25347@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Fix division by zero triggered by latch count command on uninitialized counter. Signed-off-by: Marcelo Tosatti --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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