* [dpdk-dev] [PATCH] vhost: fix add_guest_pages bug
@ 2016-12-01 10:22 Haifeng Lin
0 siblings, 0 replies; only message in thread
From: Haifeng Lin @ 2016-12-01 10:22 UTC (permalink / raw)
To: dev, yuanhan.liu, maxime.coquelin; +Cc: Haifeng Lin
When reg_size < page_size the function read in
rte_mem_virt2phy would not return, becasue gpa
is invalid.
Signed-off-by: Haifeng Lin <haifeng.lin@huawei.com>
---
lib/librte_vhost/vhost_user.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 6b83c15..ce55e85 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -447,14 +447,14 @@ add_guest_pages(struct virtio_net *dev, struct virtio_memory_region *reg,
reg_size -= size;
while (reg_size > 0) {
+ size = reg_size >= page_size ? page_size : reg_size;
host_phys_addr = rte_mem_virt2phy((void *)(uintptr_t)
host_user_addr);
- add_one_guest_page(dev, guest_phys_addr, host_phys_addr,
- page_size);
+ add_one_guest_page(dev, guest_phys_addr, host_phys_addr, size);
- host_user_addr += page_size;
- guest_phys_addr += page_size;
- reg_size -= page_size;
+ host_user_addr += size;
+ guest_phys_addr += size;
+ reg_size -= size;
}
}
--
1.8.3.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-12-01 10:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-01 10:22 [dpdk-dev] [PATCH] vhost: fix add_guest_pages bug Haifeng Lin
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).