From patchwork Tue Jul 25 10:48:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9861749 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 04B24602B1 for ; Tue, 25 Jul 2017 10:52:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71362861B for ; Tue, 25 Jul 2017 10:52:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBA522862A; Tue, 25 Jul 2017 10:52:36 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35DA42861B for ; Tue, 25 Jul 2017 10:52:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZxPh-0004tJ-SP; Tue, 25 Jul 2017 10:50:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZxPg-0004hQ-IR for xen-devel@lists.xen.org; Tue, 25 Jul 2017 10:50:04 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 69/8A-09901-B5227795; Tue, 25 Jul 2017 10:50:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVywNykWDdaqTz SoG0Sn8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnH97VaWgksaFTcvb2NtYHyg1MXIxSEkMJ1R omPPJqYuRk4OCQFeiSPLZrBC2AESH/9tYAexhQTKJaZPfQ5WwyagLHHxay8biC0iIC1x7fNlR pBBzAL/GSUmN88GaxAWCJVoWdPPCGKzCKhKnFr/DqyBV8BJ4u6p21ALFCSmPHzPPIGRewEjwy pG9eLUorLUIl1zvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MQP8yAMEOxpmX/Q8 xSnIwKYnypu8qixTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwWujWB4pJFiUmp5akZaZAww0mLQE B4+SCO91BaA0b3FBYm5xZjpE6hSjMceG1eu/MHG8mvD/G5MQS15+XqqUOO8qkFIBkNKM0jy4Q bAIuMQoKyXMywh0mhBPQWpRbmYJqvwrRnEORiVh3ucgU3gy80rg9r0COoUJ6JQ5M0pBTilJRE hJNTCqRy9jYpRn0oz9Lmu/1GuFTwq/Rw7bytnFj+TUmxVijQvsL6Wo1oV4HZsgmDUj7P5klzq v5x49ovs5rDIObRHVE5wkL/Gnu8Ahb51yTuQnFbvaJ+fFqhJZpxqnJ+WfWt94/uG/A+rvVv0t Kw67EnRKop7p4+foN+q1m/IYmcNUlWJ5f3M8UWIpzkg01GIuKk4EAB0985V7AgAA X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1500979801!108926051!1 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30399 invoked from network); 25 Jul 2017 10:50:02 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Jul 2017 10:50:02 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 03:50:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,411,1496127600"; d="scan'208"; a="1199094652" Received: from skl-2s3.sh.intel.com ([10.239.48.12]) by fmsmga002.fm.intel.com with ESMTP; 25 Jul 2017 03:49:29 -0700 From: Chao Gao To: xen-devel@lists.xen.org Date: Tue, 25 Jul 2017 18:48:26 +0800 Message-Id: <1500979706-69496-1-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 Cc: Kevin Tian , Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Crawford Eric R , Chao Gao Subject: [Xen-devel] [PATCH] Revert "VT-d: fix VF of RC integrated PF matched to wrong VT-d unit" X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 89df98b77d28136c4d7aade13a1c8bc154d2919f, which incurs Xen crash when loading VF driver. The reason seems that pci_get_pdev() can't be called when interrupt is disabled. I don't have a quick solution to fix this; therefore revert this patch to let common cases work well. As to the corner case I intended to fix, I will propose another solution later. Below is the call trace of Xen crash: (XEN) Xen BUG at spinlock.c:47 (XEN) ----[ Xen-4.10-unstable x86_64 debug=y Tainted: C ]---- (XEN) CPU: 2 (XEN) RIP: e008:[] spinlock.c#check_lock+0x3c/0x40 (XEN) RFLAGS: 0000000000010046 CONTEXT: hypervisor (d0v2) (XEN) rax: 0000000000000000 rbx: ffff82d08043b9c8 rcx: 0000000000000001 (XEN) rdx: 0000000000000000 rsi: 0000000000000000 rdi: ffff82d08043b9ce (XEN) rbp: ffff83043c47fa50 rsp: ffff83043c47fa50 r8: 0000000000000000 (XEN) r9: 0000000000000000 r10: 0000000000000000 r11: 0000ffff0000ffff (XEN) r12: 0000000000000001 r13: 0000000000000000 r14: 0000000000000072 (XEN) r15: ffff83043c006c00 cr0: 0000000080050033 cr4: 00000000003526e0 (XEN) cr3: 000000081b39a000 cr2: ffff88016c058548 (XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: e010 cs: e008 (XEN) Xen code around (spinlock.c#check_lock+0x3c/0x40): (XEN) 98 83 f2 01 39 d0 75 02 <0f> 0b 5d c3 55 48 89 e5 f0 ff 05 a1 f6 1e 00 5d (XEN) Xen stack trace from rsp=ffff83043c47fa50: (XEN) ffff83043c47fa68 ffff82d080235234 0000000000000005 ffff83043c47fa78 (XEN) ffff82d080251df3 ffff83043c47fab8 ffff82d080251e80 ffff83043c47fac8 (XEN) ffff83043c422580 ffff83042e973cd0 0000000000000005 ffff83042e9609e0 (XEN) 0000000000000072 ffff83043c47fae8 ffff82d08025795a ffff83043c47fb18 (XEN) ffff83043c47fc18 ffff83043c47fc18 ffff83042e9609e0 ffff83043c47fba8 (XEN) ffff82d080259be1 ffff83043c47fb10 ffff82d08023516b 0000000000000246 (XEN) ffff83043c47fb28 0000000000000206 0000000000000002 ffff83043c47fb58 (XEN) ffff82d080290e38 ffff83042e973cd0 ffff83043c532000 ffff83043c532000 (XEN) ffff83042e973db0 ffff83043c47fb68 ffff82d080354dd0 ffff83043c47fc18 (XEN) ffff82d080274e07 0000000000000040 ffff83042e9609e0 ffff83043c47fc18 (XEN) ffff83043c47fc18 0000000000000072 ffff83043c006c00 ffff83043c47fbb8 (XEN) ffff82d0802526f7 ffff83043c47fc08 ffff82d080273c17 ffff83043ff99d90 (XEN) ffff83043c006c00 ffff83043c47fc08 ffff83043c006c00 ffff83042e9609e0 (XEN) ffff83043c47fc18 0000000000000072 ffff83043c006c00 ffff83043c47fc48 (XEN) ffff82d0802754d1 00000000feeff00c 00000fff000041ca 0000000000000002 (XEN) ffff83042e9609e0 ffff83042e973cd0 0000000000000002 ffff83043c47fc88 (XEN) ffff82d0802755a8 ffff83043c47fc70 0000000000000246 ffff83043c532000 (XEN) 000000000000006c ffff83043c006c00 0000000000000000 ffff83043c47fd28 (XEN) ffff82d080279b4f ffff83043c532000 ffff83043c47fe00 ffff83043c47fcd8 (XEN) ffff83042e973d20 ffff83043c47fcf0 ffff830400000325 0000000000000246 (XEN) Xen call trace: (XEN) [] spinlock.c#check_lock+0x3c/0x40 (XEN) [] _spin_is_locked+0x11/0x4d (XEN) [] pcidevs_locked+0x10/0x17 (XEN) [] pci_get_pdev+0x2f/0xfd (XEN) [] acpi_find_matched_drhd_unit+0x4d/0x11a (XEN) [] msi_msg_write_remap_rte+0x2f/0x749 (XEN) [] iommu_update_ire_from_msi+0x36/0x38 (XEN) [] msi.c#write_msi_msg+0x3f/0x188 (XEN) [] __setup_msi_irq+0x3a/0x5c (XEN) [] setup_msi_irq+0xb5/0xf7 (XEN) [] map_domain_pirq+0x445/0x653 (XEN) [] allocate_and_map_msi_pirq+0x10d/0x184 (XEN) [] physdev_map_pirq+0x1f8/0x26b (XEN) [] do_physdev_op+0x595/0x110f (XEN) [] pv_hypercall+0x1ef/0x42c (XEN) [] entry.o#test_all_events+0/0x30 (XEN) (XEN) (XEN) **************************************** (XEN) Panic on CPU 2: (XEN) Xen BUG at spinlock.c:47 (XEN) **************************************** (XEN) (XEN) Reboot in five seconds... Signed-off-by: Chao Gao Acked-by: Andrew Cooper --- xen/drivers/passthrough/vtd/dmar.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c index 8a3e240..82040dd 100644 --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -218,17 +218,8 @@ struct acpi_drhd_unit *acpi_find_matched_drhd_unit(const struct pci_dev *pdev) } else if ( pdev->info.is_virtfn ) { - const struct pci_dev *physfn; - bus = pdev->info.physfn.bus; - /* - * Use 0 as 'devfn' to search VT-d unit when the physical function - * is an Extended Function. - */ - pcidevs_lock(); - physfn = pci_get_pdev(pdev->seg, bus, pdev->info.physfn.devfn); - devfn = (physfn && physfn->info.is_extfn) ? 0 : pdev->info.physfn.devfn; - pcidevs_unlock(); + devfn = PCI_SLOT(pdev->info.physfn.devfn) ? 0 : pdev->info.physfn.devfn; } else {