Skip to contentSkip to conversation

virtio-crypto: virtio crypto device specification

PATCH Superseded Gonglei 4 participants 18 messages Jan 4, 2017 – Jan 19, 2017

v15 of 18 Superseded Latest is v18 →

lore
Share & tools
lore

Gonglei

author
#0 lore raw

v15 cover virtio-crypto: virtio crypto device specification

Changes since v14:
- drop VIRTIO_CRYPTO_S_STARTED status [Halil & Cornelia]
- correct a sentence about dataqueue and controlq in the first paragraph. [Halil]
- change a MAY to MUST about max_dataqueues. [Halil]
- add non-session mode support
1) add four features for different crypto services to identify wheather support session mode.
2) extend virtio_crypto_*_para structures, for example, add the content of struct virtio_crypto_cipher_session_para into struct virtio_crypto_cipher_para.
3) use the flag property of struct virtio_crypto_op_header to identify the type of crypto request. Aka Is it a session-based or non-session request

For pervious versions of virtio crypto spec, Pls see:

[v14]:
https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg02212.html

[v13]:
https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg07348.html

For more information, please see:
http://qemu-project.org/Features/VirtioCrypto

Please help to review, thanks.

Gonglei (2):
virtio-crypto: Add virtio crypto device specification
virtio-crypto: Add conformance clauses

 conformance.tex   |   30 ++
 content.tex       |    2 +
 virtio-crypto.tex | 1029 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1061 insertions(+)
 create mode 100644 virtio-crypto.tex
Signature · 1 line
1.7.12.4
author
#1 lore raw

PATCH v15 1/2 virtio-crypto: Add virtio crypto device specification

The virtio crypto device is a virtual crypto device (ie. hardware crypto accelerator card). Currently, the virtio crypto device provides the following crypto services: CIPHER, MAC, HASH, and AEAD.

In this patch, CIPHER, MAC, HASH, AEAD services are introduced.

VIRTIO-153

CC Michael S. Tsirkin <[email protected]>
CC Cornelia Huck <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Lingli Deng <[email protected]>
CC Jani Kokkonen <[email protected]>
CC Ola Liljedahl <[email protected]>
CC Varun Sethi <[email protected]>
CC Zeng Xin <[email protected]>
CC Keating Brian <[email protected]>
CC Ma Liang J <[email protected]>
CC Griffin John <[email protected]>
CC Hanweidong <[email protected]>
CC Mihai Claudiu Caraman <[email protected]>
---
 content.tex       |    2 +
 virtio-crypto.tex | 1029 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1031 insertions(+)
 create mode 100644 virtio-crypto.tex
content.tex +2 -0
index 4b45678..ab75f78 100644
@@ -5750,6 +5750,8 @@ descriptor for the \field{sense_len}, \field{residual},
 \field{status_qualifier}, \field{status}, \field{response} and
 \field{sense} fields.
 
+\input{virtio-crypto.tex}
+
 \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
 Currently there are three device-independent feature bits defined:
virtio-crypto.tex new file +1029 -0

1,030 lines not on this page · raw message

Signature · 1 line
1.7.12.4
#2 lore raw

Re: [Qemu-devel] [PATCH v15 1/2] virtio-crypto: Add virtio crypto device specification

Quoted 13 lines · Gonglei
virtio-crypto.tex new file +13 -0
+The general header of dataq:
+
+\begin{lstlisting}
+struct virtio_crypto_op_header {
+#define VIRTIO_CRYPTO_CIPHER_ENCRYPT \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x00)
+#define VIRTIO_CRYPTO_CIPHER_DECRYPT \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x01)
+#define VIRTIO_CRYPTO_HASH \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x00)
+#define VIRTIO_CRYPTO_MAC \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x00)
+#define VIRTIO_CRYPTO_AEAD_ENCRYPT \

virtio-crypto.tex line 273

Quoted 10 lines
virtio-crypto.tex new file +10 -0
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
+#define VIRTIO_CRYPTO_AEAD_DECRYPT \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
+    le32 opcode;
+    /* algo should be service-specific algorithms */
+    le32 algo;
+    /* session_id should be service-specific algorithms */
+    le64 session_id;
+#define VIRTIO_CRYPTO_FLAG_SESSION_MODE 1
+#define VIRTIO_CRYPTO_FLAG_NONE_SESSION_MODE 2

This constant isn't mentioned anywhere in the spec, am I missing something?

Regarding naming: "none session mode" != "non-session mode"

I think this constant should be called
VIRTIO_CRYPTO_FLAG_NON_SESSION_MODE or
VIRTIO_CRYPTO_FLAG_SESSIONLESS_MODE.

#3 lore raw

Re: [Qemu-devel] [PATCH v15 1/2] virtio-crypto: Add virtio crypto device specification

Hi Stefan,

Quoted 29 lines · Gonglei
Quoted 13 lines
virtio-crypto.tex new file +13 -0
+The general header of dataq:
+
+\begin{lstlisting}
+struct virtio_crypto_op_header {
+#define VIRTIO_CRYPTO_CIPHER_ENCRYPT \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x00)
+#define VIRTIO_CRYPTO_CIPHER_DECRYPT \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x01)
+#define VIRTIO_CRYPTO_HASH \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x00)
+#define VIRTIO_CRYPTO_MAC \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x00)
+#define VIRTIO_CRYPTO_AEAD_ENCRYPT \

virtio-crypto.tex line 273

Quoted 10 lines
virtio-crypto.tex new file +10 -0
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
+#define VIRTIO_CRYPTO_AEAD_DECRYPT \
+    VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
+    le32 opcode;
+    /* algo should be service-specific algorithms */
+    le32 algo;
+    /* session_id should be service-specific algorithms */
+    le64 session_id;
+#define VIRTIO_CRYPTO_FLAG_SESSION_MODE 1
+#define VIRTIO_CRYPTO_FLAG_NONE_SESSION_MODE 2

This constant isn't mentioned anywhere in the spec, am I missing something?

Quoted 5 lines

Regarding naming: "none session mode" != "non-session mode"

I think this constant should be called
VIRTIO_CRYPTO_FLAG_NON_SESSION_MODE or
VIRTIO_CRYPTO_FLAG_SESSIONLESS_MODE.

Sorry for my typo, I used VIRTIO_CRYPTO_FLAG_NON_SESSION_MODE.

Thanks,
-Gonglei

#4 lore raw
In reply to Gonglei

Hi all,

I attach the diff files between v14 and v15 for better review.

virtio-crypto.tex +7 -6
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a kind of
 virtual hardware accelerator for virtual machines. The encryption and
-decryption requests are placed in the data queue and are ultimately handled by the
-backend crypto accelerators. The second queue is the control queue used to create 
+decryption requests are placed in any of the data active queues and are ultimately handled by the
+backend crypto accelerators. The second kind of queue is the control queue used to create 
 or destroy sessions for symmetric algorithms and will control some advanced
 features in the future. The virtio crypto device provides the following crypto
 services: CIPHER, MAC, HASH, and AEAD.
@@ -26,7 +26,7 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device / Feature bits}
 
-Undefined currently.
+None currently defined.
 
 \subsection{Device configuration layout}\label{sec:Device Types / Crypto Device / Device configuration layout}
 
@@ -54,13 +54,14 @@ struct virtio_crypto_config {
 };
 \end{lstlisting}
 
-The value of the \field{status} field is VIRTIO_CRYPTO_S_HW_READY or VIRTIO_CRYPTO_S_STARTED.
+The value of the \field{status} field is VIRTIO_CRYPTO_S_HW_READY or ~VIRTIO_CRYPTO_S_HW_READY.
 
 \begin{lstlisting}
 #define VIRTIO_CRYPTO_S_HW_READY  (1 << 0)
-#define VIRTIO_CRYPTO_S_STARTED  (1 << 1)
 \end{lstlisting}
 
+The VIRTIO_CRYPTO_S_HW_READY flag is used to show whether the hardware is ready to work or not.
+
 The following driver-read-only fields include \field{max_dataqueues}, which specifies the
 maximum number of data virtqueues (dataq1\ldots dataqN), and \field{crypto_services},
 which indicates the crypto services the virtio crypto supports.
@@ -172,7 +173,7 @@ Any other value is reserved for future use.
 \item The driver MUST read the ready \field{status} from the bottom bit of status to check whether the hardware-backed
       implementation is ready or not, and the driver MUST reread it after the device reset. 
 \item The driver MUST NOT transmit any packets to the device if the ready \field{status} is not set.
-\item The driver MAY read \field{max_dataqueues} field to discover the number of data queues the device supports.
+\item The driver MUST read \field{max_dataqueues} field to discover the number of data queues the device supports.
 \item The driver MUST read \field{crypto_services} field to discover which services the device is able to offer.
 \item The driver MUST read the detailed algorithms fields based on \field{crypto_services} field.
 \item The driver SHOULD read \field{max_size} to discover the maximum size of crypto request the device supports.

===============The below diff shows the changes of add non-session mode support:

virtio-crypto.tex +118 -35

327 lines not on this page · raw message

Regards,
-Gonglei

Quoted 55 lines

-----Original Message-----
From: Gonglei (Arei)
Sent: Wednesday, January 04, 2017 6:03 PM
To: [email protected]; [email protected]
Cc: Luonengjun; [email protected]; [email protected]; [email protected]; [email protected]; Jani Kokkonen; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Huangweidong (C); [email protected]; [email protected]; Claudio Fontana; Zhoujian (jay, Euler); [email protected]; [email protected]; Wubin (H); Shiqing Fan; [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v15 0/2] virtio-crypto: virtio crypto device specification

Changes since v14:
- drop VIRTIO_CRYPTO_S_STARTED status [Halil & Cornelia]
- correct a sentence about dataqueue and controlq in the first paragraph.
[Halil]
- change a MAY to MUST about max_dataqueues. [Halil]
- add non-session mode support
1) add four features for different crypto services to identify wheather
support session mode.
2) extend virtio_crypto_*_para structures, for example, add the content of struct virtio_crypto_cipher_session_para into struct
virtio_crypto_cipher_para.
3) use the flag property of struct virtio_crypto_op_header to identify the type of crypto request. Aka Is it a session-based or non-session request

For pervious versions of virtio crypto spec, Pls see:

[v14]:
https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg02212.html

[v13]:
https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg07348.html

For more information, please see:
http://qemu-project.org/Features/VirtioCrypto

Please help to review, thanks.

Gonglei (2):
virtio-crypto: Add virtio crypto device specification
virtio-crypto: Add conformance clauses

 conformance.tex   |   30 ++
 content.tex       |    2 +
 virtio-crypto.tex | 1029
+++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1061 insertions(+)
 create mode 100644 virtio-crypto.tex

--
1.7.12.4

#5 lore raw
Quoted 4 lines · Gonglei (Arei)

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

virtio-crypto.tex line 5

Quoted 11 lines
virtio-crypto.tex +1 -2
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a kind of
 virtual hardware accelerator for virtual machines. The encryption and
-decryption requests are placed in the data queue and are ultimately handled by the
-backend crypto accelerators. The second queue is the control queue used to create 
+decryption requests are placed in any of the data active queues and are ultimately handled by the

s/data active/active data/

Quoted 4 lines
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the control queue used to create 
 or destroy sessions for symmetric algorithms and will control some advanced
 features in the future. The virtio crypto device provides the following crypto
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 19 lines

===============The below diff shows the changes of add non-session mode support:

virtio-crypto.tex +4 -1
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device / Feature bits}
 
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is available for CIPHER service.
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is available for HASH service.
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is available for MAC service.
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is available for AEAD service.
 
 \subsection{Device configuration layout}\label{sec:Device Types / Crypto Device / Device configuration layout}
 

virtio-crypto.tex Operation parameters are algorithm-specific parameters, output data is the · line 216

Quoted 6 lines
virtio-crypto.tex +3 -0
@@ -208,6 +211,9 @@ Operation parameters are algorithm-specific parameters, output data is the
 data that should be utilized in operations, and input data is equal to
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device Types / Crypto Device / Device Operation / Control Virtqueue / Session operation}) and non-session mode, for example,
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated, the driver can use session mode for CIPHER service, otherwise it can only use non-session mode.
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the current implementation non-compliant?

Halil

#6 lore raw

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 57 lines

virtio-crypto.tex line 5

Quoted 9 lines
virtio-crypto.tex +0 -1
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a kind of
 virtual hardware accelerator for virtual machines. The encryption and
-decryption requests are placed in the data queue and are ultimately handled

by the

virtio-crypto.tex line 6

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue used to

create

virtio-crypto.tex line 5

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and are

ultimately handled by the
s/data active/active data/

virtio-crypto.tex line 6

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the control queue

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 2 lines
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the following crypto
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add non-session mode

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device / Feature

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is available

for CIPHER service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 29

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is available for

HASH service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 30

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is available for

MAC service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 31

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is available for

AEAD service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 32

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types / Crypto

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are algorithm-specific

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are algorithm-specific

parameters, output data is the

virtio-crypto.tex Operation parameters are algorithm-specific parameters, output data is the

Quoted 4 lines
virtio-crypto.tex +1 -0
 data that should be utilized in operations, and input data is equal to
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device Types /

Crypto Device / Device Operation / Control Virtqueue / Session operation}) and non-session mode, for example,

Quoted 9 lines

virtio-crypto.tex Operation parameters are algorithm-specific · line 215

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated, the driver

can use session mode for CIPHER service, otherwise it can only use non-session mode.

virtio-crypto.tex Operation parameters are algorithm-specific · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the current implementation non-compliant?

You are right, shall we use feature bits for non-session mode for compliancy? Or because the spec is on the fly, and some structures in the virtio_crypto.h need to be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

#7 lore raw
Quoted 81 lines · Gonglei (Arei)

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 57 lines

virtio-crypto.tex line 5

Quoted 9 lines
virtio-crypto.tex +0 -1
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a kind of
 virtual hardware accelerator for virtual machines. The encryption and
-decryption requests are placed in the data queue and are ultimately handled

by the

virtio-crypto.tex line 6

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue used to

create

virtio-crypto.tex line 5

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and are

ultimately handled by the
s/data active/active data/

virtio-crypto.tex line 6

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the control queue

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 2 lines
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the following crypto
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add non-session mode

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device / Feature

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is available

for CIPHER service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 29

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is available for

HASH service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 30

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is available for

MAC service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 31

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is available for

AEAD service.

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 32

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types / Crypto

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are algorithm-specific

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are algorithm-specific

parameters, output data is the

virtio-crypto.tex Operation parameters are algorithm-specific parameters, output data is the

Quoted 4 lines
virtio-crypto.tex +1 -0
 data that should be utilized in operations, and input data is equal to
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device Types /

Crypto Device / Device Operation / Control Virtqueue / Session operation}) and non-session mode, for example,

Quoted 9 lines

virtio-crypto.tex Operation parameters are algorithm-specific · line 215

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated, the driver

can use session mode for CIPHER service, otherwise it can only use non-session mode.

virtio-crypto.tex Operation parameters are algorithm-specific · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the current implementation non-compliant?

Quoted 6 lines

You are right, shall we use feature bits for non-session mode for compliancy? Or because the spec is on the fly, and some structures in the virtio_crypto.h need to be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Signature · 1 line
MST
#8 lore raw
Quoted 101 lines · Gonglei (Arei)
Quoted 15 lines

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 7 lines
Quoted 7 lines

virtio-crypto.tex line 3

Quoted 7 lines
virtio-crypto.tex +0 -0
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a kind

of

Quoted 2 lines
Quoted 2 lines

virtio-crypto.tex line 5

Quoted 2 lines
virtio-crypto.tex +0 -1
 virtual hardware accelerator for virtual machines. The encryption and
-decryption requests are placed in the data queue and are ultimately

handled

Quoted 2 lines
Quoted 2 lines

by the

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue used

to

Quoted 5 lines
Quoted 5 lines

create

virtio-crypto.tex line 5

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and are

ultimately handled by the
s/data active/active data/

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the control

queue

Quoted 4 lines
Quoted 4 lines

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 1 line
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the following

crypto

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
virtio-crypto.tex +0 -0
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add non-session

mode

Quoted 9 lines
Quoted 9 lines

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device /

Feature

Quoted 4 lines
Quoted 4 lines

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is

available

Quoted 2 lines
Quoted 2 lines

for CIPHER service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is available

for

Quoted 2 lines
Quoted 2 lines

HASH service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is available

for

Quoted 2 lines
Quoted 2 lines

MAC service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is available

for

Quoted 3 lines
Quoted 3 lines

AEAD service.

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types /

Crypto

Quoted 9 lines
Quoted 9 lines

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are algorithm-specific

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are algorithm-specific

parameters, output data is the

virtio-crypto.tex Operation parameters are algorithm-specific parameters, output data is the

Quoted 4 lines
virtio-crypto.tex +1 -0
 data that should be utilized in operations, and input data is equal to
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device Types /

Crypto Device / Device Operation / Control Virtqueue / Session operation})

and

Quoted 2 lines
Quoted 2 lines

non-session mode, for example,

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated, the

driver

Quoted 1 line
Quoted 1 line

can use session mode for CIPHER service, otherwise it can only use

non-session

Quoted 9 lines
Quoted 7 lines

mode.

virtio-crypto.tex Operation parameters are algorithm-specific · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the current implementation non-compliant?

You are right, shall we use feature bits for non-session mode for compliancy? Or because the spec is on the fly, and some structures in the virtio_crypto.h

Quoted 9 lines

need to

Quoted 4 lines

be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Sure. We use feature bits for non-session mode then. For structures modification, do we need to do some specific actions for compatibility? Take CIPHER service as an example:

The present structure:

struct virtio_crypto_cipher_para {
    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv data.
     *
     * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

The future structure if supporting non-session based operations:

struct virtio_crypto_cipher_para {
    struct {
        /* See VIRTIO_CRYPTO_CIPHER* above */
        le32 algo;
        /* length of key */
        le32 keylen;

        /* See VIRTIO_CRYPTO_OP_* above */
        le32 op;
    } sess_para;

    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv data.
     *
     * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

Thanks,
-Gonglei

#9 lore raw
Quoted 162 lines · Gonglei (Arei)
Quoted 101 lines · Gonglei (Arei)
Quoted 15 lines

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 7 lines
Quoted 7 lines

virtio-crypto.tex line 3

Quoted 7 lines
virtio-crypto.tex +0 -0
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a kind

of

Quoted 2 lines
Quoted 2 lines

virtio-crypto.tex line 5

Quoted 2 lines
virtio-crypto.tex +0 -1
 virtual hardware accelerator for virtual machines. The encryption and
-decryption requests are placed in the data queue and are ultimately

handled

Quoted 2 lines
Quoted 2 lines

by the

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue used

to

Quoted 5 lines
Quoted 5 lines

create

virtio-crypto.tex line 5

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and are

ultimately handled by the
s/data active/active data/

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the control

queue

Quoted 4 lines
Quoted 4 lines

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 1 line
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the following

crypto

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
virtio-crypto.tex +0 -0
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add non-session

mode

Quoted 9 lines
Quoted 9 lines

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device /

Feature

Quoted 4 lines
Quoted 4 lines

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is

available

Quoted 2 lines
Quoted 2 lines

for CIPHER service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is available

for

Quoted 2 lines
Quoted 2 lines

HASH service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is available

for

Quoted 2 lines
Quoted 2 lines

MAC service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is available

for

Quoted 3 lines
Quoted 3 lines

AEAD service.

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types /

Crypto

Quoted 9 lines
Quoted 9 lines

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are algorithm-specific

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are algorithm-specific

parameters, output data is the

virtio-crypto.tex Operation parameters are algorithm-specific parameters, output data is the

Quoted 4 lines
virtio-crypto.tex +1 -0
 data that should be utilized in operations, and input data is equal to
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device Types /

Crypto Device / Device Operation / Control Virtqueue / Session operation})

and

Quoted 2 lines
Quoted 2 lines

non-session mode, for example,

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated, the

driver

Quoted 1 line
Quoted 1 line

can use session mode for CIPHER service, otherwise it can only use

non-session

Quoted 9 lines
Quoted 7 lines

mode.

virtio-crypto.tex Operation parameters are algorithm-specific · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the current implementation non-compliant?

You are right, shall we use feature bits for non-session mode for compliancy? Or because the spec is on the fly, and some structures in the virtio_crypto.h

Quoted 9 lines

need to

Quoted 4 lines

be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Sure. We use feature bits for non-session mode then. For structures modification, do we need to do some specific actions for compatibility? Take CIPHER service as an example:

The present structure:

struct virtio_crypto_cipher_para {
    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv data.
     *
     * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

The future structure if supporting non-session based operations:

struct virtio_crypto_cipher_para {
    struct {
        /* See VIRTIO_CRYPTO_CIPHER* above */
        le32 algo;
        /* length of key */
        le32 keylen;

        /* See VIRTIO_CRYPTO_OP_* above */
        le32 op;
    } sess_para;

    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv data.
     *
     * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};
Quoted 2 lines

Thanks,
-Gonglei

So you will have to maintain both structures for when non-session based feature is and aren't present. You will have to give them different names, too.

Signature · 1 line
MST
#10 lore raw
Quoted 178 lines · Gonglei (Arei)
Quoted 18 lines
Quoted 18 lines · Gonglei (Arei)
Quoted 15 lines

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

virtio-crypto.tex line 3

Quoted 7 lines
virtio-crypto.tex +0 -0
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a

kind

Quoted 2 lines
Quoted 2 lines

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -0
 virtual hardware accelerator for virtual machines. The encryption

and

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

virtio-crypto.tex line 5

Quoted 1 line
virtio-crypto.tex +0 -1
-decryption requests are placed in the data queue and are ultimately

handled

Quoted 2 lines
Quoted 2 lines

by the

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue

used

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines

create

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and

are

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ultimately handled by the
s/data active/active data/

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the control

queue

Quoted 2 lines
Quoted 2 lines

used to create

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

advanced

Quoted 1 line
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the following

crypto

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
virtio-crypto.tex +0 -0
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add

non-session

Quoted 11 lines
Quoted 11 lines

mode

Quoted 9 lines
Quoted 9 lines

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device /

Feature

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is

available

Quoted 2 lines
Quoted 2 lines

for CIPHER service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

HASH service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

MAC service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is

available

Quoted 5 lines
Quoted 5 lines

for

Quoted 3 lines
Quoted 3 lines

AEAD service.

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types /

Crypto

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are algorithm-specific

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are algorithm-specific

parameters, output data is the

Quoted 4 lines
virtio-crypto.tex +1 -0
 data that should be utilized in operations, and input data is equal to
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device Types

/

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Crypto Device / Device Operation / Control Virtqueue / Session

operation})

Quoted 3 lines
Quoted 3 lines

and

Quoted 2 lines
Quoted 2 lines

non-session mode, for example,

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated,

the

Quoted 8 lines
Quoted 8 lines

driver

Quoted 1 line
Quoted 1 line

can use session mode for CIPHER service, otherwise it can only use

non-session

Quoted 5 lines
Quoted 5 lines

mode.

virtio-crypto.tex Operation parameters are algorithm-specific · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the

current

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

implementation non-compliant?

You are right, shall we use feature bits for non-session mode for

compliancy?

Quoted 1 line
Quoted 1 line
Quoted 1 line

Or because the spec is on the fly, and some structures in the

virtio_crypto.h

Quoted 61 lines
Quoted 9 lines

need to

Quoted 4 lines

be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Sure. We use feature bits for non-session mode then. For structures modification, do we need to do some specific actions for compatibility? Take CIPHER service as an example:

The present structure:

struct virtio_crypto_cipher_para {
    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv data.
     *
     * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

The future structure if supporting non-session based operations:

struct virtio_crypto_cipher_para {
    struct {
        /* See VIRTIO_CRYPTO_CIPHER* above */
        le32 algo;
        /* length of key */
        le32 keylen;

        /* See VIRTIO_CRYPTO_OP_* above */
        le32 op;
    } sess_para;

    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv data.
     *
     * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};
Quoted 7 lines
Quoted 2 lines

Thanks,
-Gonglei

So you will have to maintain both structures for when non-session based feature is and aren't present. You will have to give them different names, too.

OK, I get your point. :)

Thanks,
-Gonglei

#11 lore raw
In reply to Michael S. Tsirkin

Hi Michael and others,

I'd like to redefine struct virtio_crypto_op_data_req is as below:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

The length of union in the structure will be changed, which from current 48 byte to 72 byte.

We couldn't redefine a structure named virtio_crypto_op_data_req_non_sess, Because the feature bits are for crypto services, not for the wrapper packet request.

It's impossible to mixed use struct virtio_crypto_op_data_req and struct named virtio_crypto_op_data_req_non_sess for one data virtqueue.

For driver compabity, I can submit patches for linux dirver and Qemu to change the length of struct virtio_crypto_op_data_req.u

Is the approach available?

Thanks,
-Gonglei

Quoted 213 lines

-----Original Message-----
From: Gonglei (Arei)
Sent: Saturday, January 14, 2017 9:21 AM
To: 'Michael S. Tsirkin'
Cc: Halil Pasic; [email protected]; [email protected]; Huangweidong (C); [email protected]; [email protected]; Zhoujian (jay, Euler); [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Luonengjun; [email protected]; [email protected]; [email protected]; Shiqing Fan; Jani Kokkonen; [email protected]; Claudio Fontana; [email protected]; Wubin (H)
Subject: RE: [virtio-dev] Re: [Qemu-devel] [PATCH v15 0/2] virtio-crypto: virtio crypto device specification

Quoted 32 lines · Gonglei (Arei)
Quoted 18 lines
Quoted 18 lines · Gonglei (Arei)
Quoted 15 lines

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

virtio-crypto.tex line 3

Quoted 7 lines
virtio-crypto.tex +0 -0
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a

kind

Quoted 2 lines
Quoted 2 lines

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -0
 virtual hardware accelerator for virtual machines. The encryption

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -1
-decryption requests are placed in the data queue and are ultimately
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

handled

Quoted 2 lines
Quoted 2 lines

by the

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue

used

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines

create

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and

are

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ultimately handled by the
s/data active/active data/

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the

control

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

queue

Quoted 4 lines
Quoted 4 lines

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 1 line
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the

following

Quoted 34 lines
Quoted 6 lines
Quoted 6 lines

crypto

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
virtio-crypto.tex +0 -0
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add

non-session

Quoted 11 lines
Quoted 11 lines

mode

Quoted 9 lines
Quoted 9 lines

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device /

Feature

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is

available

Quoted 2 lines
Quoted 2 lines

for CIPHER service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

HASH service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

MAC service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is

available

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

for

Quoted 3 lines
Quoted 3 lines

AEAD service.

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types /

Crypto

Quoted 3 lines
Quoted 3 lines

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are

algorithm-specific

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

parameters, output data is the

Quoted 1 line
virtio-crypto.tex +0 -0
 data that should be utilized in operations, and input data is equal

to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

virtio-crypto.tex Operation parameters are algorithm-specific parameters, output data is the

Quoted 3 lines
virtio-crypto.tex +1 -0
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device

Types

Quoted 15 lines

/

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Crypto Device / Device Operation / Control Virtqueue / Session

operation})

Quoted 3 lines
Quoted 3 lines

and

Quoted 2 lines
Quoted 2 lines

non-session mode, for example,

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated,

the

Quoted 8 lines
Quoted 8 lines

driver

Quoted 1 line
Quoted 1 line

can use session mode for CIPHER service, otherwise it can only use

non-session

Quoted 5 lines
Quoted 5 lines

mode.

virtio-crypto.tex Operation parameters are · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the

Quoted 25 lines

current

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

implementation non-compliant?

You are right, shall we use feature bits for non-session mode for

compliancy?

Quoted 1 line
Quoted 1 line
Quoted 1 line

Or because the spec is on the fly, and some structures in the

virtio_crypto.h

Quoted 18 lines
Quoted 9 lines

need to

Quoted 4 lines

be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Sure. We use feature bits for non-session mode then. For structures modification, do we need to do some specific actions for compatibility? Take CIPHER service as an example:

The present structure:

struct virtio_crypto_cipher_para {
/*
* Byte Length of valid IV/Counter data pointed to by the below iv

data.

Quoted 2 lines
Quoted 2 lines

*
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or

for

Quoted 21 lines
Quoted 21 lines
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

The future structure if supporting non-session based operations:

struct virtio_crypto_cipher_para {
    struct {
        /* See VIRTIO_CRYPTO_CIPHER* above */
        le32 algo;
        /* length of key */
        le32 keylen;
Quoted 6 lines
Quoted 6 lines
        /* See VIRTIO_CRYPTO_OP_* above */
        le32 op;
    } sess_para;

    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv

data.

Quoted 2 lines
Quoted 2 lines

*
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or

for

Quoted 12 lines
Quoted 12 lines
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};
Quoted 7 lines
Quoted 2 lines

Thanks,
-Gonglei

So you will have to maintain both structures for when non-session based feature is and aren't present. You will have to give them different names, too.

OK, I get your point. :)

Thanks,
-Gonglei

#12 lore raw
Quoted 20 lines · Gonglei (Arei)

Hi Michael and others,

I'd like to redefine struct virtio_crypto_op_data_req is as below:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};
Quoted 5 lines

The length of union in the structure will be changed, which from current 48 byte to 72 byte.

We couldn't redefine a structure named virtio_crypto_op_data_req_non_sess, Because the feature bits are for crypto services, not for the wrapper packet request.

You mean virtio_crypto_op_data_req.virtio_crypto_op_header.flags are conceptually meant for something else and using that field woulb be misuse?

Quoted 3 lines

It's impossible to mixed use struct virtio_crypto_op_data_req and struct named virtio_crypto_op_data_req_non_sess for one data virtqueue.

I do not understand what are you trying to say here. I think you should tell us what is the new feature and how it is guarded.

Would this mean that session or non-session mode will be tied to the whole device, or to one data-queue. If it's data-queue level how is it controlled (e.g. control queue)?

I guess virtio_crypto_op_data_req.virtio_crypto_op_header.session_id would become meaningless in case of non_sess?

Quoted 5 lines

For driver compabity, I can submit patches for linux dirver and Qemu to change the length of struct virtio_crypto_op_data_req.u

Is the approach available?

In general and AFAIU any new behavior is possible, iff it is appropriately guarded by some negotiation mechanism and does not break per-existing code which knows nothing about the new stuff.

I would not mind seeing a spec re-spin with a proper proposal for session-less or stateless or whatever mode.

Cheers,
Halil

Quoted 219 lines

Thanks,
-Gonglei

Quoted 213 lines

-----Original Message-----
From: Gonglei (Arei)
Sent: Saturday, January 14, 2017 9:21 AM
To: 'Michael S. Tsirkin'
Cc: Halil Pasic; [email protected]; [email protected]; Huangweidong (C); [email protected]; [email protected]; Zhoujian (jay, Euler); [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Luonengjun; [email protected]; [email protected]; [email protected]; Shiqing Fan; Jani Kokkonen; [email protected]; Claudio Fontana; [email protected]; Wubin (H)
Subject: RE: [virtio-dev] Re: [Qemu-devel] [PATCH v15 0/2] virtio-crypto: virtio crypto device specification

Quoted 32 lines · Gonglei (Arei)
Quoted 18 lines
Quoted 18 lines · Gonglei (Arei)
Quoted 15 lines

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

virtio-crypto.tex line 3

Quoted 7 lines
virtio-crypto.tex +0 -0
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a

kind

Quoted 2 lines
Quoted 2 lines

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -0
 virtual hardware accelerator for virtual machines. The encryption

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -1
-decryption requests are placed in the data queue and are ultimately
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

handled

Quoted 2 lines
Quoted 2 lines

by the

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue

used

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines

create

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and

are

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ultimately handled by the
s/data active/active data/

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the

control

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

queue

Quoted 4 lines
Quoted 4 lines

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 1 line
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the

following

Quoted 34 lines
Quoted 6 lines
Quoted 6 lines

crypto

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
virtio-crypto.tex +0 -0
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add

non-session

Quoted 11 lines
Quoted 11 lines

mode

Quoted 9 lines
Quoted 9 lines

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device /

Feature

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is

available

Quoted 2 lines
Quoted 2 lines

for CIPHER service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

HASH service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

MAC service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is

available

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

for

Quoted 3 lines
Quoted 3 lines

AEAD service.

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types /

Crypto

Quoted 3 lines
Quoted 3 lines

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are

algorithm-specific

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

parameters, output data is the

Quoted 1 line
virtio-crypto.tex +0 -0
 data that should be utilized in operations, and input data is equal

to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

virtio-crypto.tex Operation parameters are · line 214

Quoted 3 lines
virtio-crypto.tex +1 -0
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device

Types

Quoted 15 lines

/

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Crypto Device / Device Operation / Control Virtqueue / Session

operation})

Quoted 3 lines
Quoted 3 lines

and

Quoted 2 lines
Quoted 2 lines

non-session mode, for example,

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated,

the

Quoted 8 lines
Quoted 8 lines

driver

Quoted 1 line
Quoted 1 line

can use session mode for CIPHER service, otherwise it can only use

non-session

Quoted 5 lines
Quoted 5 lines

mode.

virtio-crypto.tex Operation parameters are · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the

Quoted 25 lines

current

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

implementation non-compliant?

You are right, shall we use feature bits for non-session mode for

compliancy?

Quoted 1 line
Quoted 1 line
Quoted 1 line

Or because the spec is on the fly, and some structures in the

virtio_crypto.h

Quoted 18 lines
Quoted 9 lines

need to

Quoted 4 lines

be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Sure. We use feature bits for non-session mode then. For structures modification, do we need to do some specific actions for compatibility? Take CIPHER service as an example:

The present structure:

struct virtio_crypto_cipher_para {
/*
* Byte Length of valid IV/Counter data pointed to by the below iv

data.

Quoted 2 lines
Quoted 2 lines

*
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or

for

Quoted 21 lines
Quoted 21 lines
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

The future structure if supporting non-session based operations:

struct virtio_crypto_cipher_para {
    struct {
        /* See VIRTIO_CRYPTO_CIPHER* above */
        le32 algo;
        /* length of key */
        le32 keylen;
Quoted 6 lines
Quoted 6 lines
        /* See VIRTIO_CRYPTO_OP_* above */
        le32 op;
    } sess_para;

    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv

data.

Quoted 2 lines
Quoted 2 lines

*
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or

for

Quoted 12 lines
Quoted 12 lines
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};
Quoted 7 lines
Quoted 2 lines

Thanks,
-Gonglei

So you will have to maintain both structures for when non-session based feature is and aren't present. You will have to give them different names, too.

OK, I get your point. :)

Thanks,
-Gonglei

#13 lore raw

Hi Halil,

Quoted 30 lines · Gonglei (Arei)
Quoted 4 lines

Hi Michael and others,

I'd like to redefine struct virtio_crypto_op_data_req is as below:

Quoted 9 lines
struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess

sym_non_sess_req;

Quoted 1 line

struct virtio_crypto_hash_data_req_non_sess

hash_non_sess_req;

Quoted 1 line

struct virtio_crypto_mac_data_req_non_sess

mac_non_sess_req;

Quoted 1 line

struct virtio_crypto_aead_data_req_non_sess

aead_non_sess_req;

Quoted 5 lines
		__u8 padding[72];
    } u;
};

The length of union in the structure will be changed, which from current 48

byte to 72 byte.

Quoted 2 lines

We couldn't redefine a structure named

Quoted 9 lines

virtio_crypto_op_data_req_non_sess,

Quoted 1 line

Because the feature bits are for crypto services, not for the wrapper packet

request.

Quoted 1 line

You mean virtio_crypto_op_data_req.virtio_crypto_op_header.flags are conceptually meant for something else and using that field woulb be misuse?

Nope...

Quoted 5 lines
Quoted 4 lines

It's impossible to mixed use struct virtio_crypto_op_data_req and struct named virtio_crypto_op_data_req_non_sess for one data virtqueue.

Quoted 7 lines

I do not understand what are you trying to say here. I think you should tell us what is the new feature and how it is guarded.

Would this mean that session or non-session mode will be tied to the whole device, or to one data-queue. If it's data-queue level how is it controlled (e.g. control queue)?

... I'm so sorry for confusing explanation. Let me try to explain it more clear.

1 ) The first idea: For support non-session mode crypto operations, I introduce 4 feature bits for different crypto services, they are:

VIRTIO_CRYPTO_F_CIPHER_NON_SESSION_MODE (1) non-session mode is available for CIPHER service. VIRTIO_CRYPTO_F_HASH_NON_SESSION_MODE (2) non-session mode is available for HASH service. VIRTIO_CRYPTO_F_MAC_NON_SESSION_MODE (3) non-session mode is available for MAC service. VIRTIO_CRYPTO_F_AEAD_NON_SESSION_MODE (4) non-session mode is available for AEAD service.

but not only one feature bit, something like:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (1) non-session mode is available.

Meanwhile, I define 4 new non-session mode structures for different crypto services in order to keep compatibility to pre-existing driver.

-*Advantages*:

a) We can support different modes for different crypto services according to which features are negotiated.

b) The driver can still use the session mode when VIRTIO_CRYPTO_F_*_NON_SESSION_MODE are negotiated, which is under control by virtio_crypto_op_data_req.virtio_crypto_op_header.flags.

- *Disadvantages*:

The current crypto packets of all
crypto services (CIPHER, HASH, MAC and AEAD) are wrapped in structure virtio_crypto_op_data_req by an union in the data plane.

It will change the length of the union and break the pre-existing code if still lay all non-session mode structures in strut virtio_crypto_op_data_req like this:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

So I should submit patches to fix them.

2) Another idea is define a non-session mode structure for strut virtio_crypto_op_data_req.

struct virtio_crypto_op_data_req_non_sess {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

And keep the pre-existing strut virtio_crypto_op_data_req:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
		__u8 padding[48];
    } u;
};

- *Advantages*:

Don't break the pre-existing code.

- *Disadvantages*:

Can't support feature bits for different crypto services, only the whole device. That means we should only use the below feature bit:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (1) non-session mode is available.

3) The last idea is define a mixed structure for strut virtio_crypto_op_data_req.

struct virtio_crypto_op_data_req_mixed {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

And keep the pre-existing strut virtio_crypto_op_data_req:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
		__u8 padding[48];
    } u;
};

That means we should use below five feature bits:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (0) non-session mode is available. VIRTIO_CRYPTO_F_CIPHER_NON_SESSION_MODE (1) non-session mode is available for CIPHER service. VIRTIO_CRYPTO_F_HASH_NON_SESSION_MODE (2) non-session mode is available for HASH service. VIRTIO_CRYPTO_F_MAC_NON_SESSION_MODE (3) non-session mode is available for MAC service. VIRTIO_CRYPTO_F_AEAD_NON_SESSION_MODE (4) non-session mode is available for AEAD service.

-*Advantages*:

Both idea 1) and 2).

-*Disadvantages*:

None.

What's your opinion? Thanks a lot!

Quoted 3 lines

I guess virtio_crypto_op_data_req.virtio_crypto_op_header.session_id would become meaningless in case of non_sess?

That's true.

Quoted 7 lines
Quoted 1 line

For driver compabity, I can submit patches for linux dirver and Qemu to

change the length

Quoted 4 lines

of struct virtio_crypto_op_data_req.u

Is the approach available?

Quoted 8 lines

In general and AFAIU any new behavior is possible, iff it is appropriately guarded by some negotiation mechanism and does not break per-existing code which knows nothing about the new stuff.

I would not mind seeing a spec re-spin with a proper proposal for session-less or stateless or whatever mode.

Thanks,
-Gonglei

Quoted 214 lines

Cheers,
Halil

Quoted 8 lines

Thanks,
-Gonglei

Quoted 4 lines

-----Original Message-----
From: Gonglei (Arei)
Sent: Saturday, January 14, 2017 9:21 AM
Subject: RE: [virtio-dev] Re: [Qemu-devel] [PATCH v15 0/2] virtio-crypto:

virtio

Quoted 202 lines
Quoted 200 lines

crypto device specification

Quoted 32 lines · Gonglei (Arei)
Quoted 18 lines
Quoted 18 lines · Gonglei (Arei)
Quoted 15 lines

Hi,

Quoted 10 lines · Gonglei (Arei)
Quoted 4 lines

Hi all,

I attach the diff files between v14 and v15 for better review.

Hi,

only had a quick look. Will try to come back to this later.

That's cool.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

virtio-crypto.tex line 3

Quoted 7 lines
virtio-crypto.tex +0 -0
index 9f7faf0..884ee95 100644
@@ -2,8 +2,8 @@
 
 The virtio crypto device is a virtual cryptography device as well as a

kind

Quoted 2 lines
Quoted 2 lines

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -0
 virtual hardware accelerator for virtual machines. The encryption

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
virtio-crypto.tex +0 -1
-decryption requests are placed in the data queue and are ultimately
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

handled

Quoted 2 lines
Quoted 2 lines

by the

Quoted 1 line
virtio-crypto.tex +0 -1
-backend crypto accelerators. The second queue is the control queue

used

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines

create

Quoted 1 line
virtio-crypto.tex +1 -0
+decryption requests are placed in any of the data active queues and

are

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ultimately handled by the
s/data active/active data/

Quoted 1 line
virtio-crypto.tex +1 -0
+backend crypto accelerators. The second kind of queue is the

control

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

queue

Quoted 4 lines
Quoted 4 lines

used to create

virtio-crypto.tex line 7

Quoted 1 line
virtio-crypto.tex +0 -0
 or destroy sessions for symmetric algorithms and will control some

advanced

Quoted 1 line
virtio-crypto.tex +0 -0
 features in the future. The virtio crypto device provides the

following

Quoted 34 lines
Quoted 6 lines
Quoted 6 lines

crypto

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
virtio-crypto.tex +0 -0
 services: CIPHER, MAC, HASH, and AEAD.

[..]

Quoted 1 line

===============The below diff shows the changes of add

non-session

Quoted 11 lines
Quoted 11 lines

mode

Quoted 9 lines
Quoted 9 lines

support:

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 27

Quoted 8 lines
virtio-crypto.tex +0 -0
index 884ee95..44819f9 100644
@@ -26,7 +26,10 @@ N is set by \field{max_dataqueues}.
 
 \subsection{Feature bits}\label{sec:Device Types / Crypto Device /

Feature

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

bits}

virtio-crypto.tex N is set by \field{max_dataqueues}. · line 28

Quoted 3 lines
virtio-crypto.tex +1 -1
-None currently defined.
+VIRTIO_CRYPTO_F_CIPHER_SESSION_MODE (1) Session mode is

available

Quoted 2 lines
Quoted 2 lines

for CIPHER service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_HASH_SESSION_MODE (2) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

HASH service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_MAC_SESSION_MODE (3) Session mode is

available

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

MAC service.

Quoted 1 line
virtio-crypto.tex +1 -0
+VIRTIO_CRYPTO_F_AEAD_SESSION_MODE (4) Session mode is

available

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

for

Quoted 3 lines
Quoted 3 lines

AEAD service.

Quoted 2 lines
virtio-crypto.tex +0 -0
 \subsection{Device configuration layout}\label{sec:Device Types /

Crypto

Quoted 3 lines
Quoted 3 lines

Device / Device configuration layout}

virtio-crypto.tex Operation parameters are

Quoted 2 lines
virtio-crypto.tex +0 -0
@@ -208,6 +211,9 @@ Operation parameters are

algorithm-specific

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

parameters, output data is the

Quoted 1 line
virtio-crypto.tex +0 -0
 data that should be utilized in operations, and input data is equal

to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

virtio-crypto.tex Operation parameters are · line 214

Quoted 3 lines
virtio-crypto.tex +1 -0
 "operation result + result data".
 
+The device can support both session mode (See \ref{sec:Device

Types

Quoted 15 lines

/

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Crypto Device / Device Operation / Control Virtqueue / Session

operation})

Quoted 3 lines
Quoted 3 lines

and

Quoted 2 lines
Quoted 2 lines

non-session mode, for example,

Quoted 1 line
virtio-crypto.tex +1 -0
+As VIRTIO_CRYPTO_F_CIPHER_SESSION feature bit is negotiated,

the

Quoted 8 lines
Quoted 8 lines

driver

Quoted 1 line
Quoted 1 line

can use session mode for CIPHER service, otherwise it can only use

non-session

Quoted 5 lines
Quoted 5 lines

mode.

virtio-crypto.tex Operation parameters are · line 216

Quoted 1 line
virtio-crypto.tex +1 -0
+

As far as I understand you are adding non-session mode to the mix but providing feature bits for session mode. Would this render the the

Quoted 25 lines

current

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

implementation non-compliant?

You are right, shall we use feature bits for non-session mode for

compliancy?

Quoted 1 line
Quoted 1 line
Quoted 1 line

Or because the spec is on the fly, and some structures in the

virtio_crypto.h

Quoted 18 lines
Quoted 9 lines

need to

Quoted 4 lines

be modified, can we keep the compliancy completely?

Thanks,
-Gonglei

Since there's a linux driver upstream you must at least keep compatibility with that.

Sure. We use feature bits for non-session mode then. For structures modification, do we need to do some specific actions for compatibility? Take CIPHER service as an example:

The present structure:

struct virtio_crypto_cipher_para {
/*
* Byte Length of valid IV/Counter data pointed to by the below iv

data.

Quoted 2 lines
Quoted 2 lines

*
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or

for

Quoted 21 lines
Quoted 21 lines
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};

The future structure if supporting non-session based operations:

struct virtio_crypto_cipher_para {
    struct {
        /* See VIRTIO_CRYPTO_CIPHER* above */
        le32 algo;
        /* length of key */
        le32 keylen;
Quoted 6 lines
Quoted 6 lines
        /* See VIRTIO_CRYPTO_OP_* above */
        le32 op;
    } sess_para;

    /*
     * Byte Length of valid IV/Counter data pointed to by the below iv

data.

Quoted 2 lines
Quoted 2 lines

*
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or

for

Quoted 12 lines
Quoted 12 lines
     *   SNOW3G in UEA2 mode, this is the length of the IV (which
     *   must be the same as the block length of the cipher).
     * For block ciphers in CTR mode, this is the length of the counter
     *   (which must be the same as the block length of the cipher).
     */
    le32 iv_len;
    /* length of source data */
    le32 src_data_len;
    /* length of destination data */
    le32 dst_data_len;
};
Quoted 7 lines
Quoted 2 lines

Thanks,
-Gonglei

So you will have to maintain both structures for when non-session based feature is and aren't present. You will have to give them different names, too.

OK, I get your point. :)

Thanks,
-Gonglei

#14 lore raw
Quoted 30 lines · Gonglei (Arei)

Hi Halil,

Quoted 28 lines · Gonglei (Arei)
Quoted 4 lines

Hi Michael and others,

I'd like to redefine struct virtio_crypto_op_data_req is as below:

Quoted 9 lines
struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess

sym_non_sess_req;

Quoted 1 line

struct virtio_crypto_hash_data_req_non_sess

hash_non_sess_req;

Quoted 1 line

struct virtio_crypto_mac_data_req_non_sess

mac_non_sess_req;

Quoted 1 line

struct virtio_crypto_aead_data_req_non_sess

aead_non_sess_req;

Quoted 5 lines
		__u8 padding[72];
    } u;
};

The length of union in the structure will be changed, which from current 48

byte to 72 byte.

Quoting seems broken :(

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

We couldn't redefine a structure named

virtio_crypto_op_data_req_non_sess,

Quoted 1 line

Because the feature bits are for crypto services, not for the wrapper packet

Quoted 9 lines
Quoted 7 lines

request.

Quoted 1 line

You mean virtio_crypto_op_data_req.virtio_crypto_op_header.flags are conceptually meant for something else and using that field woulb be misuse?

Nope...

Quoted 1 line

I'm having huge difficulties following you. Please tell me what was the intended meaning of the sentence I commented! About which flags are you talking?

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

It's impossible to mixed use struct virtio_crypto_op_data_req and struct named virtio_crypto_op_data_req_non_sess for one data virtqueue.

Quoted 8 lines
Quoted 7 lines

I do not understand what are you trying to say here. I think you should tell us what is the new feature and how it is guarded.

Would this mean that session or non-session mode will be tied to the whole device, or to one data-queue. If it's data-queue level how is it controlled (e.g. control queue)?

... I'm so sorry for confusing explanation. Let me try to explain it more clear.

Which explanation? Now I see three ideas as a more clear explanation where I figured we are discussing one idea.

Quoted 34 lines

1 ) The first idea: For support non-session mode crypto operations, I introduce 4 feature bits for different crypto services, they are:

VIRTIO_CRYPTO_F_CIPHER_NON_SESSION_MODE (1) non-session mode is available for CIPHER service. VIRTIO_CRYPTO_F_HASH_NON_SESSION_MODE (2) non-session mode is available for HASH service. VIRTIO_CRYPTO_F_MAC_NON_SESSION_MODE (3) non-session mode is available for MAC service. VIRTIO_CRYPTO_F_AEAD_NON_SESSION_MODE (4) non-session mode is available for AEAD service.

but not only one feature bit, something like:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (1) non-session mode is available.

Meanwhile, I define 4 new non-session mode structures for different crypto services in order to keep compatibility to pre-existing driver.

-*Advantages*:

a) We can support different modes for different crypto services according to which features are negotiated.

b) The driver can still use the session mode when VIRTIO_CRYPTO_F_*_NON_SESSION_MODE are negotiated, which is under control by virtio_crypto_op_data_req.virtio_crypto_op_header.flags.

- *Disadvantages*:

The current crypto packets of all
crypto services (CIPHER, HASH, MAC and AEAD) are wrapped in structure virtio_crypto_op_data_req by an union in the data plane.

It will change the length of the union and break the pre-existing code if still lay all non-session mode structures in strut virtio_crypto_op_data_req like this:

Quoted 15 lines
struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

Yeah if you say a request has to look like this regardless of negotiated features, then you render the currently upstream code non-conform. That's pretty much a decisive disadvantage!

Quoted 2 lines

So I should submit patches to fix them.

And IMHO you can not fix that with patches because it's already released -- and you would have to travel back in time to fix it in time.

Quoted 29 lines

2) Another idea is define a non-session mode structure for strut virtio_crypto_op_data_req.

struct virtio_crypto_op_data_req_non_sess {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

And keep the pre-existing strut virtio_crypto_op_data_req:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
		__u8 padding[48];
    } u;
};
Quoted 8 lines

- *Advantages*:

Don't break the pre-existing code.

- *Disadvantages*:

Can't support feature bits for different crypto services, only the whole device. That means we should only use the below feature

I do not see why, and I do not see why should we want to have separate feature bits for each service.

Quoted 47 lines

bit:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (1) non-session mode is available.

3) The last idea is define a mixed structure for strut virtio_crypto_op_data_req.

struct virtio_crypto_op_data_req_mixed {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess   sym_non_sess_req;
        struct virtio_crypto_hash_data_req_non_sess  hash_non_sess_req;
        struct virtio_crypto_mac_data_req_non_sess   mac_non_sess_req;
        struct virtio_crypto_aead_data_req_non_sess  aead_non_sess_req;
		__u8 padding[72];
    } u;
};

And keep the pre-existing strut virtio_crypto_op_data_req:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
		__u8 padding[48];
    } u;
};

That means we should use below five feature bits:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (0) non-session mode is available. VIRTIO_CRYPTO_F_CIPHER_NON_SESSION_MODE (1) non-session mode is available for CIPHER service. VIRTIO_CRYPTO_F_HASH_NON_SESSION_MODE (2) non-session mode is available for HASH service. VIRTIO_CRYPTO_F_MAC_NON_SESSION_MODE (3) non-session mode is available for MAC service. VIRTIO_CRYPTO_F_AEAD_NON_SESSION_MODE (4) non-session mode is available for AEAD service.

-*Advantages*:

Quoted 9 lines

Both idea 1) and 2).

-*Disadvantages*:

None.

What's your opinion? Thanks a lot!

You kindly forget to tell us how it is to be decided which of the unioned types is actually relevant for an instance. And also forget to tell us which struct is used under which circumstances (that is feature bits).

Well it does not matter. Have seen v16 and there you went for idea 3, and decided to use virtio_crypto_op_header.flags to decide if we have a session based or a stateless request at hand if feature bits allow both. I will try to do a proper review there.

My opinion is that you should be more precise when describing your ideas if you want to hear a more constrictive opinion than this one.

Cheers,
Halil

#15 lore raw
Quoted 180 lines · Gonglei (Arei)
Quoted 30 lines

Hi Halil,

Quoted 28 lines · Gonglei (Arei)
Quoted 4 lines

Hi Michael and others,

I'd like to redefine struct virtio_crypto_op_data_req is as below:

Quoted 9 lines
struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess

sym_non_sess_req;

Quoted 1 line

struct virtio_crypto_hash_data_req_non_sess

hash_non_sess_req;

Quoted 1 line

struct virtio_crypto_mac_data_req_non_sess

mac_non_sess_req;

Quoted 1 line

struct virtio_crypto_aead_data_req_non_sess

aead_non_sess_req;

Quoted 5 lines
		__u8 padding[72];
    } u;
};

The length of union in the structure will be changed, which from current 48

byte to 72 byte.

Quoting seems broken :(

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

We couldn't redefine a structure named

virtio_crypto_op_data_req_non_sess,

Quoted 1 line

Because the feature bits are for crypto services, not for the wrapper

packet

Quoted 9 lines
Quoted 7 lines

request.

Quoted 1 line

You mean virtio_crypto_op_data_req.virtio_crypto_op_header.flags are conceptually meant for something else and using that field woulb be misuse?

Nope...

Quoted 1 line

I'm having huge difficulties following you. Please tell me what was the intended meaning of the sentence I commented! About which flags are you talking?

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

It's impossible to mixed use struct virtio_crypto_op_data_req and struct named virtio_crypto_op_data_req_non_sess for one data virtqueue.

Quoted 8 lines
Quoted 7 lines

I do not understand what are you trying to say here. I think you should tell us what is the new feature and how it is guarded.

Would this mean that session or non-session mode will be tied to the whole device, or to one data-queue. If it's data-queue level how is it controlled (e.g. control queue)?

... I'm so sorry for confusing explanation. Let me try to explain it more clear.

Which explanation? Now I see three ideas as a more clear explanation where I figured we are discussing one idea.

Quoted 2 lines

1 ) The first idea: For support non-session mode crypto operations, I introduce

4 feature bits

Quoted 3 lines

for different crypto services, they are:

VIRTIO_CRYPTO_F_CIPHER_NON_SESSION_MODE (1) non-session mode is

available for CIPHER service.

Quoted 1 line

VIRTIO_CRYPTO_F_HASH_NON_SESSION_MODE (2) non-session mode is

available for HASH service.

Quoted 1 line

VIRTIO_CRYPTO_F_MAC_NON_SESSION_MODE (3) non-session mode is

available for MAC service.

Quoted 1 line

VIRTIO_CRYPTO_F_AEAD_NON_SESSION_MODE (4) non-session mode is

available for AEAD service.

Quoted 8 lines

but not only one feature bit, something like:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (1) non-session mode is available.

Meanwhile, I define 4 new non-session mode structures for different crypto services in order to keep compatibility to pre-existing driver.

Quoted 6 lines

-*Advantages*:

a) We can support different modes for different crypto services according to which features are negotiated.

b) The driver can still use the session mode when

VIRTIO_CRYPTO_F_*_NON_SESSION_MODE are negotiated,

Quoted 1 line

which is under control by

virtio_crypto_op_data_req.virtio_crypto_op_header.flags.

Quoted 11 lines

- *Disadvantages*:

The current crypto packets of all
crypto services (CIPHER, HASH, MAC and AEAD) are wrapped in structure virtio_crypto_op_data_req by an union in the data plane.

It will change the length of the union and break the pre-existing code if still lay all non-session mode structures in strut virtio_crypto_op_data_req like this:

Quoted 9 lines
struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess

sym_non_sess_req;

Quoted 1 line

struct virtio_crypto_hash_data_req_non_sess

hash_non_sess_req;

Quoted 1 line

struct virtio_crypto_mac_data_req_non_sess

mac_non_sess_req;

Quoted 1 line

struct virtio_crypto_aead_data_req_non_sess

aead_non_sess_req;

Quoted 3 lines
		__u8 padding[72];
    } u;
};

Yeah if you say a request has to look like this regardless of negotiated features, then you render the currently upstream code non-conform. That's pretty much a decisive disadvantage!

Quoted 2 lines

So I should submit patches to fix them.

And IMHO you can not fix that with patches because it's already released -- and you would have to travel back in time to fix it in time.

Quoted 2 lines

2) Another idea is define a non-session mode structure for strut

virtio_crypto_op_data_req.

Quoted 6 lines
struct virtio_crypto_op_data_req_non_sess {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req_non_sess

sym_non_sess_req;

Quoted 1 line

struct virtio_crypto_hash_data_req_non_sess

hash_non_sess_req;

Quoted 1 line

struct virtio_crypto_mac_data_req_non_sess

mac_non_sess_req;

Quoted 1 line

struct virtio_crypto_aead_data_req_non_sess

aead_non_sess_req;

Quoted 22 lines
		__u8 padding[72];
    } u;
};

And keep the pre-existing strut virtio_crypto_op_data_req:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
		__u8 padding[48];
    } u;
};

- *Advantages*:

Don't break the pre-existing code.

Quoted 8 lines
Quoted 4 lines

- *Disadvantages*:

Can't support feature bits for different crypto services, only the whole device. That means we should only use the below feature

I do not see why, and I do not see why should we want to have separate feature bits for each service.

That's because we need fine control so that we can know use session or non-session based packet structure for each crypto services.

Quoted 62 lines
Quoted 6 lines

bit:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (1) non-session mode is available.

3) The last idea is define a mixed structure for strut

virtio_crypto_op_data_req.

Quoted 10 lines
struct virtio_crypto_op_data_req_mixed {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
        struct virtio_crypto_sym_data_req_non_sess

sym_non_sess_req;

Quoted 1 line

struct virtio_crypto_hash_data_req_non_sess

hash_non_sess_req;

Quoted 1 line

struct virtio_crypto_mac_data_req_non_sess

mac_non_sess_req;

Quoted 1 line

struct virtio_crypto_aead_data_req_non_sess

aead_non_sess_req;

Quoted 18 lines
		__u8 padding[72];
    } u;
};

And keep the pre-existing strut virtio_crypto_op_data_req:

struct virtio_crypto_op_data_req {
    struct virtio_crypto_op_header header;

    union {
        struct virtio_crypto_sym_data_req   sym_req;
        struct virtio_crypto_hash_data_req  hash_req;
        struct virtio_crypto_mac_data_req   mac_req;
        struct virtio_crypto_aead_data_req  aead_req;
		__u8 padding[48];
    } u;
};
Quoted 4 lines

That means we should use below five feature bits:

VIRTIO_CRYPTO_F_ NON_SESSION_MODE (0) non-session mode is available. VIRTIO_CRYPTO_F_CIPHER_NON_SESSION_MODE (1) non-session mode is

available for CIPHER service.

Quoted 1 line

VIRTIO_CRYPTO_F_HASH_NON_SESSION_MODE (2) non-session mode is

available for HASH service.

Quoted 1 line

VIRTIO_CRYPTO_F_MAC_NON_SESSION_MODE (3) non-session mode is

available for MAC service.

Quoted 1 line

VIRTIO_CRYPTO_F_AEAD_NON_SESSION_MODE (4) non-session mode is

available for AEAD service.

Quoted 9 lines

-*Advantages*:

Both idea 1) and 2).

-*Disadvantages*:

None.

Quoted 9 lines
Quoted 3 lines

What's your opinion? Thanks a lot!

You kindly forget to tell us how it is to be decided which of the unioned types is actually relevant for an instance. And also forget to tell us which struct is used under which circumstances (that is feature bits).

Exactly, there're some descriptions in v16.

Quoted 5 lines

Well it does not matter. Have seen v16 and there you went for idea 3, and decided to use virtio_crypto_op_header.flags to decide if we have a session based or a stateless request at hand if feature bits allow both. I will try to do a proper review there.

Yes. Looking forward to your feedback, thanks!

Quoted 4 lines

My opinion is that you should be more precise when describing your ideas if you want to hear a more constrictive opinion than this one.

Sure, sorry about that.

Thanks,
-Gonglei

author
#16 lore raw

PATCH v15 2/2 virtio-crypto: Add conformance clauses

In reply to Gonglei

Add the conformance targets and clauses for
virtio-crypto device.

---
 conformance.tex | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
conformance.tex +30 -0
index f59e360..3bde4b6 100644
@@ -146,6 +146,21 @@ An SCSI host driver MUST conform to the following normative statements:
 \item \ref{drivernormative:Device Types / SCSI Host Device / Device Operation / Device Operation: eventq}
 \end{itemize}
 
+\subsection{Crypto Driver Conformance}\label{sec:Conformance / Driver Conformance / Crypto Driver Conformance}
+
+An Crypto driver MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Crypto Device / Device configuration layout}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Initialization}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / Control Virtqueue / Session operation / Session operation: create session}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / Control Virtqueue / Session operation / Session operation: destroy session}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / HASH Service operation}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / MAC Service operation}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / Symmetric algorithms Operation}
+\item \ref{drivernormative:Device Types / Crypto Device / Device Operation / AEAD Service operation}
+\end{itemize}
+
 \section{Device Conformance}\label{sec:Conformance / Device Conformance}
 
 A device MUST conform to the following normative statements:
@@ -267,6 +282,21 @@ An SCSI host device MUST conform to the following normative statements:
 \item \ref{devicenormative:Device Types / SCSI Host Device / Device Operation / Device Operation: eventq}
 \end{itemize}
 
+\subsection{Crypto Device Conformance}\label{sec:Conformance / Device Conformance / Crypto Device Conformance}
+
+An Crypto device MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{devicenormative:Device Types / Crypto Device / Device configuration layout}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Initialization}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / Control Virtqueue / Session operation / Session operation: create session}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / Control Virtqueue / Session operation / Session operation: destroy session}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / HASH Service operation}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / MAC Service operation}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / Symmetric algorithms Operation}
+\item \ref{devicenormative:Device Types / Crypto Device / Device Operation / AEAD Service operation}
+\end{itemize}
+
 \section{Legacy Interface: Transitional Device and
 Transitional Driver Conformance}\label{sec:Conformance / Legacy
 Interface: Transitional Device and 
Signature · 1 line
1.7.12.4
#17 lore raw
In reply to Gonglei

Ping...

Any Comments?

Thanks,
-Gonglei

Quoted 55 lines

-----Original Message-----
From: Gonglei (Arei)
Sent: Wednesday, January 04, 2017 6:03 PM
To: [email protected]; [email protected]
Cc: Luonengjun; [email protected]; [email protected]; [email protected]; [email protected]; Jani Kokkonen; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Huangweidong (C); [email protected]; [email protected]; Claudio Fontana; Zhoujian (jay, Euler); [email protected]; [email protected]; Wubin (H); Shiqing Fan; [email protected]; [email protected]; Gonglei (Arei)
Subject: [PATCH v15 0/2] virtio-crypto: virtio crypto device specification

Changes since v14:
- drop VIRTIO_CRYPTO_S_STARTED status [Halil & Cornelia]
- correct a sentence about dataqueue and controlq in the first paragraph.
[Halil]
- change a MAY to MUST about max_dataqueues. [Halil]
- add non-session mode support
1) add four features for different crypto services to identify wheather
support session mode.
2) extend virtio_crypto_*_para structures, for example, add the content of struct virtio_crypto_cipher_session_para into struct
virtio_crypto_cipher_para.
3) use the flag property of struct virtio_crypto_op_header to identify the type of crypto request. Aka Is it a session-based or non-session request

For pervious versions of virtio crypto spec, Pls see:

[v14]:
https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg02212.html

[v13]:
https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg07348.html

For more information, please see:
http://qemu-project.org/Features/VirtioCrypto

Please help to review, thanks.

Gonglei (2):
virtio-crypto: Add virtio crypto device specification
virtio-crypto: Add conformance clauses

 conformance.tex   |   30 ++
 content.tex       |    2 +
 virtio-crypto.tex | 1029
+++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1061 insertions(+)
 create mode 100644 virtio-crypto.tex

--
1.7.12.4