From patchwork Tue Feb 12 14:06:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1040602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43zPhL4kx0z9sMl for ; Wed, 13 Feb 2019 01:10:58 +1100 (AEDT) Received: from localhost ([127.0.0.1]:40290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYm0-0004rO-IZ for incoming@patchwork.ozlabs.org; Tue, 12 Feb 2019 09:10:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYhv-00025L-RE for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:06:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtYhu-0006u0-BD for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:06:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35870) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtYht-0006s3-TD for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:06:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C74FC4902D; Tue, 12 Feb 2019 14:06:40 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-63.brq.redhat.com [10.40.204.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D03215D736; Tue, 12 Feb 2019 14:06:37 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Tue, 12 Feb 2019 15:06:19 +0100 Message-Id: <20190212140621.17009-2-philmd@redhat.com> In-Reply-To: <20190212140621.17009-1-philmd@redhat.com> References: <20190212140621.17009-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 12 Feb 2019 14:06:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] Revert "contrib/vhost-user-blk: fix the compilation issue" 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: Eduardo Habkost , "open list:X86" , Marcelo Tosatti , Peter Xu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Changpeng Liu , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Commit a56de056c91f8 squashed the following two unrelated commits at once: - "contrib/vhost-user-blk: fix the compilation issue" (Message-Id: 1547615970-23545-2-git-send-email-changpeng.liu@intel.com) - "i386/kvm: ignore masked irqs when update msi routes" (Message-Id: 20190116030815.27273-5-peterx@redhat.com) While the git history remains bisectable, having a commit that changes MSI/MSIX code but describes it as "fix vhost-user-blk compilation" is rather confusing. Revert the offending commit to properly apply both patches separately. Reported-by: Peter Xu Fixes: a56de056c91f8 Signed-off-by: Philippe Mathieu-Daudé --- contrib/vhost-user-blk/vhost-user-blk.c | 6 +----- target/i386/kvm.c | 14 +++----------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index 43583f2659..5c2092e13a 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -20,10 +20,6 @@ #include "contrib/libvhost-user/libvhost-user-glib.h" #include "contrib/libvhost-user/libvhost-user.h" -#if defined(__linux__) -#include -#include -#endif struct virtio_blk_inhdr { unsigned char status; @@ -525,7 +521,7 @@ vub_get_blocksize(int fd) #if defined(__linux__) && defined(BLKSSZGET) if (ioctl(fd, BLKSSZGET, &blocksize) == 0) { - return blocksize; + return blocklen; } #endif diff --git a/target/i386/kvm.c b/target/i386/kvm.c index beae1b99da..9af4542fb8 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \ static void kvm_update_msi_routes_all(void *private, bool global, uint32_t index, uint32_t mask) { - int cnt = 0, vector; + int cnt = 0; MSIRouteEntry *entry; MSIMessage msg; PCIDevice *dev; @@ -3902,19 +3902,11 @@ static void kvm_update_msi_routes_all(void *private, bool global, /* TODO: explicit route update */ QLIST_FOREACH(entry, &msi_route_list, list) { cnt++; - vector = entry->vector; dev = entry->dev; - if (msix_enabled(dev) && !msix_is_masked(dev, vector)) { - msg = msix_get_message(dev, vector); - } else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) { - msg = msi_get_message(dev, vector); - } else { - /* - * Either MSI/MSIX is disabled for the device, or the - * specific message was masked out. Skip this one. - */ + if (!msix_enabled(dev) && !msi_enabled(dev)) { continue; } + msg = pci_get_msi_message(dev, entry->vector); kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev); } kvm_irqchip_commit_routes(kvm_state); From patchwork Tue Feb 12 14:06:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1040616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43zPss74NMz9sMl for ; Wed, 13 Feb 2019 01:19:13 +1100 (AEDT) Received: from localhost ([127.0.0.1]:40418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYtz-0003Ea-R6 for incoming@patchwork.ozlabs.org; Tue, 12 Feb 2019 09:19:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYiE-0002N4-PT for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:07:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtYi4-00076h-OF for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:07:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtYi4-00073d-IB for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:06:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2843D58E5B; Tue, 12 Feb 2019 14:06:50 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-63.brq.redhat.com [10.40.204.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FD0062943; Tue, 12 Feb 2019 14:06:41 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Tue, 12 Feb 2019 15:06:20 +0100 Message-Id: <20190212140621.17009-3-philmd@redhat.com> In-Reply-To: <20190212140621.17009-1-philmd@redhat.com> References: <20190212140621.17009-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 12 Feb 2019 14:06:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] contrib/vhost-user-blk: fix the compilation issue 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: Peter Xu , Stefan Hajnoczi , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Changpeng Liu , Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Changpeng Liu Signed-off-by: Changpeng Liu Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Message-Id: <1547615970-23545-2-git-send-email-changpeng.liu@intel.com> [PMD: this patch was first (incorrectly) introduced as a56de056c91f8] Signed-off-by: Philippe Mathieu-Daudé --- contrib/vhost-user-blk/vhost-user-blk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index 5c2092e13a..43583f2659 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -20,6 +20,10 @@ #include "contrib/libvhost-user/libvhost-user-glib.h" #include "contrib/libvhost-user/libvhost-user.h" +#if defined(__linux__) +#include +#include +#endif struct virtio_blk_inhdr { unsigned char status; @@ -521,7 +525,7 @@ vub_get_blocksize(int fd) #if defined(__linux__) && defined(BLKSSZGET) if (ioctl(fd, BLKSSZGET, &blocksize) == 0) { - return blocklen; + return blocksize; } #endif From patchwork Tue Feb 12 14:06:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1040603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43zPj755gKz9s3x for ; Wed, 13 Feb 2019 01:11:39 +1100 (AEDT) Received: from localhost ([127.0.0.1]:40302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYmf-0005VZ-GS for incoming@patchwork.ozlabs.org; Tue, 12 Feb 2019 09:11:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYiL-0002QZ-BG for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:07:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtYiF-0007GY-1v for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:07:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtYiE-0007Ct-On for qemu-devel@nongnu.org; Tue, 12 Feb 2019 09:07:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 969F2C0669CB; Tue, 12 Feb 2019 14:07:00 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-63.brq.redhat.com [10.40.204.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99CD862943; Tue, 12 Feb 2019 14:06:50 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Tue, 12 Feb 2019 15:06:21 +0100 Message-Id: <20190212140621.17009-4-philmd@redhat.com> In-Reply-To: <20190212140621.17009-1-philmd@redhat.com> References: <20190212140621.17009-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 12 Feb 2019 14:07:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] i386/kvm: ignore masked irqs when update msi routes 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: Eduardo Habkost , "open list:X86" , Marcelo Tosatti , Peter Xu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Changpeng Liu , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu When we are with intel-iommu device and with IR on, KVM will register an IEC notifier to detect interrupt updates from the guest and we'll kick off kvm_update_msi_routes_all() when it happens to make sure kernel IRQ cache is matching the latest. Though, kvm_update_msi_routes_all() is buggy in that it ignored the mask bit of either MSI/MSIX messages and it tries to translate the message even if the corresponding message was already masked by the guest driver (hence the MSI/MSIX message will be invalid). Without this patch, we can receive an error message when we reboot a guest with both an assigned vfio-pci device and intel-iommu enabled: qemu-system-x86_64: vtd_interrupt_remap_msi: MSI address low 32 bit invalid: 0x0 The error does not affect functionality of the guest since when we failed to translate we'll just silently continue (which makes sense since crashing the VM for this seems even worse), but still it's better to fix it up. Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Message-Id: <20190116030815.27273-5-peterx@redhat.com> [PMD: this patch was first (incorrectly) introduced as a56de056c91f8] Signed-off-by: Philippe Mathieu-Daudé --- target/i386/kvm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 9af4542fb8..beae1b99da 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -3894,7 +3894,7 @@ static QLIST_HEAD(, MSIRouteEntry) msi_route_list = \ static void kvm_update_msi_routes_all(void *private, bool global, uint32_t index, uint32_t mask) { - int cnt = 0; + int cnt = 0, vector; MSIRouteEntry *entry; MSIMessage msg; PCIDevice *dev; @@ -3902,11 +3902,19 @@ static void kvm_update_msi_routes_all(void *private, bool global, /* TODO: explicit route update */ QLIST_FOREACH(entry, &msi_route_list, list) { cnt++; + vector = entry->vector; dev = entry->dev; - if (!msix_enabled(dev) && !msi_enabled(dev)) { + if (msix_enabled(dev) && !msix_is_masked(dev, vector)) { + msg = msix_get_message(dev, vector); + } else if (msi_enabled(dev) && !msi_is_masked(dev, vector)) { + msg = msi_get_message(dev, vector); + } else { + /* + * Either MSI/MSIX is disabled for the device, or the + * specific message was masked out. Skip this one. + */ continue; } - msg = pci_get_msi_message(dev, entry->vector); kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev); } kvm_irqchip_commit_routes(kvm_state);