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 1E2A04628F; Fri, 21 Feb 2025 18:30:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FE2E410F6; Fri, 21 Feb 2025 18:30:41 +0100 (CET) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EF770410E8; Fri, 21 Feb 2025 18:30:38 +0100 (CET) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51L8OaZi019470; Fri, 21 Feb 2025 09:30:38 -0800 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=s 2rkeuJtHh0/qo304XdqO9fvK1BBX6HK1EHMoMizz+w=; b=hH7iGlrBndCPHyjFy 9xjTmeBBjZxAGlqsl8DX4LW3xOwLDPkiRJ0sZ8/lTHv/rrKszjgdlXahrCkPFA8t PaHu41P9HN4a9R82Z3xBkGuE4UlNGknviuAX08PJ6PUGE3Z2zDrk6YRR59s6zz8f c8p3crEa8DFHzTBAx57+EXc44lkv4calnGwGUBYXyKjAdz3viSdFT693kWiWJoch k0d2J3M7jFalNjxmo3mWeRpHMsD6o0ABOjiuK4bIFb0JXLWEcNfOc7iwhWXDSC1f nuHOrgZzRLyKoaykeF7b/tlkb51Qz3JIMJFkL0d80NwlWuo60Ax8eFEamdGDUObp crW0g== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 44xnxu91b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Feb 2025 09:30:37 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 21 Feb 2025 09:30:36 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 21 Feb 2025 09:30:36 -0800 Received: from IN-lckQE5Rwctls.marvell.com (unknown [10.193.66.72]) by maili.marvell.com (Postfix) with ESMTP id 05F745B692B; Fri, 21 Feb 2025 09:30:32 -0800 (PST) From: Gowrishankar Muthukrishnan To: , , Chenbo Xia , Fan Zhang , Jay Zhou CC: , Akhil Goyal , "Gowrishankar Muthukrishnan" , Subject: [v3 1/5] vhost: skip crypto op fetch before vring init Date: Fri, 21 Feb 2025 23:00:09 +0530 Message-ID: X-Mailer: git-send-email 2.37.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: iyXd9MW2Tg9-2nV25GM0NnbzJqhxOSGT X-Proofpoint-ORIG-GUID: iyXd9MW2Tg9-2nV25GM0NnbzJqhxOSGT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-21_05,2025-02-20_02,2024-11-22_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 Until virtio avail ring is initialized (by VHOST_USER_SET_VRING_ADDR), worker thread should not try to fetch crypto op, which would lead to memory fault. Fixes: 939066d9656 ("vhost/crypto: add public function implementation") Cc: stable@dpdk.org Signed-off-by: Gowrishankar Muthukrishnan --- lib/vhost/vhost_crypto.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index 3dc41a3bd5..55ea24710e 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -1580,6 +1580,16 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, vq = dev->virtqueue[qid]; + if (unlikely(vq == NULL)) { + VC_LOG_ERR("Invalid virtqueue %u", qid); + return 0; + } + + if (unlikely(vq->avail == NULL)) { + VC_LOG_DBG("Virtqueue ring not yet initialized %u", qid); + return 0; + } + avail_idx = *((volatile uint16_t *)&vq->avail->idx); start_idx = vq->last_used_idx; count = avail_idx - start_idx; -- 2.25.1