From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 48E4A45611; Fri, 12 Jul 2024 14:36:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 361F940653; Fri, 12 Jul 2024 14:36:20 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C602740614 for ; Fri, 12 Jul 2024 14:36:17 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46C9JH9p026970; Fri, 12 Jul 2024 05:36:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=8 RTeL5PaHKwEpdgJfC+UrHb+0MP0AvAfFjE7Ba8ANfo=; b=Bo188OItIVlBNE5MD 7QL1BemsjhiWgEDSzbbMWkS1l+Y4Xg1qgrrlRCXeWJKwAIQSp9GTmfXBDIiubjmg eNlpGP+8WQ99Lae93YZ8xJ945Iilaal2ldnK6p8lcPlzuF4FG4xiXLgWxHzCUDvZ IDtHrPcbZT2THyLZsiwtBJtarV/KtyL/7Q/4FiYVovKCioW3Z8522XnxvYTpHUEY vM8TJyDCbNEwsk14wMkSgUl8uvSJp/fFW5J/qNRVUxO+hLrxyWuK1UZ7RfSqNEsc Zo1sWk5y7z2GOFh44F2ujKpN3dXcDDkbe2ppiNnpZe0tJZOyRPCyKiJu4kN8BTIP Vrd5Q== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 40b1rgrgp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Jul 2024 05:36:16 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 12 Jul 2024 05:36:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 12 Jul 2024 05:36:15 -0700 Received: from localhost.localdomain (unknown [10.28.36.175]) by maili.marvell.com (Postfix) with ESMTP id 5B51B3F70A2; Fri, 12 Jul 2024 05:36:13 -0700 (PDT) From: Srujana Challa To: , , CC: , , , , Subject: [PATCH v3] net/virtio_user: fix cq descriptor conversion with non vDPA backend Date: Fri, 12 Jul 2024 18:06:12 +0530 Message-ID: <20240712123612.2389160-1-schalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240711124436.2383232-1-schalla@marvell.com> References: <20240711124436.2383232-1-schalla@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: O2GhG-OQ_OWl2TJ-OaRffEmkihtZkEin X-Proofpoint-GUID: O2GhG-OQ_OWl2TJ-OaRffEmkihtZkEin X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-12_09,2024-07-11_01,2024-05-17_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch modifies the code to convert descriptor buffer IOVA addresses to virtual addresses only when use_va flag is false. This patch fixes segmentation fault with vhost-user backend. Fixes: 67e9e504dae2 ("net/virtio_user: convert cq descriptor IOVA address to Virtual address") Reported-by: David Marchand Signed-off-by: Srujana Challa --- v3: - Addressed the review comments from David Marchand. v2: - Added Reported-by tag. .../net/virtio/virtio_user/virtio_user_dev.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index fed66d2ae9..48b872524a 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -905,9 +905,9 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs) #define CVQ_MAX_DATA_DESCS 32 static inline void * -virtio_user_iova2virt(rte_iova_t iova) +virtio_user_iova2virt(struct virtio_user_dev *dev, rte_iova_t iova) { - if (rte_eal_iova_mode() == RTE_IOVA_VA) + if (rte_eal_iova_mode() == RTE_IOVA_VA || dev->hw.use_va) return (void *)(uintptr_t)iova; else return rte_mem_iova2virt(iova); @@ -938,18 +938,18 @@ virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vri idx_status = i; n_descs++; - hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr); + hdr = virtio_user_iova2virt(dev, vring->desc[idx_hdr].addr); if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { uint16_t queues, *addr; - addr = virtio_user_iova2virt(vring->desc[idx_data].addr); + addr = virtio_user_iova2virt(dev, vring->desc[idx_data].addr); queues = *addr; status = virtio_user_handle_mq(dev, queues); } else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { struct virtio_net_ctrl_rss *rss; - rss = virtio_user_iova2virt(vring->desc[idx_data].addr); + rss = virtio_user_iova2virt(dev, vring->desc[idx_data].addr); status = virtio_user_handle_mq(dev, rss->max_tx_vq); } else if (hdr->class == VIRTIO_NET_CTRL_RX || hdr->class == VIRTIO_NET_CTRL_MAC || @@ -962,7 +962,7 @@ virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vri (struct virtio_pmd_ctrl *)hdr, dlen, nb_dlen); /* Update status */ - *(virtio_net_ctrl_ack *)virtio_user_iova2virt(vring->desc[idx_status].addr) = status; + *(virtio_net_ctrl_ack *)virtio_user_iova2virt(dev, vring->desc[idx_status].addr) = status; return n_descs; } @@ -1004,18 +1004,18 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev, n_descs++; } - hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr); + hdr = virtio_user_iova2virt(dev, vring->desc[idx_hdr].addr); if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { uint16_t queues, *addr; - addr = virtio_user_iova2virt(vring->desc[idx_data].addr); + addr = virtio_user_iova2virt(dev, vring->desc[idx_data].addr); queues = *addr; status = virtio_user_handle_mq(dev, queues); } else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { struct virtio_net_ctrl_rss *rss; - rss = virtio_user_iova2virt(vring->desc[idx_data].addr); + rss = virtio_user_iova2virt(dev, vring->desc[idx_data].addr); status = virtio_user_handle_mq(dev, rss->max_tx_vq); } else if (hdr->class == VIRTIO_NET_CTRL_RX || hdr->class == VIRTIO_NET_CTRL_MAC || @@ -1028,7 +1028,7 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev, (struct virtio_pmd_ctrl *)hdr, dlen, nb_dlen); /* Update status */ - *(virtio_net_ctrl_ack *)virtio_user_iova2virt(vring->desc[idx_status].addr) = status; + *(virtio_net_ctrl_ack *)virtio_user_iova2virt(dev, vring->desc[idx_status].addr) = status; /* Update used descriptor */ vring->desc[idx_hdr].id = vring->desc[idx_status].id; -- 2.25.1