From patchwork Thu Apr 5 17:41:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 10325105 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 DEBA5600CB for ; Thu, 5 Apr 2018 17:42:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE54B1FF1E for ; Thu, 5 Apr 2018 17:42:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2873285CA; Thu, 5 Apr 2018 17:42:42 +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=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 EF55F22299 for ; Thu, 5 Apr 2018 17:42:41 +0000 (UTC) Received: from localhost ([::1]:44447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f48uG-00049E-Ea for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Apr 2018 13:42:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f48ta-0003mN-QO for qemu-devel@nongnu.org; Thu, 05 Apr 2018 13:41:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f48tV-0004EB-Se for qemu-devel@nongnu.org; Thu, 05 Apr 2018 13:41:58 -0400 Received: from mout.web.de ([212.227.17.11]:52609) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f48tV-0004DQ-HX for qemu-devel@nongnu.org; Thu, 05 Apr 2018 13:41:53 -0400 Received: from [192.168.2.11] ([92.77.50.102]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LxweO-1ePWfa208K-015FTz; Thu, 05 Apr 2018 19:41:50 +0200 From: Jan Kiszka To: Dmitry Fleytman , qemu-devel Openpgp: preference=signencrypt Message-ID: Date: Thu, 5 Apr 2018 19:41:47 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 Content-Language: en-US X-Provags-ID: V03:K1:YBALxfZsxQpHnHAfJLdTgYWX6oGieT+M0Qb2cq8qssyIqlBL9jq 42+chLZrp8wCD9C/WMXXluPwr4c6enBEFIGZteKBS9o1MPpEvFjIgHlD7oflu7ouPQxSs3y 6txSresTr5meRO/Ww5ZYf7gGwJD/B1viaLLg85hT8lj5CVtIAaQFW9sp0lriBAYUI2GaNqn YORbkqF4VTOtaSuG9Eq+w== X-UI-Out-Filterresults: notjunk:1; V01:K0:oe0V8zlz7jo=:aVWOnk2r5pbf6w3lNTxn8I FYa2uO5HGXraotdO9cEQKqVK3kKoRaOvOQjsC7meT3aw0DYI2/lKziqRjSJtD7HGzuS9ov71n TQHzILnurWz3BIHm/z0Ro1dn6dYpuS97czdAb7BsAMqIeABq31rEB8XDlHSGb1quG1OjXyayP z+A9mIP5D42NkFBbxrPGUeJqQIwVrxqxtwZGcS4BoKwR5nI4jHVjmt7DGXzRqCKXAMwScXbN6 L0hVcXmzP1ZpJ1zCeM2VZbS+O7eJ4mFPcFAovlAIinR1djsgM4XXpCu1rz72jSNVpL9r9motE u6QYtK512eT94aGn5mx59LV7PWpMKr3yPNI8TMoIe0bWP937ebQYs3b6+k4OVFx1KfjlQGWL6 xFeJyIkdPYSEVD60gRHb0x3iyqKLHsgv7qYCYJ0j9fRsqm/8jZO5YbtaVs1ZRta39d3i8/+Yb ZqpIiDEuEHq8NdRmTgJT3MYwm4Po38aR0CsWkh2G4ZeHEEgTO42qEG0CJmBHYIlwBjLXpXFtc sSpiz1/mGv87zA5rj8t2iJ0MxXy2X2IskWc9Abj2gaNya39WXGKllCnd0VyQYkoSlO42N31s5 Wcq0D/VN8fbtUTrDD5IMWx0eYwn6/s6WN2o7wnWjC8VLYG5ju4JXzYHdGjFmuPRn52o8YT5hE CcwOsVz/P7EbAN30x335GOWByl8DgtW+FZYC5gQOwDspjNpBLKFWJR0ZN1G+pI5YRzv9f6ZpR tGaHO7t4o/wVopZH8c8/z2+Ckp8+9PEKBCp91JiqPUN1qKH5eahzFWbCSzgdO3Upr4gVGu74C 7BtuqIq2FY3xackccwInhnXZnX3/tWdjH6Q9N/9FmXVJzWs/Tg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.11 Subject: [Qemu-devel] [PATCH v2] e1000e: Prevent MSI/MSI-X storms 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 From: Jan Kiszka Only signal MSI/MSI-X events on rising edges. So far we re-triggered the interrupt sources even if the guest did no consumed the pending one, easily causing interrupt storms. Issue was observable with Linux 4.16 e1000e driver when MSI-X was used. Vector 2 was causing interrupt storms after the driver activated the device. Signed-off-by: Jan Kiszka --- Changes in v2: - also update msi_causes_pending after EIAC changes (required because there is no e1000e_update_interrupt_state after that hw/net/e1000e_core.c | 11 +++++++++++ hw/net/e1000e_core.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index c93c4661ed..d6ddd59986 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2027,6 +2027,7 @@ e1000e_msix_notify_one(E1000ECore *core, uint32_t cause, uint32_t int_cfg) } core->mac[ICR] &= ~effective_eiac; + core->msi_causes_pending &= ~effective_eiac; if (!(core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) { core->mac[IMS] &= ~effective_eiac; @@ -2123,6 +2124,13 @@ e1000e_send_msi(E1000ECore *core, bool msix) { uint32_t causes = core->mac[ICR] & core->mac[IMS] & ~E1000_ICR_ASSERTED; + core->msi_causes_pending &= causes; + causes ^= core->msi_causes_pending; + if (causes == 0) { + return; + } + core->msi_causes_pending |= causes; + if (msix) { e1000e_msix_notify(core, causes); } else { @@ -2160,6 +2168,9 @@ e1000e_update_interrupt_state(E1000ECore *core) core->mac[ICS] = core->mac[ICR]; interrupts_pending = (core->mac[IMS] & core->mac[ICR]) ? true : false; + if (!interrupts_pending) { + core->msi_causes_pending = 0; + } trace_e1000e_irq_pending_interrupts(core->mac[ICR] & core->mac[IMS], core->mac[ICR], core->mac[IMS]); diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h index 7d8ff41890..63a15510cc 100644 --- a/hw/net/e1000e_core.h +++ b/hw/net/e1000e_core.h @@ -109,6 +109,8 @@ struct E1000Core { NICState *owner_nic; PCIDevice *owner; void (*owner_start_recv)(PCIDevice *d); + + uint32_t msi_causes_pending; }; void