kni: fix crash on userspace VA for segmented packets
authorFerruh Yigit <ferruh.yigit@intel.com>
Tue, 22 Jun 2021 12:29:56 +0000 (13:29 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 24 Jun 2021 08:04:25 +0000 (10:04 +0200)
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>
kernel/linux/kni/kni_net.c

index f259327..611719b 100644 (file)
@@ -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;