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 BB254A0540 for ; Thu, 7 Jul 2022 09:58:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B165A406B4; Thu, 7 Jul 2022 09:58:51 +0200 (CEST) Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by mails.dpdk.org (Postfix) with ESMTP id 8A74C40DDE for ; Thu, 7 Jul 2022 09:58:50 +0200 (CEST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (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 smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 3B43140274 for ; Thu, 7 Jul 2022 07:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657180729; bh=tMnKaZ9F9+xQst9VkoeAL6lYeW2zexyB9qJsI13P8zg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=atps3rtgiLRvjwUv8XjY52aTjMGTJHanI4tw0S7pXq4hnZPVuBDgystSAx//nnQpc jx/aHdQVIw0s2kZxb10GCsxftQYRpU6ralUwYGuI9ozcDo2uKsF18mA2xWZXyx6ssP A/ZzzvEz2d7KJOKwcgDAPMc9a4tkZNKqS2I7rVWU45T3xbZTHjJDVI6/+FNLtt6C34 pvVPG4SbViPu3DNUa+int9bGm5C/tx+JqoYKmntyAaNNGCFY8E3ZrMv1hLvh7HsKbL 7C5v4eJe3FUpwvkBbdw2y1CVTTMP66clEopPGlqxGn0AVyibj39VTbM30s/isLvGUg FAZJQwXG+X7zA== Received: by mail-ed1-f71.google.com with SMTP id w13-20020a05640234cd00b0043a991fb3f3so937507edc.3 for ; Thu, 07 Jul 2022 00:58:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tMnKaZ9F9+xQst9VkoeAL6lYeW2zexyB9qJsI13P8zg=; b=XJqZZlg/ycSRcSHn6GsDxCm1Qqb8ayIHiYwTjZEnHxByEWbrLvDue2YrThl8yGzPJd XBGcjGH1qM5fYWaHK5MhtqUIr9OeJXETx4kck2/gzjx6kIwFR+laSb7J3Xq/ZpX7CPom cMCStex8+mPf30Apwa/PzQRlEAOm/laI65BRjSh8ncwQ/R0Z5HkvF9w4w2vivVnno1Wk CAqMzczPHUf04oHYzmssGBIFtbGojjP1RT3ZEgAF+IGRQoY5YDVyuRrCkk1KLE53uARc 5zF+bH2doBPT05HWNARWtLz01fXzuACSNia+yzIMDit3iZq8QlURxlApphoupcr8hGTn 6n5Q== X-Gm-Message-State: AJIora+DXY/wCGT7Q/FNbqqZDhb18X5gPobeU+wb6l20SjgHseB97dzn zi/y6WVxaSCMi7EL5mviQJBoxdukffR45hDUpFI9ucDEgUHrL44wLektNAc+kbN9e11MKDEPhvd TBmfmPgMA6F4tqZ2pYvdWe2Yf X-Received: by 2002:a17:907:97d4:b0:722:e550:7490 with SMTP id js20-20020a17090797d400b00722e5507490mr44185029ejc.625.1657180728978; Thu, 07 Jul 2022 00:58:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uXIFh/Fz1Q2VjIdgJB3mTtRyl+8547JWFPpD5drRUZn86OFeyTRcl82tw1Vuny4OuwyzBKjw== X-Received: by 2002:a17:907:97d4:b0:722:e550:7490 with SMTP id js20-20020a17090797d400b00722e5507490mr44185010ejc.625.1657180728693; Thu, 07 Jul 2022 00:58:48 -0700 (PDT) Received: from Keschdeichel.fritz.box ([2a02:6d40:3a4f:7b00:c19b:938e:7c97:afe2]) by smtp.gmail.com with ESMTPSA id t12-20020a50d70c000000b0043590660f16sm28173064edi.35.2022.07.07.00.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 00:58:47 -0700 (PDT) From: christian.ehrhardt@canonical.com To: David Marchand Cc: Maxime Coquelin , dpdk stable Subject: patch 'vhost/crypto: fix build with GCC 12' has been queued to stable release 19.11.13 Date: Thu, 7 Jul 2022 09:55:02 +0200 Message-Id: <20220707075522.194223-67-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707075522.194223-1-christian.ehrhardt@canonical.com> References: <20220707075522.194223-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 19.11.13 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/09/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/9a6f9e34878ae119598c794061f7988215b51732 Thanks. Christian Ehrhardt --- >From 9a6f9e34878ae119598c794061f7988215b51732 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 [ 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 0439b12bc7..b8bdfe4bc7 100644 --- a/lib/librte_vhost/vhost_crypto.c +++ b/lib/librte_vhost/vhost_crypto.c @@ -566,94 +566,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; @@ -853,6 +817,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; } @@ -884,6 +849,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; } @@ -1007,6 +973,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; } @@ -1038,6 +1005,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; } @@ -1122,6 +1090,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.37.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-07-07 09:54:13.938515549 +0200 +++ 0067-vhost-crypto-fix-build-with-GCC-12.patch 2022-07-07 09:54:10.981824716 +0200 @@ -1 +1 @@ -From 4414bb67010dfec2559af52efe8f479b26d55447 Mon Sep 17 00:00:00 2001 +From 9a6f9e34878ae119598c794061f7988215b51732 Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 4414bb67010dfec2559af52efe8f479b26d55447 ] + @@ -30 +31,0 @@ -Cc: stable@dpdk.org @@ -35 +36 @@ - lib/vhost/vhost_crypto.c | 123 +++++++++++++++------------------------ + lib/librte_vhost/vhost_crypto.c | 123 ++++++++++++-------------------- @@ -38,5 +39,5 @@ -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 -@@ -565,94 +565,58 @@ get_data_ptr(struct vhost_crypto_data_req *vc_req, +diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c +index 0439b12bc7..b8bdfe4bc7 100644 +--- a/lib/librte_vhost/vhost_crypto.c ++++ b/lib/librte_vhost/vhost_crypto.c +@@ -566,94 +566,58 @@ get_data_ptr(struct vhost_crypto_data_req *vc_req, @@ -178 +179 @@ -@@ -852,6 +816,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, +@@ -853,6 +817,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, @@ -186 +187 @@ -@@ -883,6 +848,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, +@@ -884,6 +849,7 @@ prepare_sym_cipher_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, @@ -194 +195 @@ -@@ -1006,6 +972,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, +@@ -1007,6 +973,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, @@ -202 +203 @@ -@@ -1037,6 +1004,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, +@@ -1038,6 +1005,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, @@ -210 +211 @@ -@@ -1121,6 +1089,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op, +@@ -1122,6 +1090,7 @@ prepare_sym_chain_op(struct vhost_crypto *vcrypto, struct rte_crypto_op *op,