* [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug @ 2016-12-01 11:42 Haifeng Lin 2016-12-06 2:28 ` Yuanhan Liu 0 siblings, 1 reply; 4+ messages in thread From: Haifeng Lin @ 2016-12-01 11:42 UTC (permalink / raw) To: dev, yuanhan.liu, maxime.coquelin; +Cc: jerry.lilijun When reg_size < page_size the function read in rte_mem_virt2phy would not return, becausue host_user_addr is invalid. Signed-off-by: Haifeng Lin <haifeng.lin@huawei.com> --- v2: fix TYPO_SPELLING warning --- 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] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug 2016-12-01 11:42 [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug Haifeng Lin @ 2016-12-06 2:28 ` Yuanhan Liu 2016-12-06 5:40 ` linhaifeng 0 siblings, 1 reply; 4+ messages in thread From: Yuanhan Liu @ 2016-12-06 2:28 UTC (permalink / raw) To: Haifeng Lin; +Cc: dev, maxime.coquelin, jerry.lilijun, stable On Thu, Dec 01, 2016 at 07:42:02PM +0800, Haifeng Lin wrote: > When reg_size < page_size the function read in > rte_mem_virt2phy would not return, becausue > host_user_addr is invalid. > > Signed-off-by: Haifeng Lin <haifeng.lin@huawei.com> > --- > v2: > fix TYPO_SPELLING warning > --- > 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; I'd use RTE_MIN(reg_size, page_size) here. Also, this patch miss a fixline (http://dpdk.org/dev): Fixes: e246896178e6 ("vhost: get guest/host physical address mappings") Applied to dpdk-next-virtio, with above fixed. Thanks for the fix! --yliu > 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] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug 2016-12-06 2:28 ` Yuanhan Liu @ 2016-12-06 5:40 ` linhaifeng 2016-12-06 5:44 ` Yuanhan Liu 0 siblings, 1 reply; 4+ messages in thread From: linhaifeng @ 2016-12-06 5:40 UTC (permalink / raw) To: Yuanhan Liu; +Cc: dev, maxime.coquelin, jerry.lilijun, stable 在 2016/12/6 10:28, Yuanhan Liu 写道: > On Thu, Dec 01, 2016 at 07:42:02PM +0800, Haifeng Lin wrote: >> When reg_size < page_size the function read in >> rte_mem_virt2phy would not return, becausue >> host_user_addr is invalid. >> >> Signed-off-by: Haifeng Lin <haifeng.lin@huawei.com> >> --- >> v2: >> fix TYPO_SPELLING warning >> --- >> 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; > > I'd use RTE_MIN(reg_size, page_size) here. Also, this patch miss a > fixline (http://dpdk.org/dev): > > Fixes: e246896178e6 ("vhost: get guest/host physical address mappings") > > Applied to dpdk-next-virtio, with above fixed. > > Thanks for the fix! > > --yliu > >> 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 >> > > . > Hi,yliu The bug would happen like this: ----------------------------- | region | ----------------------------- : : remain : -------------- --------------- | hugepage | ... | hugepage | -------------- --------------- so the remain reg_size maybe smaller than a hugepage size, and "reg_size -= page_size" is not correct. apply all the patch? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug 2016-12-06 5:40 ` linhaifeng @ 2016-12-06 5:44 ` Yuanhan Liu 0 siblings, 0 replies; 4+ messages in thread From: Yuanhan Liu @ 2016-12-06 5:44 UTC (permalink / raw) To: linhaifeng; +Cc: dev, maxime.coquelin, jerry.lilijun, stable On Tue, Dec 06, 2016 at 01:40:52PM +0800, linhaifeng wrote: > 在 2016/12/6 10:28, Yuanhan Liu 写道: > > On Thu, Dec 01, 2016 at 07:42:02PM +0800, Haifeng Lin wrote: > >> When reg_size < page_size the function read in > >> rte_mem_virt2phy would not return, becausue > >> host_user_addr is invalid. > >> > >> Signed-off-by: Haifeng Lin <haifeng.lin@huawei.com> > >> --- > >> v2: > >> fix TYPO_SPELLING warning > >> --- > >> 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; > > > > I'd use RTE_MIN(reg_size, page_size) here. Also, this patch miss a > > fixline (http://dpdk.org/dev): > > > > Fixes: e246896178e6 ("vhost: get guest/host physical address mappings") > > > > Applied to dpdk-next-virtio, with above fixed. > > > > Thanks for the fix! > > > > --yliu > > > >> 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 > >> > > > > . > > > > Hi,yliu > The bug would happen like this: > > ----------------------------- > | region | > ----------------------------- > : : remain : > -------------- --------------- > | hugepage | ... | hugepage | > -------------- --------------- > so the remain reg_size maybe smaller than a hugepage size, and "reg_size -= page_size" is not correct. > > apply all the patch? Yes, I actually have applied the whole patch, with some minor fixes stated above. It makes no senes to apply partial of one patch after all. --yliu ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-06 5:43 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-12-01 11:42 [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug Haifeng Lin 2016-12-06 2:28 ` Yuanhan Liu 2016-12-06 5:40 ` linhaifeng 2016-12-06 5:44 ` Yuanhan Liu
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).