From: Chao Gao <chao.gao@intel.com>
To: xen-devel@lists.xen.org
Cc: "Kevin Tian" <kevin.tian@intel.com>,
"Venu Busireddy" <venu.busireddy@oracle.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Crawford Eric R" <Eric.R.Crawford@intel.com>,
"Chao Gao" <chao.gao@intel.com>
Subject: [PATCH v4] VT-d: fix VF of RC integrated PF matched to wrong VT-d unit
Date: Fri, 30 Jun 2017 09:17:06 +0800 [thread overview]
Message-ID: <1498785426-9093-1-git-send-email-chao.gao@intel.com> (raw)
The problem is for a VF of RC integrated PF (e.g. PF's BDF is 00:02.0),
we would wrongly use 00:00.0 to search VT-d unit.
From SRIOV spec REV 1.0 section 3.7.3, it says:
"ARI is not applicable to Root Complex integrated Endpoints; all other
SR-IOV Capable Devices (Devices that include at least one PF) shall
implement the ARI Capability in each Function.". So PFs can be classified to
two kinds: one is RC integrated PF and the other is non-RC integrated PF. The
former can't support ARI and the latter shall support ARI. For Extended
Functions, one traditional function's BDF should be used to search VT-d unit.
And according to PCIe spec, Extened Function means within an ARI device, a
Function whose Function Number is greater than 7. Thus, the former can't be an
extended function, while the latter is as long as its devfn > 7, this check is
exactly what the original code did; The original code wasn't aware the former.
This patch directly looks up the 'is_extfn' field of PF's struct pci_dev
to decide whether the PF is a extended function.
Reported-by: Crawford, Eric R <Eric.R.Crawford@intel.com>
Signed-off-by: Chao Gao <chao.gao@intel.com>
---
v3:
- access pf's struct pci_pdev between pcidevs_lock() and pcidevs_unlock()
---
xen/drivers/passthrough/vtd/dmar.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c
index 82040dd..27ff471 100644
--- a/xen/drivers/passthrough/vtd/dmar.c
+++ b/xen/drivers/passthrough/vtd/dmar.c
@@ -218,8 +218,17 @@ struct acpi_drhd_unit *acpi_find_matched_drhd_unit(const struct pci_dev *pdev)
}
else if ( pdev->info.is_virtfn )
{
+ struct pci_dev *physfn;
+
bus = pdev->info.physfn.bus;
- devfn = PCI_SLOT(pdev->info.physfn.devfn) ? 0 : pdev->info.physfn.devfn;
+ /*
+ * 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();
}
else
{
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2017-06-30 1:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 1:17 Chao Gao [this message]
2017-06-30 9:19 ` [PATCH v4] VT-d: fix VF of RC integrated PF matched to wrong VT-d unit Tian, Kevin
2017-06-30 10:40 ` Jan Beulich
2017-07-03 4:36 ` Chao Gao
2017-07-05 2:46 ` Tian, Kevin
2017-07-05 4:28 ` Chao Gao
2017-07-05 5:18 ` Tian, Kevin
2017-07-05 7:56 ` Chao Gao
2017-07-05 8:06 ` Tian, Kevin
2017-07-05 8:19 ` Jan Beulich
2017-07-05 8:29 ` Roger Pau Monné
2017-07-05 8:45 ` Chao Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1498785426-9093-1-git-send-email-chao.gao@intel.com \
--to=chao.gao@intel.com \
--cc=Eric.R.Crawford@intel.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=roger.pau@citrix.com \
--cc=venu.busireddy@oracle.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).