From: Yong Wang <yongwang@vmware.com>
To: dev@dpdk.org
Cc: anatoly.burakov@intel.com, dan@kernelim.com,
thomas.monjalon@6wind.com, Yong Wang <yongwang@vmware.com>,
Ronghua Zhang <rzhang@vmware.com>
Subject: [dpdk-dev] [PATCH v2] vfio: fix pci_vfio_map_resource
Date: Thu, 14 Jul 2016 17:15:10 -0700 [thread overview]
Message-ID: <1468541710-47751-1-git-send-email-yongwang@vmware.com> (raw)
In-Reply-To: <20160714153415.GA8329@gmail.com>
The offset of the 2nd mmap() when mapping the region after msix_bar
needs to take region address into consideration as mmap() takes
address that is resource-relative instead of bar-relative. This is
exposed when binding vmxnet3 to vfio-pci.
Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables")
Signed-off-by: Yong Wang <yongwang@vmware.com>
Signed-off-by: Ronghua Zhang <rzhang@vmware.com>
---
v2:
* Addressed review comment from Dan
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 46cd683..bf7cf61 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -431,7 +431,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
} else {
memreg[0].offset = reg.offset;
memreg[0].size = table_start;
- memreg[1].offset = table_end;
+ memreg[1].offset = reg.offset + table_end;
memreg[1].size = reg.size - table_end;
RTE_LOG(DEBUG, EAL,
@@ -474,7 +474,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
/* if there's a second part, try to map it */
if (map_addr != MAP_FAILED
&& memreg[1].offset && memreg[1].size) {
- void *second_addr = RTE_PTR_ADD(bar_addr, memreg[1].offset);
+ void *second_addr = RTE_PTR_ADD(bar_addr,
+ memreg[1].offset - reg.offset);
map_addr = pci_map_resource(second_addr,
vfio_dev_fd, memreg[1].offset,
memreg[1].size,
--
1.9.1
next prev parent reply other threads:[~2016-07-15 0:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 22:26 [dpdk-dev] [PATCH 1/2] " Yong Wang
2016-07-07 22:26 ` [dpdk-dev] [PATCH 2/2] vfio: fix coding style Yong Wang
2016-07-14 13:25 ` [dpdk-dev] [PATCH 1/2] vfio: fix pci_vfio_map_resource Thomas Monjalon
2016-07-14 14:50 ` Burakov, Anatoly
2016-07-14 15:34 ` Dan Aloni
2016-07-15 0:15 ` Yong Wang [this message]
2016-07-15 13:05 ` [dpdk-dev] [PATCH v2] " Burakov, Anatoly
2016-07-15 15:32 ` Thomas Monjalon
2016-07-15 16:42 ` Thomas Monjalon
2016-07-15 16:56 ` Thomas Monjalon
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=1468541710-47751-1-git-send-email-yongwang@vmware.com \
--to=yongwang@vmware.com \
--cc=anatoly.burakov@intel.com \
--cc=dan@kernelim.com \
--cc=dev@dpdk.org \
--cc=rzhang@vmware.com \
--cc=thomas.monjalon@6wind.com \
/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).