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 036524642F for ; Tue, 8 Apr 2025 09:47:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED5734027F; Tue, 8 Apr 2025 09:47:28 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2071.outbound.protection.outlook.com [40.107.236.71]) by mails.dpdk.org (Postfix) with ESMTP id 74C694027F for ; Tue, 8 Apr 2025 09:47:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gOj3vXuCtCAz/9j+q8IPMiGUdJLO2VXbrupiwRAVXYkUN/5NAYatSWXbcNRbA7dF5qyMwqEQ4CE1Al4xhWj1pATlkJO1HWSBKnV8I6A5wOy5O3Ci9EEme9EPD4ZNsmGB1eyWenGmVnz2c4CmkIZr2ooIsADGT6kDNye4xSrZbwTnevv5pALZ+15lqGEmGuAjVYKBSDD+QMmcsRfU93C4X1UdtwBRXhfoAycbjXNyV/qDVj+a4gj78q6GH8LbGHz0IEaElAZHIgT9CPlJxvLi0thCqBGt7Lo/ypncMVUmPMkTbaOR6F6f6qXQ9jMHJkCgQFyK2sEWrk3HT9CAEh6wnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rgCUJ+Ld0HMgo37XwaYnQnRWKHN0wP8Wf4hwUPBKtjs=; b=pDenntoYapYrzSwf+HdKFEpOGkY3u4hfea9RtShkqhPXV5+krrt9mI8D2f0jk7iD3E/P+es7XMY4fpbOLP5djgFlp3z4Kwtbny0ZP/1INPFP6it2mgAhv3MreVLdYuqT1rT1Ke0uYkoUzwlypiSqyJMkqb8gANVJbE9ZHTlPpNZcTQRdG+GRyucSN074bRr2QGQvQVh+UlTp4LqJVYA4FIu8vbSHJvrogZKNwgKnpDMwG7oG1G9jCn+bRQFhXyVfutnquRPy4moo1Xwd8QsQOUUDkY46tap4WvZKYo/S6lUb5w8suah8zk8QJHd7XuBlyyXa58Z3hM6nTK7SEVl2sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=marvell.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgCUJ+Ld0HMgo37XwaYnQnRWKHN0wP8Wf4hwUPBKtjs=; b=SqufPrgJySHyXmmfp5UmTGTNUcwduas9RUWubYeKwsPhyHiFJzVFXL1SMk5HEldUR4BQe8pXzfHbVWV2rB8KtfCl5BpG0uMCqST2/yyB51/sKn+AgiX6Jb+Ts1dENOp2j0e8t+MKPbADg2HiOUQE7SSaUX/Zc4HEMoaE/AfZt7HahRzJCWvtQwqE0cKHYRR7UQTyatO4fuwFKdER5ZyDAtHqrfvq9/uqDJO3ZH5Jpmz4gDmYVuAA7hegZIU0hj7cuMveAHCwg+ni9GLhhG3YklHYNbzHqFSsoWH7cYOlwKYd2jjeqs9Ic0FguDaLv0mOoUsDgze1S/CVHLZj5o9ILQ== Received: from MW4PR04CA0105.namprd04.prod.outlook.com (2603:10b6:303:83::20) by DM3PR12MB9327.namprd12.prod.outlook.com (2603:10b6:0:42::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.27; Tue, 8 Apr 2025 07:47:22 +0000 Received: from SJ1PEPF000023CF.namprd02.prod.outlook.com (2603:10b6:303:83:cafe::fc) by MW4PR04CA0105.outlook.office365.com (2603:10b6:303:83::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.34 via Frontend Transport; Tue, 8 Apr 2025 07:47:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023CF.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 07:47:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 8 Apr 2025 00:47:08 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Tue, 8 Apr 2025 00:47:05 -0700 From: Xueming Li To: Gowrishankar Muthukrishnan CC: Xueming Li , Akhil Goyal , "Maxime Coquelin" , dpdk stable Subject: patch 'vhost/crypto: skip fetch before vring init' has been queued to stable release 23.11.4 Date: Tue, 8 Apr 2025 15:44:36 +0800 Message-ID: <20250408074515.361046-12-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250408074515.361046-1-xuemingl@nvidia.com> References: <20250218123523.36836-1-xuemingl@nvidia.com> <20250408074515.361046-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CF:EE_|DM3PR12MB9327:EE_ X-MS-Office365-Filtering-Correlation-Id: 73ed4411-59f8-4bc1-b6af-08dd767198ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026|13003099007|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?y41AF09kjI0jdR4NDbOf4IZ7usyAcdyMPc8nqkf1TaO+kAgch7vHY3i3DSvY?= =?us-ascii?Q?OAylHYmtBOI0mxaLTsrkEpyTIGUsAmrLjhMprGWllai/1p1jzvTQMmWCGCgF?= =?us-ascii?Q?//fNJLdzuS/ehTS6rII5v477MQNT/tpLzM7OnRLVZu5eOL2db1AC5fTYfPfo?= =?us-ascii?Q?jjrmUVXcb3rz8Mf54dzl7RHmbsFcg9eosj+yTLSIUQjA7aX3gbcmzGOme18I?= =?us-ascii?Q?m3Jpm0SnEK6z5FfB0Z51PPLfB7ON5TdXOVO9IpYeBuAjFgNq7vdrDFHOPaVw?= =?us-ascii?Q?YliVbOmJZWGngQUK3XLMZ1l+vzfn2RZ0NOfk8Rtuw86caLFRpDv4CKHeh3Sp?= =?us-ascii?Q?hr0kRur3sSlymcdSKW2pXj8VXhD/2pFYhMPZ/1o8hF/Q4ZgHBYphlFlm4eDW?= =?us-ascii?Q?GYpYdN43MSBLRVJpAYhcVF1HWuk73VvO4ct4ezeh03s9o5nEjblMgJw6S3y1?= =?us-ascii?Q?lBuQjQ+SU+j6hXi3tyg+4SEHZEDF1JpQcj0Tiir1mz5Wvsk/aI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kHDcaCmQE96izi3p3ttm4VEKs1N7wNznd+0Sat?= =?us-ascii?Q?gzbK6vVVPn8kha0uid3ldCwQwXWRVDmIEUxXl4DKGgPCU/W36bib6Xjoc3UA?= =?us-ascii?Q?Xei1bhC+uY95Nbk=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026)(13003099007)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 07:47:22.5066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73ed4411-59f8-4bc1-b6af-08dd767198ea X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CF.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9327 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 23.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/10/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=2d91d69fb5e5fae47919afa5390231121f5e629f Thanks. Xueming Li --- >From 2d91d69fb5e5fae47919afa5390231121f5e629f 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 Cc: Xueming Li [ 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 7b22281815..23eb59459e 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -7,6 +7,7 @@ #include #include +#include "iotlb.h" #include "rte_vhost_crypto.h" #include "vhost.h" #include "vhost_user.h" @@ -1579,6 +1580,20 @@ 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; count = avail_idx - start_idx; @@ -1586,7 +1601,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, count = RTE_MIN(count, nb_ops); if (unlikely(count == 0)) - return 0; + goto out_unlock; /* for zero copy, we need 2 empty mbufs for src and dst, otherwise * we need only 1 mbuf as src and dst @@ -1596,7 +1611,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, if (unlikely(rte_mempool_get_bulk(vcrypto->mbuf_pool, (void **)mbufs, count * 2) < 0)) { VC_LOG_ERR("Insufficient memory"); - return 0; + goto out_unlock; } for (i = 0; i < count; i++) { @@ -1626,7 +1641,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, if (unlikely(rte_mempool_get_bulk(vcrypto->mbuf_pool, (void **)mbufs, count) < 0)) { VC_LOG_ERR("Insufficient memory"); - return 0; + goto out_unlock; } for (i = 0; i < count; i++) { @@ -1655,6 +1670,10 @@ 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.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-04-08 15:39:06.361153041 +0800 +++ 0011-vhost-crypto-skip-fetch-before-vring-init.patch 2025-04-08 15:39:05.886436594 +0800 @@ -1 +1 @@ -From b03cb9c87a61054ce34b1c19c89170c80d75d27d Mon Sep 17 00:00:00 2001 +From 2d91d69fb5e5fae47919afa5390231121f5e629f Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit b03cb9c87a61054ce34b1c19c89170c80d75d27d ] @@ -11 +13,0 @@ -Cc: stable@dpdk.org @@ -21 +23 @@ -index 4c36df9cb2..38c5a7f06f 100644 +index 7b22281815..23eb59459e 100644 @@ -24 +26 @@ -@@ -8,6 +8,7 @@ +@@ -7,6 +7,7 @@ @@ -32 +34 @@ -@@ -1586,6 +1587,20 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1579,6 +1580,20 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -53 +55 @@ -@@ -1593,7 +1608,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1586,7 +1601,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -62 +64 @@ -@@ -1603,7 +1618,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1596,7 +1611,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -71 +73 @@ -@@ -1633,7 +1648,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1626,7 +1641,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, @@ -80 +82 @@ -@@ -1662,6 +1677,10 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, +@@ -1655,6 +1670,10 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,