From patchwork Fri May 19 11:21:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 764622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wTm4w2VGmz9s7k for ; Fri, 19 May 2017 21:28:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hEzhN0B+"; dkim-atps=neutral Received: from localhost ([::1]:57954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBg4b-0001In-Q2 for incoming@patchwork.ozlabs.org; Fri, 19 May 2017 07:27:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBfyJ-0004LM-CJ for qemu-devel@nongnu.org; Fri, 19 May 2017 07:21:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBfyI-0000wE-AT for qemu-devel@nongnu.org; Fri, 19 May 2017 07:21:27 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:32772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dBfyI-0000vy-3X for qemu-devel@nongnu.org; Fri, 19 May 2017 07:21:26 -0400 Received: by mail-wm0-x244.google.com with SMTP id b84so1792230wmh.0 for ; Fri, 19 May 2017 04:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=T6bvJg/zc/9Mpl3ah40Cn4ahjkiLMrxR5IZSt98CIm8=; b=hEzhN0B+RofqsOYq4Xj74TvGtnaDNsftyPQaya2i7S8VhzQoOOeVYX82VvmOByzyVm zX4M8QsgB0R8tg8HiOzfEt9Sx+p/v5mZE+s4VbLg3fN1gmxRvnut2lVHSxzTq6oqHzbT ANxTq792L3GZqrB+atUuqfHQuV/fMvFYVRrVt95LDRw7tJqNQAprqn2sjlr/lf8UqjTL Qp5NkrutvmugtT1lv4Xp49dUEG0SKeTaMKRrcK3eGPX1g04U23FvFBoqwzu6ri2iIkei 2zskcKANlWNHskJaOMoOZ19DMTbz185uIyoUWn81MABXVT3tqKoECjudzlREPF3C6/8Q JkZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=T6bvJg/zc/9Mpl3ah40Cn4ahjkiLMrxR5IZSt98CIm8=; b=de1TTTMri88bKqjIynGdRZ5Mb55Q6sV83SaA8G178yajP4XxDjRWoOBNneMGmCLyox tsQKzsWbtkftTI8qbJBK/T4eRUlAfFRnHHIzgzyBUNeO78ij629Rme2Qh5qhpqa9pbQr nmEUCuBuzOxcys7P2FpRdFLUkkMHMXuUAX59aAqCa9A52Y6Gq/ixUKSBRzlrFUiBvv00 sHmT00K1enaxalpTDnjZg4UCPzFHfTU67AAjAVGetkEGpna8b0qTrztjl9ArJrBxxmTF WahGtrHVpgvagWUpD+TASHkAysc5MrOl5958IElZVzP4wGrQJj9fSAKmkbioYTFFSG7A 4a7Q== X-Gm-Message-State: AODbwcD48odIdcSmNN/anGeNsJjGSXLeu/3bjl7jDts81GrOZlHV9Q84 PnLQ+JHQyn74L8HLdDQ= X-Received: by 10.28.214.211 with SMTP id n202mr5924522wmg.105.1495192884933; Fri, 19 May 2017 04:21:24 -0700 (PDT) Received: from 640k.lan (94-39-157-43.adsl-ull.clienti.tiscali.it. [94.39.157.43]) by smtp.gmail.com with ESMTPSA id v65sm2640095wmv.5.2017.05.19.04.21.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 04:21:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 13:21:00 +0200 Message-Id: <1495192872-27667-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1495192872-27667-1-git-send-email-pbonzini@redhat.com> References: <1495192872-27667-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 08/20] 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: Peter Xu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu 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=1448813 Signed-off-by: Peter Xu Message-Id: <1494309644-18743-4-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 011d4a5..82c72d2 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/blocker.h" #include "exec/memattrs.h" #include "trace.h" @@ -3510,12 +3511,17 @@ static void kvm_update_msi_routes_all(void *private, bool global, int cnt = 0; MSIRouteEntry *entry; MSIMessage msg; + PCIDevice *dev; + /* TODO: explicit route update */ QLIST_FOREACH(entry, &msi_route_list, list) { cnt++; - msg = pci_get_msi_message(entry->dev, entry->vector); - kvm_irqchip_update_msi_route(kvm_state, entry->virq, - msg, entry->dev); + dev = entry->dev; + 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); trace_kvm_x86_update_msi_routes(cnt);