From patchwork Sat Sep 28 14:20:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 11165415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 962CD17EE for ; Sat, 28 Sep 2019 14:22:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7132320815 for ; Sat, 28 Sep 2019 14:22:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="j0QHtM6c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7132320815 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb4-0003jr-GZ; Sat, 28 Sep 2019 14:21:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEDb3-0003jX-EU for xen-devel@lists.xenproject.org; Sat, 28 Sep 2019 14:21:17 +0000 X-Inumbo-ID: 39f16b46-e1fb-11e9-97fb-bc764e2007e4 Received: from out5-smtp.messagingengine.com (unknown [66.111.4.29]) by localhost (Halon) with ESMTPS id 39f16b46-e1fb-11e9-97fb-bc764e2007e4; Sat, 28 Sep 2019 14:21:13 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 9149821C1C; Sat, 28 Sep 2019 10:21:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 28 Sep 2019 10:21:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=v7bttf3yQOOR1SZPxB6rw3qy/co3pMgStgeM8sWnq as=; b=j0QHtM6cJwEJK8Oe4DumSwdn3mmcdrKRopVeCd1s9dziVLGYGBZcQWXXT Zsw4hrxLn5Jsr7J5SaBShaNCNK8/pwPuSp+Zhkquyv6RwQTkqMMxKB69lU6Uawb4 W5/dGoaPii1XkDyKt1wTKWUjVypokMxdktPLyFCOqeu0OFLUjqmHSyuedMUOn40q ng/J9FHp3D3+LDmpW3n4k1YIxrQKea2hQ45FUXo+n9FAIikfS+NHnmbtC8w+qMtw cR3J4yHLs/VktJI3uaYdfz8WT9TNN8urBuFkrsgmciUCf3CpoF7T+UIq0o7Uiavn Q70cRxtOOuskE+XhYpoYKAmIeq40w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeekgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 8966CD60057; Sat, 28 Sep 2019 10:21:12 -0400 (EDT) From: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Sat, 28 Sep 2019 16:20:35 +0200 Message-Id: <38b059a9d0a923c7d3f7eb24b675f6ab43863340.1569680095.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v8 2/4] libxl: do not attach xen-pciback to HVM domain, if stubdomain is in use X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" HVM domains use IOMMU and device model assistance for communicating with PCI devices, xen-pcifront/pciback isn't directly needed by HVM domain. But pciback serve also second function - it reset the device when it is deassigned from the guest and for this reason pciback needs to be used with HVM domain too. When HVM domain has device model in stubdomain, attaching xen-pciback to the target domain itself may prevent attaching xen-pciback to the (PV) stubdomain, effectively breaking PCI passthrough. Fix this by attaching pciback only to one domain: if PV stubdomain is in use, let it be stubdomain (the commit prevents attaching device to target HVM in this case); otherwise, attach it to the target domain. Signed-off-by: Marek Marczykowski-Górecki Acked-by: Wei Liu --- Changes in v2: - previously called "libxl: attach xen-pciback only to PV domains" - instead of excluding all HVMs, change the condition to what actually matters here - check if stubdomain is in use; this way xen-pciback is always in use (either for the target domain, or it's stubdomain), fixing PCI reset by xen-pciback concerns Changes in v3: - adjust commit message Changes in v8: - rebase on staging --- tools/libxl/libxl_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 2edff64..ac597a5 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -1399,7 +1399,7 @@ out_no_irq: } } - if (!starting) + if (!starting && !libxl_get_stubdom_id(CTX, domid)) rc = libxl__device_pci_add_xenstore(gc, domid, pcidev, starting); else rc = 0; @@ -1697,7 +1697,7 @@ static void add_pcidevs_done(libxl__egc *egc, libxl__multidev *multidev, libxl_domid domid = apds->domid; libxl__ao_device *aodev = apds->outer_aodev; - if (d_config->num_pcidevs > 0) { + if (d_config->num_pcidevs > 0 && !libxl_get_stubdom_id(CTX, domid)) { rc = libxl__create_pci_backend(gc, domid, d_config->pcidevs, d_config->num_pcidevs); if (rc < 0) {