Skip to contentSkip to conversation

crypto/virtio: fix iv physical address

PATCH Superseded Fan Zhang 4 participants 8 messages Jun 14, 2018 – Jul 6, 2018

Subsystems (3)
lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH 1/1 crypto/virtio: fix iv physical address

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")
---
 drivers/crypto/virtio/virtio_cryptodev.c | 6 ++++++
 drivers/crypto/virtio/virtio_cryptodev.h | 3 +++
 drivers/crypto/virtio/virtio_rxtx.c      | 8 +++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/crypto/virtio/virtio_cryptodev.c +6 -0
index df88953f6..6ffa7619c 100644
@@ -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 cannot 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
drivers/crypto/virtio/virtio_cryptodev.h +3 -0
index e402c0309..676e008d9 100644
@@ -16,6 +16,8 @@
 
 #define NUM_ENTRY_VIRTIO_CRYPTO_OP 7
 
+#define VIRTIO_CRYPTO_MAX_IV_SIZE 32
+
 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];
 };
 
 /*
drivers/crypto/virtio/virtio_rxtx.c +7 -1
index 450392843..1b16221d0 100644
@@ -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,11 @@ virtqueue_crypto_sym_enqueue_xmit(
 
 	/* indirect vring: iv of cipher */
 	if (session->iv.length) {
-		desc[idx].addr = cop->phys_addr + session->iv.offset;
+		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;
 	}
Signature · 1 line
2.13.6
#1 lore raw
Quoted 39 lines · Fan Zhang

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")
---
 drivers/crypto/virtio/virtio_cryptodev.c | 6 ++++++
 drivers/crypto/virtio/virtio_cryptodev.h | 3 +++
 drivers/crypto/virtio/virtio_rxtx.c      | 8 +++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/crypto/virtio/virtio_cryptodev.c +6 -0
index df88953f6..6ffa7619c 100644
@@ -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 cannot 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
drivers/crypto/virtio/virtio_cryptodev.h +0 -0
index e402c0309..676e008d9 100644

drivers/crypto/virtio/virtio_cryptodev.h line 20

Quoted 5 lines
drivers/crypto/virtio/virtio_cryptodev.h +2 -0
@@ -16,6 +16,8 @@
 
 #define NUM_ENTRY_VIRTIO_CRYPTO_OP 7
 
+#define VIRTIO_CRYPTO_MAX_IV_SIZE 32
+

max iv size supported in capability is 16 and here it is 32.

#3 lore raw
In reply to Fan Zhang

Hi Fan,

Quoted 30 lines

-----Original Message-----
From: Fan Zhang [mailto:[email protected]]
Sent: Thursday, June 14, 2018 7:03 PM
To: [email protected]
Cc: [email protected]; Zhoujian (jay) <[email protected]>; [email protected]
Subject: [PATCH] crypto/virtio: fix iv physical address

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")
---
 drivers/crypto/virtio/virtio_cryptodev.c | 6 ++++++
drivers/crypto/virtio/virtio_cryptodev.h | 3 +++
 drivers/crypto/virtio/virtio_rxtx.c      | 8 +++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/crypto/virtio/virtio_cryptodev.c +0 -0
index df88953f6..6ffa7619c 100644

drivers/crypto/virtio/virtio_cryptodev.c virtio_crypto_sym_pad_op_ctrl_req( · line 1226

Quoted 4 lines
drivers/crypto/virtio/virtio_cryptodev.c +1 -0
@@ -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) {

Considering the consistency with iv.length, could we use VIRTIO_CRYPTO_MAX_IV_LENGTH instead of VIRTIO_CRYPTO_MAX_IV_SIZE?

drivers/crypto/virtio/virtio_cryptodev.c virtio_crypto_sym_pad_op_ctrl_req( · line 1228

Quoted 2 lines
drivers/crypto/virtio/virtio_cryptodev.c +2 -0
+			VIRTIO_CRYPTO_SESSION_LOG_ERR(
+				"cipher IV cannot longer than %u",

s/cipher IV/cipher IV length/ would be better, I think.

Quoted 44 lines
drivers/crypto/virtio/virtio_cryptodev.c +3 -0
+				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
drivers/crypto/virtio/virtio_cryptodev.h +3 -0
index e402c0309..676e008d9 100644
@@ -16,6 +16,8 @@
 
 #define NUM_ENTRY_VIRTIO_CRYPTO_OP 7
 
+#define VIRTIO_CRYPTO_MAX_IV_SIZE 32
+
 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];
 };
 
 /*
drivers/crypto/virtio/virtio_rxtx.c +2 -0
index 450392843..1b16221d0 100644
@@ -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,11 @@ virtqueue_crypto_sym_enqueue_xmit(

drivers/crypto/virtio/virtio_rxtx.c virtqueue_crypto_sym_enqueue_xmit( · line 268

Quoted 8 lines
drivers/crypto/virtio/virtio_rxtx.c +5 -1
 	/* indirect vring: iv of cipher */
 	if (session->iv.length) {
-		desc[idx].addr = cop->phys_addr + session->iv.offset;
+		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;

This ops of rte_memcpy could be avoided if cop->phys_addr is initialized, so how about:

    if (cop->phys_addr) {
        desc[idx].addr = cop->phys_addr + session->iv.offset;
    } else {
        ...
    }

Regards,
Jay

Quoted 5 lines
drivers/crypto/virtio/virtio_rxtx.c +0 -1
 		desc[idx].len = session->iv.length;
 		desc[idx++].flags = VRING_DESC_F_NEXT;
 	}
--

2.13.6

#2 lore raw
In reply to Akhil Goyal

Hi Akhil,

Quoted 50 lines

-----Original Message-----
From: Akhil Goyal [mailto:[email protected]]
Sent: Thursday, June 14, 2018 8:39 PM
To: Fan Zhang <[email protected]>; [email protected]
Cc: [email protected]; Zhoujian (jay) <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] crypto/virtio: fix iv physical address

Quoted 41 lines · Fan Zhang

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")
---
 drivers/crypto/virtio/virtio_cryptodev.c | 6 ++++++
drivers/crypto/virtio/virtio_cryptodev.h | 3 +++
 drivers/crypto/virtio/virtio_rxtx.c      | 8 +++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/crypto/virtio/virtio_cryptodev.c +6 -0
index df88953f6..6ffa7619c 100644
@@ -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 cannot 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
drivers/crypto/virtio/virtio_cryptodev.h +0 -0
index e402c0309..676e008d9 100644
@@ -16,6 +16,8 @@
 
Quoted 6 lines

drivers/crypto/virtio/virtio_cryptodev.h line 20

Quoted 4 lines
drivers/crypto/virtio/virtio_cryptodev.h +2 -0
 #define NUM_ENTRY_VIRTIO_CRYPTO_OP 7
 
+#define VIRTIO_CRYPTO_MAX_IV_SIZE 32
+

max iv size supported in capability is 16 and here it is 32.

Yes, I agree. We could use 16 for now.

Regards,
Jay

Quoted 1 line
author
#4 lore raw

PATCH v2 1/1 crypto/virtio: fix iv physical address

In reply to Fan Zhang

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")

---

v2:
- change max iv size to 16
- use branch to avoid unnecessary memcpy

 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(-)
drivers/crypto/virtio/virtio_cryptodev.c +6 -0
index df88953f6..6ffa7619c 100644
@@ -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 cannot 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
drivers/crypto/virtio/virtio_cryptodev.h +3 -0
index e402c0309..0fd7b722e 100644
@@ -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];
 };
 
 /*
drivers/crypto/virtio/virtio_rxtx.c +13 -1
index 450392843..4f695f3e6 100644
@@ -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;
 	}
Signature · 1 line
2.13.6
Reviewed-by on v2 1/1
#5 lore raw
Quoted 35 lines

-----Original Message-----
From: Fan Zhang [mailto:[email protected]]
Sent: Tuesday, June 26, 2018 10:11 AM
To: [email protected]
Cc: [email protected]; Zhoujian (jay) <[email protected]>; [email protected]
Subject: [PATCH v2] crypto/virtio: fix iv physical address

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")

---

v2:
- change max iv size to 16
- use branch to avoid unnecessary memcpy

 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(-)
drivers/crypto/virtio/virtio_cryptodev.c +0 -0
index df88953f6..6ffa7619c 100644

drivers/crypto/virtio/virtio_cryptodev.c virtio_crypto_sym_pad_op_ctrl_req( · line 1228

Quoted 6 lines
drivers/crypto/virtio/virtio_cryptodev.c +3 -0
@@ -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 cannot longer than %u",

Hi Fan,

As I mentioned in V1, do you agree to use "cipher IV length" or "cipher IV size" instead of "cipher IV" here?

Apart from that,

Quoted 63 lines
drivers/crypto/virtio/virtio_cryptodev.c +3 -0
+				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
drivers/crypto/virtio/virtio_cryptodev.h +3 -0
index e402c0309..0fd7b722e 100644
@@ -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];
 };
 
 /*
drivers/crypto/virtio/virtio_rxtx.c +2 -0
index 450392843..4f695f3e6 100644
@@ -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(

drivers/crypto/virtio/virtio_rxtx.c +11 -2
 	/* 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.13.6

#6 lore raw

Hi Jianjay,

Quoted 52 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhoujian (jay)
Sent: Tuesday, July 3, 2018 1:29 PM
To: Zhang, Roy Fan <[email protected]>; [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] crypto/virtio: fix iv physical address

Quoted 11 lines

-----Original Message-----
From: Fan Zhang [mailto:[email protected]]
Sent: Tuesday, June 26, 2018 10:11 AM
To: [email protected]
Cc: [email protected]; Zhoujian (jay) <[email protected]>; [email protected]
Subject: [PATCH v2] crypto/virtio: fix iv physical address

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.

Quoted 24 lines

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")

---

v2:
- change max iv size to 16
- use branch to avoid unnecessary memcpy

 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(-)
drivers/crypto/virtio/virtio_cryptodev.c +0 -0
index df88953f6..6ffa7619c 100644

drivers/crypto/virtio/virtio_cryptodev.c virtio_crypto_sym_pad_op_ctrl_req( · line 1228

Quoted 6 lines
drivers/crypto/virtio/virtio_cryptodev.c +3 -0
@@ -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 cannot longer than %u",

Hi Fan,

Quoted 2 lines

As I mentioned in V1, do you agree to use "cipher IV length" or "cipher IV size" instead of "cipher IV" here?

Fan is out of office this week. Since this is a minor change, I can apply it and make that change on the fly.

Thanks,
Pablo

Quoted 4 lines

Apart from that,

#7 lore raw
Quoted 68 lines

-----Original Message-----
From: De Lara Guarch, Pablo [mailto:[email protected]]
Sent: Thursday, July 05, 2018 6:54 PM
To: Zhoujian (jay) <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v2] crypto/virtio: fix iv physical address

Hi Jianjay,

Quoted 55 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhoujian (jay)
Sent: Tuesday, July 3, 2018 1:29 PM
To: Zhang, Roy Fan <[email protected]>; [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] crypto/virtio: fix iv physical address

Quoted 8 lines

-----Original Message-----
From: Fan Zhang [mailto:[email protected]]
Sent: Tuesday, June 26, 2018 10:11 AM
To: [email protected]
Cc: [email protected]; Zhoujian (jay) <[email protected]>; [email protected]
Subject: [PATCH v2] crypto/virtio: fix iv physical address

Quoted 4 lines

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.

Quoted 24 lines

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")

---

v2:
- change max iv size to 16
- use branch to avoid unnecessary memcpy

 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(-)
drivers/crypto/virtio/virtio_cryptodev.c +0 -0
index df88953f6..6ffa7619c 100644

drivers/crypto/virtio/virtio_cryptodev.c virtio_crypto_sym_pad_op_ctrl_req( · line 1228

Quoted 6 lines
drivers/crypto/virtio/virtio_cryptodev.c +3 -0
@@ -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 cannot longer than %u",

Hi Fan,

Quoted 6 lines
Quoted 1 line

As I mentioned in V1, do you agree to use "cipher IV length" or "cipher IV

size"

Quoted 1 line

instead of "cipher IV" here?

Fan is out of office this week. Since this is a minor change, I can apply it and make that change on the fly.

Hi Pablo,
Thanks for doing this, :)

Regards,
Jay

Quoted 8 lines

Thanks,
Pablo

Quoted 4 lines

Apart from that,