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 B23E7A00C5 for ; Wed, 20 Jul 2022 10:23:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD1B340FAE; Wed, 20 Jul 2022 10:23:57 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by mails.dpdk.org (Postfix) with ESMTP id EEEE940697 for ; Wed, 20 Jul 2022 10:23:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3TL1ndo6YrQTCuJP7nvwtqnmdbYGx5J2rQ3NNk2YKgxZriat1bx+4ZSNUf0SoDciteSBhLB2t0gGprIFdhhHhj8LEodRiIS7FexElieduQphZNYXJLI2jo3Im+nW9tFYQnVkrjrYCzEfhiw0hqJ/bWLI/mFd7RGpAnhy6uCf7CQJfkSgGy5r4mRl/wWi//270lZ+myi+CMxOSpSPN6vXL7xAOG+/WoB6LxiaCNxrp4nvp9OgepfxI0o9Hx9/JmVgSkUs58ltd2+pjO6a3Lq8h0BMLwbIvLhoUalsDwjPg9HQNM1uVshQjvZOfCWCKA/GUKo2QMhU6OD63x0I1HQ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=VpL9rBpnfBTJT8dI0AC5tYaA4a7yy/MeUGFDudzy6sI=; b=BZg0RhwMhSUNtLqOntHr0gxzGlz8uj9+avbNXsOL/dW6m9TOxq/fLXDOV4FDJ96/TiUm3V4u7TRw5O4OKXIHN8MiySf+qrs9CRKtoe9vq5rPRA5Zlt7eA989S6BD11iUy+ITqiwdspVO7EhFbw/f2xTAt5jhDAVdxeMJ3OGxToUzHM2dH0hSnZPDzrQMlIT21WSr1gJ85zK4v+0c/CSC6L7lhcnmsn+RgQUVbVbXEesPVE82bL7v9DaayRtsTZZUbD1m2ZgWsu5YklIPQVMuloQJNPPdmkYg3D0a+PSIKauG2iVp5E4iciH8VnWxkvYYtA9XSTtecVg0r7IHXK/1AA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org 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 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=VpL9rBpnfBTJT8dI0AC5tYaA4a7yy/MeUGFDudzy6sI=; b=rIVZ/xW8WZHR+C9TAj19d+4oSWNIDA/Qj3weDytmloLBXJGbbDChp8sOIBtkawuxO3lpR3E2tFeuSmL8b3qSuYpNhE4Fp9HmFxfB5Z/2PVjTwKbsQCPagzW5+pgAngiK+YIxTVjTBhXXfgddDNv8IVGu0t/jLXAzDezrvPIC2YM6IBvqmLV+7cVWKSlh7TmVZGJrH3fuAxeL4Z9/tIJMeIdJ6EwOIwbwSlaxJww1fvZMLBaz/4ViAxFd188pTof17VWcXJg1Ot63c2Ws9nf1GTaPmF5xvFBvpYjw9dt4Gl6g7uY1G7PJuDH3Z+I/w/hPTL52Lo73AFYqscanm32Ymg== Received: from BN9PR03CA0800.namprd03.prod.outlook.com (2603:10b6:408:13f::25) by DM6PR12MB4059.namprd12.prod.outlook.com (2603:10b6:5:215::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19; Wed, 20 Jul 2022 08:23:53 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::85) by BN9PR03CA0800.outlook.office365.com (2603:10b6:408:13f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.15 via Frontend Transport; Wed, 20 Jul 2022 08:23:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 08:23:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 20 Jul 2022 08:23:52 +0000 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.986.26; Wed, 20 Jul 2022 01:23:50 -0700 From: Xueming Li To: David Marchand CC: , Maxime Coquelin , "dpdk stable" Subject: patch 'vhost/crypto: fix build with GCC 12' has been queued to stable release 20.11.6 Date: Wed, 20 Jul 2022 11:20:52 +0300 Message-ID: <20220720082132.3954126-23-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220720082132.3954126-1-xuemingl@nvidia.com> References: <20220621080301.2315720-1-xuemingl@nvidia.com> <20220720082132.3954126-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2196eabf-6c4d-4f40-dda8-08da6a292e7e X-MS-TrafficTypeDiagnostic: DM6PR12MB4059:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dDZZOVEyRzVCZ0tIek4xNjEvY2svTUhNN2hKWVlQVTVtbUNwY0RlSUlIbVUw?= =?utf-8?B?azVFRThTZDFXeWltVG4yOVpMKzZMbW1ZUG9rNzVNUTloc0ZDU3M5bFlkQmZt?= =?utf-8?B?Sk16RlphTVIyQmRSRnl4VHlHYzJ4QXpLeUZOSXJTbklXTmlWUkQwdjFZbk1r?= =?utf-8?B?QjEwOWl3eG5NcXZMMGxaN3J1M3REb1pzcGRLemNSVVBPNXlFKzFYVzk1Wnp4?= =?utf-8?B?TDYyWldIS2ZqWEtQY0FDbWNvUktPdjYzU3J5N0U1ankrcUNCM1pzbU83cWRV?= =?utf-8?B?aHNMQk9HRkdWbVpUeWxyZlEwNWoyOTdtRGJxUzA3QmFUa0ovTlZmYS9ESHRt?= =?utf-8?B?ZzNWU1E2aWo2VVpBRXJhcThreXV2Uy90d3Q5NlRKWVVBTnBjTXkyb2VDTWk0?= =?utf-8?B?MHE3WUJVS0s1RjFvRGxrSkRXMVlkQ0RBSkplR215b3lHU2JLb0UvT2xpVnpq?= =?utf-8?B?YTlKc28rUmZKcUNRRExHbmlya2FqTXRPOXozWlJEb3MzK0UvUHcrNlpVSkhW?= =?utf-8?B?RERyam1JUjZDQ1RrNGV6aWEyS1Z3V2R1aFRSMzBZZFpBbnV5OFpWQUJKRFZY?= =?utf-8?B?aEVLanp4NTFhTkQ1bmJnU0p4ajZScU1FOGVZUmVTV2pFQmx2aUJlbnJtMm1W?= =?utf-8?B?STBXVmJnZ2krdWxBMVZPL08reklRSXY1UnRXVmpLYzUrTHNsS2VocnlPVUwz?= =?utf-8?B?ZGZKS0tPanpsQ2tuaGhFYVMveGwyVFZsNEd6bTVCUlNuOWZpcGF3ZlBBQTd4?= =?utf-8?B?Nlo3Nm1jaTE4eXpaOEtUZDNHTjNWYko1ci9sdG5Ya1BNeDRiclRSYWtLcEJW?= =?utf-8?B?TUF6dlB3QkxrZmhoaC9KaHpoQ2JOR2JJWjNFYm5tTExYM1crZnlnRS90RDdn?= =?utf-8?B?UUN6bG5LU2RUMlZ2ak45WUdmeE1LTFFIMGFYeEVhV3VIU0QxeXBQQWNFVndo?= =?utf-8?B?Zlh3MHlQVDdpSGZDMTEzd085ZjR1bW1LZWV1M2hLaU5SSVJrK2FBWG1scGYx?= =?utf-8?B?RDZLUE44dlRSZks4WStOOHRhZkNlWng5NXJVcDliTm5RNGdkMkNmYkZlS3Er?= =?utf-8?B?a3FUM1VZYWx5amVKTDhIMmNhTEF0ZHpHbDYvSWY5R2NxNTZuU1ZKWWpYZmZY?= =?utf-8?B?ODJyS0lUS0lHRnAyZHcxVkpCdmd4aTJnS3FVM28vOWFlbzFBWmtnckpSQVRF?= =?utf-8?B?dkpNdzlEN2FaL2RLVHFHZlc4NUVVZTg5S3VSc2tkc1ZBL2l6ZTh3M0RFQmM4?= =?utf-8?B?UW8wTkx6WE5ZWEVDbXJWUUVLbVN2alVSWWwzVUNDOEJCUFlTUT09?= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(136003)(396003)(376002)(346002)(36840700001)(40470700004)(46966006)(966005)(82310400005)(316002)(54906003)(2616005)(36860700001)(7696005)(36756003)(41300700001)(6286002)(26005)(6916009)(40460700003)(82740400003)(86362001)(4326008)(2906002)(1076003)(81166007)(5660300002)(40480700001)(70206006)(8676002)(55016003)(186003)(83380400001)(478600001)(426003)(53546011)(336012)(16526019)(8936002)(356005)(47076005)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 08:23:53.0272 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2196eabf-6c4d-4f40-dda8-08da6a292e7e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4059 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 20.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/22/22. 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/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/8aa20e45c65bb806718cda71aef85132486b1cd7 Thanks. Xueming Li --- >From 8aa20e45c65bb806718cda71aef85132486b1cd7 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Thu, 16 Jun 2022 16:46:50 +0200 Subject: [PATCH] vhost/crypto: fix build with GCC 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Xueming Li [ upstream commit 4414bb67010dfec2559af52efe8f479b26d55447 ] GCC 12 raises the following warning: In file included from ../lib/mempool/rte_mempool.h:46, from ../lib/mbuf/rte_mbuf.h:38, from ../lib/vhost/vhost_crypto.c:7: ../lib/vhost/vhost_crypto.c: In function ‘rte_vhost_crypto_fetch_requests’: ../lib/eal/x86/include/rte_memcpy.h:371:9: warning: array subscript 1 is outside array bounds of ‘struct virtio_crypto_op_data_req[1]’ [-Warray-bounds] 371 | rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/vhost/vhost_crypto.c:1178:42: note: while referencing ‘req’ 1178 | struct virtio_crypto_op_data_req req; | ^~~ Split this function and separate the per descriptor copy. This makes the code clearer, and the compiler happier. Note: logs for errors have been moved to callers to avoid duplicates. Fixes: 3c79609fda7c ("vhost/crypto: handle virtually non-contiguous buffers") Signed-off-by: David Marchand Reviewed-by: Maxime Coquelin --- lib/librte_vhost/vhost_crypto.c | 123 ++++++++++++-------------------- 1 file changed, 46 insertions(+), 77 deletions(-) diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c index 926b5c0bd9..293960d350 100644 --- a/lib/librte_vhost/vhost_crypto.c +++ b/lib/librte_vhost/vhost_crypto.c @@ -565,94 +565,58 @@ get_data_ptr(struct vhost_crypto_data_req *vc_req, return data; } -static __rte_always_inline int -copy_data(void *dst_data, struct vhost_crypto_data_req *vc_req, - struct vhost_crypto_desc *head, - struct vhost_crypto_desc **cur_desc, - uint32_t size, uint32_t max_n_descs) +static __rte_always_inline uint32_t +copy_data_from_desc(void *dst, struct vhost_crypto_data_req *vc_req, + struct vhost_crypto_desc *desc, uint32_t size) { - struct vhost_crypto_desc *desc = *cur_desc; - uint64_t remain, addr, dlen, len; - uint32_t to_copy; - uint8_t *data = dst_data; - uint8_t *src; - int left = size; - - to_copy = RTE_MIN(desc->len, (uint32_t)left); - dlen = to_copy; - src = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, &dlen, - VHOST_ACCESS_RO); - if (unlikely(!src || !dlen)) - return -1; + uint64_t remain; + uint64_t addr; + + remain = RTE_MIN(desc->len, size); + addr = desc->addr; + do { + uint64_t len; + void *src; + + len = remain; + src = IOVA_TO_VVA(void *, vc_req, addr, &len, VHOST_ACCESS_RO); + if (unlikely(src == NULL || len == 0)) + return 0; - rte_memcpy((uint8_t *)data, src, dlen); - data += dlen; + rte_memcpy(dst, src, len); + remain -= len; + /* cast is needed for 32-bit architecture */ + dst = RTE_PTR_ADD(dst, (size_t)len); + addr += len; + } while (unlikely(remain != 0)); - if (unlikely(dlen < to_copy)) { - remain = to_copy - dlen; - addr = desc->addr + dlen; + return RTE_MIN(desc->len, size); +} - while (remain) { - len = remain; - src = IOVA_TO_VVA(uint8_t *, vc_req, addr, &len, - VHOST_ACCESS_RO); - if (unlikely(!src || !len)) { - VC_LOG_ERR("Failed to map descriptor"); - return -1; - } - rte_memcpy(data, src, len); - addr += len; - remain -= len; - data += len; - } - } +static __rte_always_inline int +copy_data(void *data, struct vhost_crypto_data_req *vc_req, + struct vhost_crypto_desc *head, struct vhost_crypto_desc **cur_desc, + uint32_t size, uint32_t max_n_descs) +{ + struct vhost_crypto_desc *desc = *cur_desc; + uint32_t left = size; - left -= to_copy; + do { + uint32_t copied; - while (desc >= head && desc - head < (int)max_n_descs && left) { - desc++; - to_copy = RTE_MIN(desc->len, (uint32_t)left); - dlen = to_copy; - src = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr, &dlen, - VHOST_ACCESS_RO); - if (unlikely(!src || !dlen)) { - VC_LOG_ERR("Failed to map descriptor"); + copied = copy_data_from_desc(data, vc_req, desc, left); + if (copied == 0) return -1; - } - - rte_memcpy(data, src, dlen); - data += dlen; - - if (unlikely(dlen < to_copy)) { - remain = to_copy - dlen; - addr = desc->addr + dlen; - - while (remain) { - len = remain; - src = IOVA_TO_VVA(uint8_t *, vc_req, addr, &len, - VHOST_ACCESS_RO); - if (unlikely(!src || !len)) { - VC_LOG_ERR("Failed to map descriptor"); - return -1; - } - - rte_memcpy(data, src, len); - addr += len; - remain -= len; - data += len; - } - } - - left -= to_copy; - } + left -= copied; + data = RTE_PTR_ADD(data, copied); + desc++; + } while (desc < head + max_n_descs && left != 0); - if (unlikely(left > 0)) { - VC_LOG_ERR("Incorrect virtio descriptor"); + if (unlikely(left != 0)) return -1; - } - if (unlikely(desc - head == (int)max_n_descs)) + if (unlikely(desc == head + max_n_descs)) *cur_desc = NULL; else *cur_desc = desc + 1; @@ -852,6 +816,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, /* iv */ if (unlikely(copy_data(iv_data, vc_req, head, &desc, cipher->para.iv_len, max_n_descs))) { + VC_LOG_ERR("Incorrect virtio descriptor"); ret = VIRTIO_CRYPTO_BADMSG; goto error_exit; } @@ -883,6 +848,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), vc_req, head, &desc, cipher->para.src_data_len, max_n_descs) < 0)) { + VC_LOG_ERR("Incorrect virtio descriptor"); ret = VIRTIO_CRYPTO_BADMSG; goto error_exit; } @@ -1006,6 +972,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, /* iv */ if (unlikely(copy_data(iv_data, vc_req, head, &desc, chain->para.iv_len, max_n_descs) < 0)) { + VC_LOG_ERR("Incorrect virtio descriptor"); ret = VIRTIO_CRYPTO_BADMSG; goto error_exit; } @@ -1037,6 +1004,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, if (unlikely(copy_data(rte_pktmbuf_mtod(m_src, uint8_t *), vc_req, head, &desc, chain->para.src_data_len, max_n_descs) < 0)) { + VC_LOG_ERR("Incorrect virtio descriptor"); ret = VIRTIO_CRYPTO_BADMSG; goto error_exit; } @@ -1121,6 +1089,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, if (unlikely(copy_data(digest_addr, vc_req, head, &digest_desc, chain->para.hash_result_len, max_n_descs) < 0)) { + VC_LOG_ERR("Incorrect virtio descriptor"); ret = VIRTIO_CRYPTO_BADMSG; goto error_exit; } -- 2.35.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-07-20 15:00:59.843384947 +0800 +++ 0023-vhost-crypto-fix-build-with-GCC-12.patch 2022-07-20 15:00:58.711000496 +0800 @@ -1 +1 @@ -From 4414bb67010dfec2559af52efe8f479b26d55447 Mon Sep 17 00:00:00 2001 +From 8aa20e45c65bb806718cda71aef85132486b1cd7 Mon Sep 17 00:00:00 2001 @@ -7,0 +8,3 @@ +Cc: Xueming Li + +[ upstream commit 4414bb67010dfec2559af52efe8f479b26d55447 ] @@ -30 +32,0 @@ -Cc: stable@dpdk.org @@ -35 +37 @@ - lib/vhost/vhost_crypto.c | 123 +++++++++++++++------------------------ + lib/librte_vhost/vhost_crypto.c | 123 ++++++++++++-------------------- @@ -38,4 +40,4 @@ -diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c -index b1c0eb6a0f..96ffb82a5d 100644 ---- a/lib/vhost/vhost_crypto.c -+++ b/lib/vhost/vhost_crypto.c +diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c +index 926b5c0bd9..293960d350 100644 +--- a/lib/librte_vhost/vhost_crypto.c ++++ b/lib/librte_vhost/vhost_crypto.c