From patchwork Wed May 10 08:57:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5p6X?= <8610_28@163.com> X-Patchwork-Id: 9719615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A1A7601E7 for ; Wed, 10 May 2017 09:28:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91A17283B9 for ; Wed, 10 May 2017 09:28:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8695928576; Wed, 10 May 2017 09:28:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, FROM_STARTS_WITH_NUMS, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1115C283B9 for ; Wed, 10 May 2017 09:28:29 +0000 (UTC) Received: from localhost ([::1]:41310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8Nv2-0001zj-V0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 10 May 2017 05:28:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <8610_28@163.com>) id 1d8NuV-0001zX-Dy for qemu-devel@nongnu.org; Wed, 10 May 2017 05:27:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <8610_28@163.com>) id 1d8NuS-0007Tt-69 for qemu-devel@nongnu.org; Wed, 10 May 2017 05:27:55 -0400 Received: from m12-16.163.com ([220.181.12.16]:35064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <8610_28@163.com>) id 1d8NuR-0007Rq-CX for qemu-devel@nongnu.org; Wed, 10 May 2017 05:27:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=SsTVi 3GvPoSyJhPSjQOvnfYmoxW+QRPYfQcSYBTHB+Y=; b=SLsXoug/Fh/huKgfz6BgU Gnd6LrCVk947bVnF399zPrXU5CNjzY/Zvh4iK5jtf+taLJRZKsW9eSvuY4DF6upS PWthEc0UmwFeKEvQy5RHDt2FPd5x0a1cLozOYynkgRsJjtYD4zvqmx4pmJS/m43A rmoxUXg5z0Pdj0t8qoPsC8= Received: from 8610_28$163.com ( [125.69.66.103] ) by ajax-webmail-wmsvr56 (Coremail) ; Wed, 10 May 2017 16:57:10 +0800 (CST) X-Originating-IP: [125.69.66.103] Date: Wed, 10 May 2017 16:57:10 +0800 (CST) From: =?GBK?B?wO7B1g==?= <8610_28@163.com> To: qemu-devel@nongnu.org X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20160729(86883.8884) Copyright (c) 2002-2017 www.mailtech.cn 163com X-CM-CTRLDATA: MOSxvmZvb3Rlcl9odG09MTU0Mzo1Ng== MIME-Version: 1.0 Message-ID: <1894a033.84c.15bf1938bed.Coremail.8610_28@163.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: OMGowAC3wKjm1RJZUkwWAA--.35459W X-CM-SenderInfo: qywrisisy6il2tof0z/1tbiYwbTHVaDszdNOQACsM X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.16 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] ehci: fix "int" overflow for calculation ehci->last_run_ns X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If we experience large delays between echi timer callbacks (i.e. because other periodic handlers have taken a lot of time to complete) we get a lot of skipped frames which then delay ehci timer callback. Then we will calculation ehci->last_run_ns,but skipped_uframes is int,so "UFRAME_TIMER_NS * skipped_uframes" will be int,and if skipped_uframes is big enough ,it can overflow ,and this can not calculation the right number,then it can raise large amountsinterrupts; Observable behaviour is qemu consuming 100% host CPU time while guest is unresponsive. This misbehavior could happen for a while and QEMU does not get out from this state automatically without the patch in Branch-master repository. t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 50ef817f93..8df2f08783 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2238,7 +2238,7 @@ static void ehci_frame_timer(void *opaque) int need_timer = 0; int64_t expire_time, t_now; uint64_t ns_elapsed; - int uframes, skipped_uframes; + uint64 uframes, skipped_uframes; int i;