From patchwork Mon Nov 20 12:49:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladi Prosek X-Patchwork-Id: 10066387 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 783A9602B7 for ; Mon, 20 Nov 2017 12:50:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66DBE28772 for ; Mon, 20 Nov 2017 12:50:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5867028D36; Mon, 20 Nov 2017 12:50:07 +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,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 CDFC228772 for ; Mon, 20 Nov 2017 12:50:06 +0000 (UTC) Received: from localhost ([::1]:56882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGlWX-00063l-Gp for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Nov 2017 07:50:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGlVo-00063N-BD for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:49:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGlVl-0006oj-84 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:49:20 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:39138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGlVl-0006oa-36 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:49:17 -0500 Received: by mail-ua0-f196.google.com with SMTP id 31so645695uaj.6 for ; Mon, 20 Nov 2017 04:49:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5aPXcp25EhMD9bg4kbV9qRqYHL6FfGhNRt/oUyVLkm8=; b=AGtFAMTckBaG/OMQrfGyHMXapaHuPr9RwcqScYumVuQUPgGFMFhr1bR1cGJhXIatUJ Fm6b2M4dcoiQny5ItYiLw/eWrIzpsTIepSfU8lnJoKQQgXf2IAiKcZxqslxT1yKrsGCj DK4riZzkXaa+d4VbOyT2v65WmUKtWk8UcrId34PkMJyHOooVOQy27wmqyFtgo+OZvQuL 4IpdiscIgxSxeLIoLoCusF1NTmNV04OyLbciqbuHDXyzDLHQUKhsYPPmUva0PZMEzAgL bHp96XAcOv5OwLiNHpRfRml3LjeUYprp2CSUYI4Dugc1/ZhLFg5zzNiK1WRu89J7D1uz WAYw== X-Gm-Message-State: AJaThX6DsUFREsLtvwoNt06I56QxYOl0h3HxqyyL0GuliRK1Wi2JsAO8 p1Vvn7JKP12qwqjLJ6p3aE70L2qdVPHo0abAQlcrhA== X-Google-Smtp-Source: AGs4zMb3m1ma4rSYEBS53PwKs/ZqIALZ4p88U4bOqeMCb0FYsl9vq2egXKeoK5wlkARJr6GfMBnglRo7txWBxp3OwBk= X-Received: by 10.159.59.219 with SMTP id y27mr11097481uah.47.1511182156314; Mon, 20 Nov 2017 04:49:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.52.199 with HTTP; Mon, 20 Nov 2017 04:49:15 -0800 (PST) In-Reply-To: References: <20171115073144.14758-1-lprosek@redhat.com> <1f8754babd990beb90c516d2973b21d3@hostfission.com> From: Ladi Prosek Date: Mon, 20 Nov 2017 13:49:15 +0100 Message-ID: To: Geoffrey McRae X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.217.196 Subject: Re: [Qemu-devel] [PATCH v2 0/3] ivshmem: MSI bug fixes 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: , Cc: Paolo Bonzini , qemu-devel , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Markus Armbruster Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Nov 20, 2017 at 10:07 AM, Ladi Prosek wrote: > On Sun, Nov 19, 2017 at 9:39 PM, wrote: >> I just updated to the latest build and applied this patch set, now on VM >> reset the qemu crashes with the following assert: >> >> ivshmem.c:467: ivshmem_add_kvm_msi_virq: Assertion >> `!s->msi_vectors[vector].pdev' failed. > > I see asserts too. Even with v1 on top of QEMU v2.10.0 so I must have > missed something. > > Looking. And, needless to say, these patches should not be applied just yet :) Ok, here goes it. 1) ivshmem.c:467: ivshmem_add_kvm_msi_virq: Assertion `!s->msi_vectors[vector].pdev' failed. Is caused by the ivshmem device not undoing the effects of ivshmem_enable_irqfd() on reset. This fix works for me: Then either no further changes to this patchset are necessary. Or, if relying on unmasks/masks (or msix_vector_use_notifier/msix_vector_release_notifier as it's called in msix.c) always being balanced is not recommended, the assert will simply change into an if. > Thanks! > Ladi > >> On 2017-11-15 18:31, Ladi Prosek wrote: >>> >>> Fixes bugs in the ivshmem device implementation uncovered with the new >>> Windows ivshmem driver: >>> >>> https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem >>> >>> v1->v2: >>> * Patch 1 - added reproducer info to commit message (Markus) >>> * Patch 2 - restructured conditionals, fixed comment formatting (Markus) >>> * Patch 3 - added reproducer info to commit message (Markus) >>> >>> Ladi Prosek (3): >>> ivshmem: Don't update non-existent MSI routes >>> ivshmem: Always remove irqfd notifiers >>> ivshmem: Improve MSI irqfd error handling >>> >>> hw/misc/ivshmem.c | 77 >>> +++++++++++++++++++++++++++++++++++++++++-------------- >>> 1 file changed, 58 insertions(+), 19 deletions(-) >> >> --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -758,10 +758,15 @@ static void ivshmem_msix_vector_use(IVShmemState *s) } } + +static void ivshmem_disable_irqfd(IVShmemState *s); + static void ivshmem_reset(DeviceState *d) { IVShmemState *s = IVSHMEM_COMMON(d); + ivshmem_disable_irqfd(s); + s->intrstatus = 0; s->intrmask = 0; if (ivshmem_has_feature(s, IVSHMEM_MSI)) { 2) ivshmem.c:354: ivshmem_vector_mask: Assertion `v->unmasked' failed. which I've been also getting after I enabled Driver Verifier and Windows started crashing (https://github.com/virtio-win/kvm-guest-drivers-windows/pull/199), is caused by the MSI-X code masking already masked vectors on reset. I'm going to post a patch similar to this: --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -500,11 +500,12 @@ void msix_reset(PCIDevice *dev) return; } msix_clear_all_vectors(dev); + msix_mask_all(dev, dev->msix_entries_nr); dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &= ~dev->wmask[dev->msix_cap + MSIX_CONTROL_OFFSET]; memset(dev->msix_table, 0, dev->msix_entries_nr * PCI_MSIX_ENTRY_SIZE); memset(dev->msix_pba, 0, QEMU_ALIGN_UP(dev->msix_entries_nr, 64) / 8); - msix_mask_all(dev, dev->msix_entries_nr); + msix_update_function_masked(dev); }