diff mbox series

kni: fix crash on userspace VA for segmented packets

Message ID 20210622122956.3130231-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted
Headers show
Series kni: fix crash on userspace VA for segmented packets | expand

Checks

Context Check Description
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-testing fail Testing issues
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit June 22, 2021, 12:29 p.m. UTC
When IOVA=VA, address translation for segmented packets is wrong, it
assumes the address in the mbuf->next is physical address, not VA
address.

Fixing the address translation to work both PA & VA mode.

Fixes: e73831dc6c26 ("kni: support userspace VA")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: vattunuru@marvell.com
---
 kernel/linux/kni/kni_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ajit Khaparde June 24, 2021, 1:57 a.m. UTC | #1
On Tue, Jun 22, 2021 at 5:39 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> When IOVA=VA, address translation for segmented packets is wrong, it
> assumes the address in the mbuf->next is physical address, not VA
> address.
>
> Fixing the address translation to work both PA & VA mode.
>
> Fixes: e73831dc6c26 ("kni: support userspace VA")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

> ---
> Cc: vattunuru@marvell.com
> ---
>  kernel/linux/kni/kni_net.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index f259327954b2..611719b5ee27 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -245,7 +245,7 @@ kni_fifo_trans_pa2va(struct kni_dev *kni,
>                                         break;
>
>                                 prev_kva = kva;
> -                               kva = pa2kva(kva->next);
> +                               kva = get_kva(kni, kva->next);
>                                 /* Convert physical address to virtual address */
>                                 prev_kva->next = pa2va(prev_kva->next, kva);
>                         }
> @@ -422,7 +422,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>                                         break;
>
>                                 prev_kva = kva;
> -                               kva = pa2kva(kva->next);
> +                               kva = get_kva(kni, kva->next);
>                                 data_kva = kva2data_kva(kva);
>                                 /* Convert physical address to virtual address */
>                                 prev_kva->next = pa2va(prev_kva->next, kva);
> @@ -501,7 +501,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
>                         kni->va[i] = pa2va(kni->pa[i], kva);
>
>                         while (kva->next) {
> -                               next_kva = pa2kva(kva->next);
> +                               next_kva = get_kva(kni, kva->next);
>                                 /* Convert physical address to virtual address */
>                                 kva->next = pa2va(kva->next, next_kva);
>                                 kva = next_kva;
> --
> 2.31.1
>
Thomas Monjalon June 24, 2021, 7:48 a.m. UTC | #2
24/06/2021 03:57, Ajit Khaparde:
> On Tue, Jun 22, 2021 at 5:39 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> >
> > When IOVA=VA, address translation for segmented packets is wrong, it
> > assumes the address in the mbuf->next is physical address, not VA
> > address.
> >
> > Fixing the address translation to work both PA & VA mode.
> >
> > Fixes: e73831dc6c26 ("kni: support userspace VA")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

Applied, thanks
diff mbox series

Patch

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index f259327954b2..611719b5ee27 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -245,7 +245,7 @@  kni_fifo_trans_pa2va(struct kni_dev *kni,
 					break;
 
 				prev_kva = kva;
-				kva = pa2kva(kva->next);
+				kva = get_kva(kni, kva->next);
 				/* Convert physical address to virtual address */
 				prev_kva->next = pa2va(prev_kva->next, kva);
 			}
@@ -422,7 +422,7 @@  kni_net_rx_normal(struct kni_dev *kni)
 					break;
 
 				prev_kva = kva;
-				kva = pa2kva(kva->next);
+				kva = get_kva(kni, kva->next);
 				data_kva = kva2data_kva(kva);
 				/* Convert physical address to virtual address */
 				prev_kva->next = pa2va(prev_kva->next, kva);
@@ -501,7 +501,7 @@  kni_net_rx_lo_fifo(struct kni_dev *kni)
 			kni->va[i] = pa2va(kni->pa[i], kva);
 
 			while (kva->next) {
-				next_kva = pa2kva(kva->next);
+				next_kva = get_kva(kni, kva->next);
 				/* Convert physical address to virtual address */
 				kva->next = pa2va(kva->next, next_kva);
 				kva = next_kva;