From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id A47555B1E for ; Mon, 30 Jul 2018 18:21:35 +0200 (CEST) Received: from 1.general.paelzer.uk.vpn ([10.172.196.172] helo=lap.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkAqt-00009D-PA; Mon, 30 Jul 2018 16:16:55 +0000 From: Christian Ehrhardt To: Fan Zhang Cc: Jay Zhou , dpdk stable Date: Mon, 30 Jul 2018 18:12:11 +0200 Message-Id: <20180730161342.16566-86-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730161342.16566-1-christian.ehrhardt@canonical.com> References: <20180730161342.16566-1-christian.ehrhardt@canonical.com> Subject: [dpdk-stable] patch 'crypto/virtio: fix IV physical address' has been queued to stable release 18.05.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 16:21:35 -0000 Hi, FYI, your patch has been queued to stable release 18.05.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/01/18. So please shout if anyone has objections. Thanks. Christian Ehrhardt --- >>From a4e7d4e4149bff1c9ad898612ae1510f48d2f75e Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Tue, 26 Jun 2018 03:10:48 +0100 Subject: [PATCH] crypto/virtio: fix IV physical address [ upstream commit b063e843fa03c6af076ae9f5bce73e97211d8989 ] The physical address of IV required by Virtio was computed using crypto operations' physical address plus the offset. However not all crypto ops will have physical address field initialized and compute it runtimely is costly. This patch fixes this problem by adding iv field in virtio_crypto_op_cookie and does a memcpy of iv instead. Fixes: 82adb12a1fce ("crypto/virtio: support burst enqueue/dequeue") Signed-off-by: Fan Zhang Reviewed-by: Jay Zhou --- drivers/crypto/virtio/virtio_cryptodev.c | 6 ++++++ drivers/crypto/virtio/virtio_cryptodev.h | 3 +++ drivers/crypto/virtio/virtio_rxtx.c | 14 +++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c index df88953f6..f9c890bb3 100644 --- a/drivers/crypto/virtio/virtio_cryptodev.c +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -1223,6 +1223,12 @@ virtio_crypto_sym_pad_op_ctrl_req( /* Get cipher xform from crypto xform chain */ cipher_xform = virtio_crypto_get_cipher_xform(xform); if (cipher_xform) { + if (cipher_xform->iv.length > VIRTIO_CRYPTO_MAX_IV_SIZE) { + VIRTIO_CRYPTO_SESSION_LOG_ERR( + "cipher IV size cannot be longer than %u", + VIRTIO_CRYPTO_MAX_IV_SIZE); + return -1; + } if (is_chainned) ret = virtio_crypto_sym_pad_cipher_param( &ctrl->u.sym_create_session.u.chain.para diff --git a/drivers/crypto/virtio/virtio_cryptodev.h b/drivers/crypto/virtio/virtio_cryptodev.h index e402c0309..0fd7b722e 100644 --- a/drivers/crypto/virtio/virtio_cryptodev.h +++ b/drivers/crypto/virtio/virtio_cryptodev.h @@ -16,6 +16,8 @@ #define NUM_ENTRY_VIRTIO_CRYPTO_OP 7 +#define VIRTIO_CRYPTO_MAX_IV_SIZE 16 + extern uint8_t cryptodev_virtio_driver_id; enum virtio_crypto_cmd_id { @@ -29,6 +31,7 @@ struct virtio_crypto_op_cookie { struct virtio_crypto_op_data_req data_req; struct virtio_crypto_inhdr inhdr; struct vring_desc desc[NUM_ENTRY_VIRTIO_CRYPTO_OP]; + uint8_t iv[VIRTIO_CRYPTO_MAX_IV_SIZE]; }; /* diff --git a/drivers/crypto/virtio/virtio_rxtx.c b/drivers/crypto/virtio/virtio_rxtx.c index 450392843..4f695f3e6 100644 --- a/drivers/crypto/virtio/virtio_rxtx.c +++ b/drivers/crypto/virtio/virtio_rxtx.c @@ -203,6 +203,8 @@ virtqueue_crypto_sym_enqueue_xmit( uint16_t req_data_len = sizeof(struct virtio_crypto_op_data_req); uint32_t indirect_vring_addr_offset = req_data_len + sizeof(struct virtio_crypto_inhdr); + uint32_t indirect_iv_addr_offset = indirect_vring_addr_offset + + sizeof(struct vring_desc) * NUM_ENTRY_VIRTIO_CRYPTO_OP; struct rte_crypto_sym_op *sym_op = cop->sym; struct virtio_crypto_session *session = (struct virtio_crypto_session *)get_session_private_data( @@ -259,7 +261,17 @@ virtqueue_crypto_sym_enqueue_xmit( /* indirect vring: iv of cipher */ if (session->iv.length) { - desc[idx].addr = cop->phys_addr + session->iv.offset; + if (cop->phys_addr) + desc[idx].addr = cop->phys_addr + session->iv.offset; + else { + rte_memcpy(crypto_op_cookie->iv, + rte_crypto_op_ctod_offset(cop, + uint8_t *, session->iv.offset), + session->iv.length); + desc[idx].addr = indirect_op_data_req_phys_addr + + indirect_iv_addr_offset; + } + desc[idx].len = session->iv.length; desc[idx++].flags = VRING_DESC_F_NEXT; } -- 2.17.1