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 5924F46364 for ; Fri, 7 Mar 2025 13:48:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5304040E3E; Fri, 7 Mar 2025 13:48:14 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 40EB140E3A for ; Fri, 7 Mar 2025 13:48:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741351692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lN/DWytfYsgNcGD4OURtTnKVPWZv9LPJ+pUA1NJcegQ=; b=ZY96mE7V4vPuchgs/dk1djX3vylSwZvzYIeyBuoHnRoIOK+xecXR2Jc4FbX3TLhWS/FGZ+ yUfTyWsyu2brSdv0/7zXLbA38dMsgoziuWsw21NLY6gCLV+1s+Ej/WlgcSM04TAWE657Ci +5//MBYMNPXUZlDdPf8rUQEfmjNqw2Q= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-HoYL1-3WPPan0XWowW-E-Q-1; Fri, 07 Mar 2025 07:48:11 -0500 X-MC-Unique: HoYL1-3WPPan0XWowW-E-Q-1 X-Mimecast-MFC-AGG-ID: HoYL1-3WPPan0XWowW-E-Q_1741351690 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB05519560A3; Fri, 7 Mar 2025 12:48:10 +0000 (UTC) Received: from rh.Home (unknown [10.45.226.25]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AB1351956095; Fri, 7 Mar 2025 12:48:08 +0000 (UTC) From: Kevin Traynor To: Gowrishankar Muthukrishnan Cc: Akhil Goyal , Maxime Coquelin , dpdk stable Subject: patch 'vhost/crypto: skip fetch before vring init' has been queued to stable release 24.11.2 Date: Fri, 7 Mar 2025 12:46:50 +0000 Message-ID: <20250307124726.475001-17-ktraynor@redhat.com> In-Reply-To: <20250307124726.475001-1-ktraynor@redhat.com> References: <20250307124726.475001-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: d7oSm7axgSk2BXcJdjFfUaiqcrgYq7TSYGv5ZZ4pVQg_1741351690 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 24.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/12/25. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/35d722b7a10303e04e5ca186763e239027f6d75e Thanks. Kevin --- >From 35d722b7a10303e04e5ca186763e239027f6d75e Mon Sep 17 00:00:00 2001 From: Gowrishankar Muthukrishnan Date: Fri, 28 Feb 2025 19:17:09 +0530 Subject: [PATCH] vhost/crypto: skip fetch before vring init [ upstream commit b03cb9c87a61054ce34b1c19c89170c80d75d27d ] 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: 939066d96563 ("vhost/crypto: add public function implementation") Signed-off-by: Gowrishankar Muthukrishnan Acked-by: Akhil Goyal Reviewed-by: Maxime Coquelin --- lib/vhost/vhost_crypto.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index 7caf6d9afa..912dae012b 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -9,4 +9,5 @@ #include +#include "iotlb.h" #include "rte_vhost_crypto.h" #include "vhost.h" @@ -1581,4 +1582,18 @@ 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(rte_rwlock_read_trylock(&vq->access_lock) != 0)) + return 0; + + vhost_user_iotlb_rd_lock(vq); + if (unlikely(!vq->access_ok)) { + VC_LOG_DBG("Virtqueue %u vrings not yet initialized", qid); + goto out_unlock; + } + avail_idx = *((volatile uint16_t *)&vq->avail->idx); start_idx = vq->last_used_idx; @@ -1588,5 +1603,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, if (unlikely(count == 0)) - return 0; + goto out_unlock; /* for zero copy, we need 2 empty mbufs for src and dst, otherwise @@ -1598,5 +1613,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, (void **)mbufs, count * 2) < 0)) { VC_LOG_ERR("Insufficient memory"); - return 0; + goto out_unlock; } @@ -1628,5 +1643,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, (void **)mbufs, count) < 0)) { VC_LOG_ERR("Insufficient memory"); - return 0; + goto out_unlock; } @@ -1657,4 +1672,8 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, vq->last_used_idx += i; +out_unlock: + vhost_user_iotlb_rd_unlock(vq); + rte_rwlock_read_unlock(&vq->access_lock); + return i; } -- 2.48.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-03-07 11:02:57.529052751 +0000 +++ 0017-vhost-crypto-skip-fetch-before-vring-init.patch 2025-03-07 11:02:56.857335643 +0000 @@ -1 +1 @@ -From b03cb9c87a61054ce34b1c19c89170c80d75d27d Mon Sep 17 00:00:00 2001 +From 35d722b7a10303e04e5ca186763e239027f6d75e Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit b03cb9c87a61054ce34b1c19c89170c80d75d27d ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -21 +22 @@ -index 4c36df9cb2..38c5a7f06f 100644 +index 7caf6d9afa..912dae012b 100644 @@ -30 +31 @@ -@@ -1587,4 +1588,18 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1581,4 +1582,18 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -49 +50 @@ -@@ -1594,5 +1609,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1588,5 +1603,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -56 +57 @@ -@@ -1604,5 +1619,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1598,5 +1613,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -63 +64 @@ -@@ -1634,5 +1649,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1628,5 +1643,5 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -70 +71 @@ -@@ -1663,4 +1678,8 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1657,4 +1672,8 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,