vhost: fix get hpa fail from guest pages
PATCH 1/1 vhost: fix get hpa fail from guest pages
When processing front-end memory regions messages,
vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode
and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.
--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)
lib/vhost/vhost.h +16 -2
@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(const void *p1,return 0 ; } +static __rte_always_inline int guest_page_rangecmp(const void *p1, const void *p2) +{ +const struct guest_page *page1 = (const struct guest_page *)p1; +const struct guest_page *page2 = (const struct guest_page *)p2; + +if (page1->guest_phys_addr >= page2->guest_phys_addr) { +if (page1->guest_phys_addr < page2->guest_phys_addr + page2->size) +return 0 ; +else +return 1 ; + }else +return -1 ; +} + static __rte_always_inline rte_iova_tgpa_to_first_hpa (struct virtio_net *dev,uint64_t gpa,uint64_t gpa_size,uint64_t *hpa_size)
@@ -597,9 +611,9 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa, *hpa_size = gpa_size;if (dev->nr_guest_pages >=VHOST_BINARY_SEARCH_THRESH ) { - key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page =bsearch (&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); +sizeof (struct guest_page ), guest_page_rangecmp);if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size) {
lib/vhost/vhost_user.c +11 -4
@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,if (dev->nr_guest_pages >0 ) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + last_page->size) { +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + } + +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page->guest_phys_addr + last_page->size) { + last_page->size += size; +return 0 ; + } } }
Signature · 1 line
2.25.1
Quoted 75 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages,
vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode
and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical address mappings")Fixes 6563cf92380 ("vhost: fix async copy on multi-page buffers")Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h +14
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(constvoid *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void *p1, const void *p2) +{ +const struct guest_page *page1 = (const struct guest_page *)p1; +const struct guest_page *page2 = (const struct guest_page *)p2; + +if (page1->guest_phys_addr >= page2->guest_phys_addr) { +if (page1->guest_phys_addr < page2->guest_phys_addr + page2->size) +return 0 ; +else +return 1 ; + }else +return -1 ; +} +static __rte_always_inline rte_iova_tgpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,lib/vhost/vhost.h +2
-2uint64_t gpa_size, uint64_t *hpa_size)@@ -597,9 +611,9 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa, *hpa_size = gpa_size;if (dev->nr_guest_pages >=VHOST_BINARY_SEARCH_THRESH ) { - key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page =bsearch (&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); +sizeof (struct guest_page ), guest_page_rangecmp);if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size) {lib/vhost/vhost_user.c +0
-0@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t · line 1008
Quoted 10 lines
lib/vhost/vhost_user.c +5
-4-if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + last_page->size) { +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }
This makes me think about a question: In IOVA_VA mode, what ensures HPA and GPA are both contiguous?
Maxime & Yuan, any thought?
Thanks,
Chenbo
Quoted 12 lines
lib/vhost/vhost_user.c +6
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page->guest_phys_addr + last_page->size) { + last_page->size += size; +return 0 ; + }lib/vhost/vhost_user.c +0
-1} } --2.25.1
Quoted 92 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, November 15, 2021 4:04 PM
To: Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 7 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang,YuanX
Quoted 25 lines
<[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages,
vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode
and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical address mappings")Fixes 6563cf92380 ("vhost: fix async copy on multi-page buffers")Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h +0
-0lib/vhost/vhost.h static __rte_always_inline int guest_page_addrcmp(const · line 591
Quoted 5 lines
lib/vhost/vhost.h +1
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(constvoid *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void *p1, constvoid
Quoted 44 lines
lib/vhost/vhost.h +13
-0*p2) +{ +const struct guest_page *page1 = (const struct guest_page *)p1; +const struct guest_page *page2 = (const struct guest_page *)p2; + +if (page1->guest_phys_addr >= page2->guest_phys_addr) { +if (page1->guest_phys_addr < page2->guest_phys_addr + page2->size) +return 0 ; +else +return 1 ; + }else +return -1 ; +} +static __rte_always_inline rte_iova_tgpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,lib/vhost/vhost.h +2
-2uint64_t gpa_size, uint64_t *hpa_size)@@ -597,9 +611,9 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa, *hpa_size = gpa_size;if (dev->nr_guest_pages >=VHOST_BINARY_SEARCH_THRESH ) { - key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page =bsearch (&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); +sizeof (struct guest_page ), guest_page_rangecmp);if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size) {lib/vhost/vhost_user.c +1
-4@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + last_page->size) {
Quoted 8 lines
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, · line 1006
Quoted 4 lines
lib/vhost/vhost_user.c +4
-0+if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }This makes me think about a question: In
IOVA_VAmode, what ensures HPA and GPA are
both contiguous?
When I wrote this email, I thought host_phys_addr is HPA but in VA mode, it's Host IOVA, aka VA in DPDK's case. So in most cases GPA and VA will be both contiguous when the contiguous pages are all in one memory region. But I think we should not make such assumption as some vhost master may send GPA-contiguous pages in different memory region, then the VA after mmap may not be contiguous.
Maxime, What do you think?
Thanks,
Chenbo
Quoted 18 lines
Maxime & Yuan, any thought?
Thanks,
ChenboQuoted 12 lines
lib/vhost/vhost_user.c +6
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page->guest_phys_addr + last_page->size) { + last_page->size += size; +return 0 ; + }lib/vhost/vhost_user.c +0
-1} } --2.25.1
Hi Chenbo,
Quoted 118 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 16:07
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 6 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, November 15, 2021 4:04 PM
To: Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He,Xingguang
Quoted 45 lines
<[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 8 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang,YuanX
Quoted 26 lines
<[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages, vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical addressmappings")
Fixes 6563cf92380 ("vhost: fix async copy on multi-page buffers")Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h index renamed from lib/vhost/vhost.h +0
-0
7085e0885c..b3f0c1d07c100644lib/vhost/vhost.h static __rte_always_inline int · line 592
Quoted 6 lines
lib/vhost/vhost.h +2
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(const void *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void *p1, +constvoid
Quoted 7 lines
lib/vhost/vhost.h static __rte_always_inline int guest_page_addrcmp(const void *p1,
Quoted 7 lines
lib/vhost/vhost.h +6
-0*p2) +{ + const struct guest_page *page1 = (const struct guest_page *)p1; + const struct guest_page *page2 = (const struct guest_page *)p2; + + if (page1->guest_phys_addr >= page2->guest_phys_addr) { + if (page1->guest_phys_addr < page2->guest_phys_addr +
page2->size)Quoted 12 lines
Quoted 12 lines
lib/vhost/vhost.h +7
-0+return 0 ; + else + return 1; + }else +return -1 ; +} + static __rte_always_inline rte_iova_t gpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,
uint64_tgpa_size,uint64_t*hpa_size) @@ -597,9 +611,9 @@
gpa_to_first_hpa(structvirtio_net*dev,uint64_tgpa,Quoted 10 lines
lib/vhost/vhost.h gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
Quoted 10 lines
lib/vhost/vhost.h +2
-2*hpa_size = gpa_size;if (dev->nr_guest_pages >=VHOST_BINARY_SEARCH_THRESH ) { - key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page =bsearch (&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); +sizeof (struct guest_page ), guest_page_rangecmp);if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size){ diff --git
Quoted 15 lines
Quoted 15 lines
a/lib/vhost/vhost_user.cb/lib/vhost/vhost_user.cindexa781346c4d..7d58fde458100644lib/vhost/vhost_user.c +2
-4@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev,uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + +last_page->size)Quoted 8 lines
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, · line 1006
Quoted 5 lines
lib/vhost/vhost_user.c +4
-0{ +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }This makes me think about a question: In
IOVA_VAmode, what ensures HPA and GPA are both contiguous?
Quoted 6 lines
When I wrote this email, I thought
host_phys_addris HPA but in VA mode, it's Host IOVA, aka VA in DPDK's case. So in most cases GPA and VA will be both contiguous when the contiguous pages are all in one memory region. But I think we should not make such assumption as some vhost master may send GPA- contiguous pages in different memory region, then the VA after mmap may not be contiguous.
Now we do async vfio mapping at page granularity.
For 4K/2M pages, without this assumption, pages not be merged may exceed the IOMMU's capability. This limits only use 1G hugepage for DMA device.
Thanks,
Xuan
Quoted 25 lines
Maxime, What do you think?
Thanks,
ChenboQuoted 19 lines
Maxime & Yuan, any thought?
Thanks,
Chenbolib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
Quoted 3 lines
lib/vhost/vhost_user.c +3
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page-
guest_phys_addr+Quoted 9 lines
lib/vhost/vhost_user.c +3
-1last_page->size) { + last_page->size += size; +return 0 ; + } } } --2.25.1
Hi,
Quoted 127 lines · Xuan
Hi Chenbo,
Quoted 118 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 16:07
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 6 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, November 15, 2021 4:04 PM
To: Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He,Xingguang
Quoted 45 lines
<[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 8 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang,YuanX
Quoted 26 lines
<[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages, vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical addressmappings")
Fixes 6563cf92380 ("vhost: fix async copy on multi-page buffers")Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h index renamed from lib/vhost/vhost.h +0
-0
7085e0885c..b3f0c1d07c100644lib/vhost/vhost.h static __rte_always_inline int · line 592
Quoted 6 lines
lib/vhost/vhost.h +2
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(const void *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void *p1, +constvoid
Quoted 7 lines
lib/vhost/vhost.h static __rte_always_inline int guest_page_addrcmp(const void *p1,
Quoted 7 lines
lib/vhost/vhost.h +6
-0*p2) +{ + const struct guest_page *page1 = (const struct guest_page *)p1; + const struct guest_page *page2 = (const struct guest_page *)p2; + + if (page1->guest_phys_addr >= page2->guest_phys_addr) { + if (page1->guest_phys_addr < page2->guest_phys_addr +
page2->size)Quoted 12 lines
Quoted 12 lines
lib/vhost/vhost.h +7
-0+return 0 ; + else + return 1; + }else +return -1 ; +} + static __rte_always_inline rte_iova_t gpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,
uint64_tgpa_size,uint64_t*hpa_size) @@ -597,9 +611,9 @@
gpa_to_first_hpa(structvirtio_net*dev,uint64_tgpa,Quoted 10 lines
lib/vhost/vhost.h gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
Quoted 10 lines
*hpa_size = gpa_size; if (dev->nr_guest_pages >= VHOST_BINARY_SEARCH_THRESH) {lib/vhost/vhost.h +2
-2- key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page =bsearch (&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); +sizeof (struct guest_page ), guest_page_rangecmp);if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size){ diff --git
Quoted 15 lines
Quoted 15 lines
a/lib/vhost/vhost_user.cb/lib/vhost/vhost_user.cindexa781346c4d..7d58fde458100644lib/vhost/vhost_user.c +2
-4@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev,uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + +last_page->size)Quoted 8 lines
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, · line 1006
Quoted 5 lines
lib/vhost/vhost_user.c +4
-0{ +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }This makes me think about a question: In
IOVA_VAmode, what ensures HPA and GPA are both contiguous?Quoted 6 lines
When I wrote this email, I thought
host_phys_addris HPA but in VA mode, it's Host IOVA, aka VA in DPDK's case. So in most cases GPA and VA will be both contiguous when the contiguous pages are all in one memory region. But I think we should not make such assumption as some vhost master may send GPA- contiguous pages in different memory region, then the VA after mmap may not be contiguous.
Quoted 3 lines
Now we do async vfio mapping at page granularity.
For 4K/2M pages, without this assumption, pages not be merged may exceed the IOMMU's capability. This limits only use 1G hugepage for DMA device.
I'm sorry, but I'm not sure to understand your explanation. Could you please rephrase it?
Thanks,
Maxime
Quoted 29 lines
Thanks,
XuanQuoted 25 lines
Maxime, What do you think?
Thanks,
ChenboQuoted 19 lines
Maxime & Yuan, any thought?
Thanks,
Chenbolib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
Quoted 3 lines
lib/vhost/vhost_user.c +3
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page-
guest_phys_addr+Quoted 9 lines
lib/vhost/vhost_user.c +3
-1last_page->size) { + last_page->size += size; +return 0 ; + } } } --2.25.1
Quoted 134 lines
-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, November 16, 2021 4:47 PM
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesHi Chenbo,
Quoted 118 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 16:07
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 6 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, November 15, 2021 4:04 PM
To: Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He,Xingguang
Quoted 45 lines
<[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 8 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang,YuanX
Quoted 26 lines
<[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages, vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical addressmappings")
Fixes 6563cf92380 ("vhost: fix async copy on multi-page buffers")Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h index renamed from lib/vhost/vhost.h +0
-0
7085e0885c..b3f0c1d07c100644lib/vhost/vhost.h static __rte_always_inline int · line 592
Quoted 6 lines
lib/vhost/vhost.h +2
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(const void *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void *p1, +constvoid
Quoted 7 lines
lib/vhost/vhost.h static __rte_always_inline int guest_page_addrcmp(const void *p1,
Quoted 7 lines
lib/vhost/vhost.h +6
-0*p2) +{ + const struct guest_page *page1 = (const struct guest_page *)p1; + const struct guest_page *page2 = (const struct guest_page *)p2; + + if (page1->guest_phys_addr >= page2->guest_phys_addr) { + if (page1->guest_phys_addr < page2->guest_phys_addr +
page2->size)Quoted 12 lines
Quoted 12 lines
lib/vhost/vhost.h +7
-0+return 0 ; + else + return 1; + }else +return -1 ; +} + static __rte_always_inline rte_iova_t gpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,
uint64_tgpa_size,uint64_t*hpa_size) @@ -597,9 +611,9 @@
gpa_to_first_hpa(structvirtio_net*dev,uint64_tgpa,Quoted 10 lines
lib/vhost/vhost.h gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
Quoted 10 lines
lib/vhost/vhost.h +2
-2*hpa_size = gpa_size;if (dev->nr_guest_pages >=VHOST_BINARY_SEARCH_THRESH ) { - key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page =bsearch (&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); +sizeof (struct guest_page ), guest_page_rangecmp);if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size){ diff --git
Quoted 15 lines
Quoted 15 lines
a/lib/vhost/vhost_user.cb/lib/vhost/vhost_user.cindexa781346c4d..7d58fde458100644lib/vhost/vhost_user.c +2
-4@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev,uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + +last_page->size)Quoted 8 lines
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, · line 1006
Quoted 5 lines
lib/vhost/vhost_user.c +4
-0{ +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }This makes me think about a question: In
IOVA_VAmode, what ensures HPA and GPA are both contiguous?Quoted 1 line
When I wrote this email, I thought
host_phys_addris HPA but in VA mode,it's
Quoted 2 lines
Host IOVA, aka VA in DPDK's case. So in most cases GPA and VA will be both contiguous when the contiguous pages are all in one memory region. But I
Quoted 8 lines
think
Quoted 3 lines
we should not make such assumption as some vhost master may send GPA- contiguous pages in different memory region, then the VA after mmap may not be contiguous.
Now we do async vfio mapping at page granularity.
For 4K/2M pages, without this assumption, pages not be merged may exceed the IOMMU's capability. This limits only use 1G hugepage for DMA device.
I was not saying merging should be done, but merging with correct logic.
That is to say, the pages that should be merged will still be merged, but make the Logic to handle all cases.
Thanks,
Chenbo
Quoted 29 lines
Thanks,
XuanQuoted 25 lines
Maxime, What do you think?
Thanks,
ChenboQuoted 19 lines
Maxime & Yuan, any thought?
Thanks,
Chenbolib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
Quoted 3 lines
lib/vhost/vhost_user.c +3
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page-
guest_phys_addr+Quoted 9 lines
lib/vhost/vhost_user.c +3
-1last_page->size) { + last_page->size += size; +return 0 ; + } } } --2.25.1
Hi,
Quoted 160 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 17:01
To: Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 10 lines
-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, November 16, 2021 4:47 PM
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 17 lines
Hi Chenbo,
Quoted 15 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 16:07
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 4 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, November 15, 2021 4:04 PM
To: Wang, YuanX <[email protected]>;Quoted 50 lines
Quoted 50 lines
Quoted 2 lines
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He,
Xingguang
Quoted 47 lines
<[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 9 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang,YuanX
Quoted 27 lines
<[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages, vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical addressmappings")
Fixes 6563cf92380 ("vhost: fix async copy on multi-pagebuffers")
Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h index renamed from lib/vhost/vhost.h +0
-0
7085e0885c..b3f0c1d07c100644lib/vhost/vhost.h static __rte_always_inline int · line 592
Quoted 6 lines
lib/vhost/vhost.h +2
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(const void *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void +*p1, constvoid
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/vhost/vhost.h static __rte_always_inline int guest_page_addrcmp(const void *p1,
Quoted 8 lines
lib/vhost/vhost.h +7
-0*p2) +{ +const struct guest_page *page1 = (const struct guest_page *)p1; +const struct guest_page *page2 = (const struct guest_page +*)p2; + +if (page1->guest_phys_addr >= page2->guest_phys_addr) { + if (page1->guest_phys_addr < page2->guest_phys_addr+
Quoted 13 lines
Quoted 13 lines
page2->size)Quoted 12 lines
Quoted 12 lines
lib/vhost/vhost.h +7
-0+return 0 ; + else + return 1; + }else +return -1 ; +} + static __rte_always_inline rte_iova_t gpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,
uint64_tgpa_size,uint64_t*hpa_size) @@ -597,9 +611,9 @@
gpa_to_first_hpa(structvirtio_net*dev,uint64_tgpa,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/vhost/vhost.h gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
Quoted 7 lines
lib/vhost/vhost.h +2
-2*hpa_size = gpa_size;if (dev->nr_guest_pages >=VHOST_BINARY_SEARCH_THRESH ) { - key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page = bsearch(&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); + sizeof(struct guest_page),
guest_page_rangecmp);Quoted 34 lines
Quoted 28 lines
Quoted 3 lines
lib/vhost/vhost.h gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
Quoted 3 lines
lib/vhost/vhost.h +0
-0if (page) {if (gpa + gpa_size <= page->guest_phys_addr + page->size){ diff --git
Quoted 15 lines
Quoted 15 lines
a/lib/vhost/vhost_user.cb/lib/vhost/vhost_user.cindexa781346c4d..7d58fde458100644lib/vhost/vhost_user.c +2
-4@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev,uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + +last_page->size)Quoted 8 lines
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, · line 1006
Quoted 5 lines
lib/vhost/vhost_user.c +4
-0{ +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }This makes me think about a question: In
IOVA_VAmode, what ensures HPA and GPA are both contiguous?Quoted 2 lines
When I wrote this email, I thought
host_phys_addris HPA but in VA mode,it's
Quoted 3 lines
Host IOVA, aka VA in DPDK's case. So in most cases GPA and VA will be both contiguous when the contiguous pages are all in one memory region. But I
Quoted 8 lines
think
Quoted 3 lines
we should not make such assumption as some vhost master may send GPA- contiguous pages in different memory region, then the VA after mmap may not be contiguous.
Now we do async vfio mapping at page granularity.
For 4K/2M pages, without this assumption, pages not be merged may exceed the IOMMU's capability. This limits only use 1G hugepage for DMA
Quoted 6 lines
device.
I was not saying merging should be done, but merging with correct logic.
That is to say, the pages that should be merged will still be merged, but make the Logic to handle all cases.
Sorry, I misunderstood your point. I was to add a supplement, PA mode will have lots of pages to map for 4K/2M cases,
it may exceed IOMMU's capability. But it is rational, that's what I hope to explain in the doc.
Thanks,
Xuan
Quoted 33 lines
Thanks,
ChenboQuoted 29 lines
Thanks,
XuanQuoted 25 lines
Maxime, What do you think?
Thanks,
ChenboQuoted 19 lines
Maxime & Yuan, any thought?
Thanks,
Chenbolib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
Quoted 3 lines
lib/vhost/vhost_user.c +3
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page-
guest_phys_addr+Quoted 9 lines
lib/vhost/vhost_user.c +3
-1last_page->size) { + last_page->size += size; +return 0 ; + } } } --2.25.1
Quoted 166 lines · Xuan
Hi,
Quoted 164 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 17:01
To: Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 10 lines
-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, November 16, 2021 4:47 PM
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 17 lines
Hi Chenbo,
Quoted 15 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: 2021年11月16日 16:07
To: Xia, Chenbo <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 4 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, November 15, 2021 4:04 PM
To: Wang, YuanX <[email protected]>;Quoted 50 lines
Quoted 50 lines
Quoted 2 lines
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He,
Xingguang
Quoted 47 lines
<[email protected]>; Yang, YvonneX <[email protected]>
Subject: RE: [PATCH] vhost: fix get hpa fail from guest pagesQuoted 9 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, November 11, 2021 2:27 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Ma, WenwuX <[email protected]>; He, Xingguang <[email protected]>; Yang, YvonneX <[email protected]>; Wang,YuanX
Quoted 27 lines
<[email protected]>
Subject: [PATCH] vhost: fix get hpa fail from guest pagesWhen processing front-end memory regions messages, vhost saves the guest/host physical address mappings to guest pages and merges adjacent contiguous pages if hpa is contiguous, however gpa is likely not contiguous in PA mode and merging will cause the gpa range to change.
This patch distinguishes the case of discontinuous gpa and does a range lookup on gpa when doing a binary search.Fixes e246896178e("vhost: get guest/host physical addressmappings")
Fixes 6563cf92380 ("vhost: fix async copy on multi-pagebuffers")
Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/vhost.h | 18 ++++++++++++++++-- lib/vhost/vhost_user.c | 15 +++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)lib/vhost/vhost.h index renamed from lib/vhost/vhost.h +0
-0
7085e0885c..b3f0c1d07c100644lib/vhost/vhost.h static __rte_always_inline int · line 592
Quoted 6 lines
lib/vhost/vhost.h +2
-0@@ -587,6 +587,20 @@ static __rte_always_inline int guest_page_addrcmp(const void *p1, return 0; } +static __rte_always_inline int guest_page_rangecmp(const void +*p1, constvoid
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/vhost/vhost.h static __rte_always_inline int guest_page_addrcmp(const void *p1,
Quoted 8 lines
lib/vhost/vhost.h +7
-0*p2) +{ +const struct guest_page *page1 = (const struct guest_page *)p1; +const struct guest_page *page2 = (const struct guest_page +*)p2; + +if (page1->guest_phys_addr >= page2->guest_phys_addr) { + if (page1->guest_phys_addr < page2->guest_phys_addr+
Quoted 13 lines
Quoted 13 lines
page2->size)Quoted 12 lines
Quoted 12 lines
lib/vhost/vhost.h +7
-0+return 0 ; + else + return 1; + }else +return -1 ; +} + static __rte_always_inline rte_iova_t gpa_to_first_hpa(struct
virtio_net*dev,uint64_tgpa,
uint64_tgpa_size,uint64_t*hpa_size) @@ -597,9 +611,9 @@
gpa_to_first_hpa(structvirtio_net*dev,uint64_tgpa,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/vhost/vhost.h gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
Quoted 7 lines
*hpa_size = gpa_size; if (dev->nr_guest_pages >= VHOST_BINARY_SEARCH_THRESH) {lib/vhost/vhost.h +2
-2- key.guest_phys_addr = gpa & ~(dev->guest_pages[0 ].size -1 ); + key.guest_phys_addr = gpa; page = bsearch(&key, dev->guest_pages, dev->nr_guest_pages, -sizeof (struct guest_page ), guest_page_addrcmp); + sizeof(struct guest_page),
guest_page_rangecmp);Quoted 34 lines
Quoted 28 lines
Quoted 3 lines
Quoted 3 lines
if (page) { if (gpa + gpa_size <= page->guest_phys_addr + page->size){ diff --git
Quoted 15 lines
Quoted 15 lines
a/lib/vhost/vhost_user.cb/lib/vhost/vhost_user.cindexa781346c4d..7d58fde458100644lib/vhost/vhost_user.c +2
-4@@ -999,10 +999,17 @@ add_one_guest_page(struct virtio_net *dev,uint64_t guest_phys_addr, if (dev->nr_guest_pages > 0) { last_page = &dev->guest_pages[dev->nr_guest_pages -1 ];/* merge if the two pages are continuous */ -if (host_phys_addr == last_page->host_phys_addr + - last_page->size) { - last_page->size += size; -return 0 ; +if (host_phys_addr == last_page->host_phys_addr + +last_page->size)Quoted 8 lines
lib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr, · line 1006
Quoted 5 lines
lib/vhost/vhost_user.c +4
-0{ +if (rte_eal_iova_mode () ==RTE_IOVA_VA ) { + last_page->size += size; +return 0 ; + }This makes me think about a question: In
IOVA_VAmode, what ensures HPA and GPA are both contiguous?Quoted 2 lines
When I wrote this email, I thought
host_phys_addris HPA but in VA mode,it's
Quoted 3 lines
Host IOVA, aka VA in DPDK's case. So in most cases GPA and VA will be both contiguous when the contiguous pages are all in one memory region. But I
Quoted 8 lines
think
Quoted 3 lines
we should not make such assumption as some vhost master may send GPA- contiguous pages in different memory region, then the VA after mmap may not be contiguous.
Now we do async vfio mapping at page granularity.
For 4K/2M pages, without this assumption, pages not be merged may exceed the IOMMU's capability. This limits only use 1G hugepage for DMAdevice.
I was not saying merging should be done, but merging with correct logic.
Quoted 7 lines
Quoted 2 lines
That is to say, the pages that should be merged will still be merged, but make the Logic to handle all cases.
Sorry, I misunderstood your point. I was to add a supplement, PA mode will have lots of pages to map for 4K/2M cases,
it may exceed IOMMU's capability. But it is rational, that's what I hope to explain in the doc.
We are running out of time for v21.11 release. Do you agree to postpone the fix to new release? It can be backported to v21.11 LTS later.
Quoted 37 lines
Thanks,
XuanQuoted 33 lines
Thanks,
ChenboQuoted 29 lines
Thanks,
XuanQuoted 25 lines
Maxime, What do you think?
Thanks,
ChenboQuoted 19 lines
Maxime & Yuan, any thought?
Thanks,
Chenbolib/vhost/vhost_user.c add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
Quoted 3 lines
lib/vhost/vhost_user.c +3
-0+ +if (rte_eal_iova_mode () ==RTE_IOVA_PA && + guest_phys_addr == last_page-
guest_phys_addr+Quoted 9 lines
lib/vhost/vhost_user.c +3
-1last_page->size) { + last_page->size += size; +return 0 ; + } } } --2.25.1