From nobody Tue Apr 30 17:48:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494310001985251.76039875432377; Mon, 8 May 2017 23:06:41 -0700 (PDT) Received: from localhost ([::1]:35200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7yIC-0006o0-KA for importer@patchew.org; Tue, 09 May 2017 02:06:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7yCj-0002Vn-1K for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7yCf-0001sJ-PZ for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54178) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d7yCf-0001ry-JL for qemu-devel@nongnu.org; Tue, 09 May 2017 02:00:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6843880C0A for ; Tue, 9 May 2017 06:00:56 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-50.pek2.redhat.com [10.72.5.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84A845C7A4; Tue, 9 May 2017 06:00:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6843880C0A Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6843880C0A From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 14:00:42 +0800 Message-Id: <1494309644-18743-2-git-send-email-peterx@redhat.com> In-Reply-To: <1494309644-18743-1-git-send-email-peterx@redhat.com> References: <1494309644-18743-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 09 May 2017 06:00:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/3] kvm: irqchip: trace changes on msi add/remove 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 , peterx@redhat.com, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It'll be nice to know which virq belongs to which device/vector when adding msi routes, so adding two more parameters for the add trace. Meanwhile, releasing virq has no tracing before. Add one for it. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- kvm-all.c | 4 +++- trace-events | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 90b8573..2598b1f 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1144,6 +1144,7 @@ void kvm_irqchip_release_virq(KVMState *s, int virq) } clear_gsi(s, virq); kvm_arch_release_virq_post(virq); + trace_kvm_irqchip_release_virq(virq); } =20 static unsigned int kvm_hash_msi(uint32_t data) @@ -1287,7 +1288,8 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector= , PCIDevice *dev) return -EINVAL; } =20 - trace_kvm_irqchip_add_msi_route(virq); + trace_kvm_irqchip_add_msi_route(dev ? dev->name : (char *)"N/A", + vector, virq); =20 kvm_add_routing_entry(s, &kroute); kvm_arch_add_msi_route_post(&kroute, vector, dev); diff --git a/trace-events b/trace-events index e582d63..f01ec05 100644 --- a/trace-events +++ b/trace-events @@ -69,8 +69,9 @@ kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d,= type 0x%x, arg %p" kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retri= eve ONEREG %" PRIu64 " from KVM: %s" kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set O= NEREG %" PRIu64 " to KVM: %s" kvm_irqchip_commit_routes(void) "" -kvm_irqchip_add_msi_route(int virq) "Adding MSI route virq=3D%d" +kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector= %d virq %d" kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=3D%d" +kvm_irqchip_release_virq(int virq) "virq %d" =20 # TCG related tracing (mostly disabled by default) # cpu-exec.c --=20 2.7.4 From nobody Tue Apr 30 17:48:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494309763838385.1021221517782; Mon, 8 May 2017 23:02:43 -0700 (PDT) Received: from localhost ([::1]:35175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7yEK-0003fm-Bb for importer@patchew.org; Tue, 09 May 2017 02:02:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7yCj-0002WU-UV for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7yCj-0001tC-7E for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41654) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d7yCi-0001st-VG for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAADA85547 for ; Tue, 9 May 2017 06:00:59 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-50.pek2.redhat.com [10.72.5.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id E901919652; Tue, 9 May 2017 06:00:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CAADA85547 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CAADA85547 From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 14:00:43 +0800 Message-Id: <1494309644-18743-3-git-send-email-peterx@redhat.com> In-Reply-To: <1494309644-18743-1-git-send-email-peterx@redhat.com> References: <1494309644-18743-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 09 May 2017 06:01:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/3] msix: trace control bit write op 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 , peterx@redhat.com, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Meanwhile, abstract a function to detect msix masked bit. Signed-off-by: Peter Xu Acked-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/pci/msix.c | 11 +++++++++-- hw/pci/trace-events | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index bb54e8b..fc5fe51 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -22,6 +22,7 @@ #include "hw/xen/xen.h" #include "qemu/range.h" #include "qapi/error.h" +#include "trace.h" =20 #define MSIX_CAP_LENGTH 12 =20 @@ -130,10 +131,14 @@ static void msix_handle_mask_update(PCIDevice *dev, i= nt vector, bool was_masked) } } =20 +static bool msix_masked(PCIDevice *dev) +{ + return dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & MSIX_MASKALL= _MASK; +} + static void msix_update_function_masked(PCIDevice *dev) { - dev->msix_function_masked =3D !msix_enabled(dev) || - (dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & MSIX_MASKALL_M= ASK); + dev->msix_function_masked =3D !msix_enabled(dev) || msix_masked(dev); } =20 /* Handle MSI-X capability config write. */ @@ -148,6 +153,8 @@ void msix_write_config(PCIDevice *dev, uint32_t addr, return; } =20 + trace_msix_write_config(dev->name, msix_enabled(dev), msix_masked(dev)= ); + was_masked =3D dev->msix_function_masked; msix_update_function_masked(dev); =20 diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 2b9cf24..83c8f5a 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -7,3 +7,6 @@ pci_update_mappings_add(void *d, uint32_t bus, uint32_t slo= t, uint32_t func, int # hw/pci/pci_host.c pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs= , unsigned val) "%s %02u:%u @0x%x -> 0x%x" pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned off= s, unsigned val) "%s %02u:%u @0x%x <- 0x%x" + +# hw/pci/msix.c +msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %= d masked %d" --=20 2.7.4 From nobody Tue Apr 30 17:48:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494309911055923.9915854950445; Mon, 8 May 2017 23:05:11 -0700 (PDT) Received: from localhost ([::1]:35185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7yGj-0005qZ-Ne for importer@patchew.org; Tue, 09 May 2017 02:05:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7yCn-0002Zm-FY for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7yCm-0001u1-Fi for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36542) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d7yCm-0001ts-9r for qemu-devel@nongnu.org; Tue, 09 May 2017 02:01:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 329174E334 for ; Tue, 9 May 2017 06:01:03 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-50.pek2.redhat.com [10.72.5.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D24860466; Tue, 9 May 2017 06:01:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 329174E334 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 329174E334 From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 14:00:44 +0800 Message-Id: <1494309644-18743-4-git-send-email-peterx@redhat.com> In-Reply-To: <1494309644-18743-1-git-send-email-peterx@redhat.com> References: <1494309644-18743-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 09 May 2017 06:01:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/3] kvm: irqchip: skip update msi when disabled 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 , peterx@redhat.com, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It's possible that one device kept its irqfd/virq there even when MSI/MSIX was disabled globally for that device. One example is virtio-net-pci (see commit f1d0f15a6 and virtio_pci_vq_vector_mask()). It is used as a fast path to avoid allocate/release irqfd/virq frequently when guest enables/disables MSIX. However, this fast path brought a problem to msi_route_list, that the device MSIRouteEntry is still dangling there even if MSIX disabled - then we cannot know which message to fetch, even if we can, the messages are meaningless. In this case, we can just simply ignore this entry. It's safe, since when MSIX is enabled again, we'll rebuild them no matter what. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1448813 Signed-off-by: Peter Xu --- target/i386/kvm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 55865db..554950d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -43,6 +43,7 @@ #include "standard-headers/asm-x86/hyperv.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" +#include "hw/pci/msix.h" #include "migration/migration.h" #include "exec/memattrs.h" #include "trace.h" @@ -3510,12 +3511,16 @@ static void kvm_update_msi_routes_all(void *private= , bool global, int cnt =3D 0; MSIRouteEntry *entry; MSIMessage msg; + PCIDevice *dev; + /* TODO: explicit route update */ QLIST_FOREACH(entry, &msi_route_list, list) { - cnt++; - msg =3D pci_get_msi_message(entry->dev, entry->vector); - kvm_irqchip_update_msi_route(kvm_state, entry->virq, - msg, entry->dev); + dev =3D entry->dev; + if (!msix_enabled(dev) && !msi_enabled(dev)) { + continue; + } + msg =3D pci_get_msi_message(dev, entry->vector); + kvm_irqchip_update_msi_route(kvm_state, entry->virq, msg, dev); } kvm_irqchip_commit_routes(kvm_state); trace_kvm_x86_update_msi_routes(cnt); --=20 2.7.4