Skip to contentSkip to conversation

cryptodev: add vhost support

PATCH Superseded Jay Zhou 2 participants 14 messages Jan 21, 2018 – Feb 14, 2018

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
author
#1 lore raw

PATCH v6 1/4 cryptodev: add vhost-user as a new cryptodev backend

In reply to Jay Zhou

From: Gonglei <[email protected]>

Usage:
-chardev socket,id=charcrypto0,path=/path/to/your/socket -object cryptodev-vhost-user,id=cryptodev0,chardev=charcrypto0 -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0

---
 backends/Makefile.objs           |   6 +
 backends/cryptodev-vhost-user.c  | 333 +++++++++++++++++++++++++++++++++++++++
 backends/cryptodev-vhost.c       |  89 +++++++++++
 configure                        |  15 ++
 include/sysemu/cryptodev-vhost.h | 154 ++++++++++++++++++
 qemu-options.hx                  |  21 +++
 vl.c                             |   6 +
 7 files changed, 624 insertions(+)
 create mode 100644 backends/cryptodev-vhost-user.c
 create mode 100644 backends/cryptodev-vhost.c
 create mode 100644 include/sysemu/cryptodev-vhost.h
backends/Makefile.objs +6 -0
index 0400799..a13020b 100644
@@ -8,3 +8,9 @@ common-obj-$(CONFIG_LINUX) += hostmem-file.o
 
 common-obj-y += cryptodev.o
 common-obj-y += cryptodev-builtin.o
+
+ifeq ($(CONFIG_VIRTIO),y)
+common-obj-$(CONFIG_LINUX) += cryptodev-vhost.o
+common-obj-$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) += \
+    cryptodev-vhost-user.o
+endif
backends/cryptodev-vhost-user.c new file +333 -0

333 lines not on this page · raw message

backends/cryptodev-vhost.c new file +89 -0

89 lines not on this page · raw message

configure +15 -0
index 6d8c996..4d91a5b 100755
@@ -332,6 +332,7 @@ xfs=""
 tcg="yes"
 
 vhost_net="no"
+vhost_crypto="no"
 vhost_scsi="no"
 vhost_vsock="no"
 vhost_user=""
@@ -801,6 +802,7 @@ Linux)
   linux_user="yes"
   kvm="yes"
   vhost_net="yes"
+  vhost_crypto="yes"
   vhost_scsi="yes"
   vhost_vsock="yes"
   QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
@@ -1163,6 +1165,14 @@ for opt do
   ;;
   --enable-vhost-net) vhost_net="yes"
   ;;
+  --disable-vhost-crypto) vhost_crypto="no"
+  ;;
+  --enable-vhost-crypto)
+      vhost_crypto="yes"
+      if test "$mingw32" = "yes"; then
+          error_exit "vhost-crypto isn't available on win32"
+      fi
+  ;;
   --disable-vhost-scsi) vhost_scsi="no"
   ;;
   --enable-vhost-scsi) vhost_scsi="yes"
@@ -1555,6 +1565,7 @@ disabled with --disable-FEATURE, default is enabled if available:
   cap-ng          libcap-ng support
   attr            attr and xattr support
   vhost-net       vhost-net acceleration support
+  vhost-crypto    vhost-crypto acceleration support
   spice           spice
   rbd             rados block device (rbd)
   libiscsi        iscsi support
@@ -5591,6 +5602,7 @@ echo "madvise           $madvise"
 echo "posix_madvise     $posix_madvise"
 echo "libcap-ng support $cap_ng"
 echo "vhost-net support $vhost_net"
+echo "vhost-crypto support $vhost_crypto"
 echo "vhost-scsi support $vhost_scsi"
 echo "vhost-vsock support $vhost_vsock"
 echo "vhost-user support $vhost_user"
@@ -6652,6 +6664,9 @@ if supported_kvm_target $target; then
             echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
         fi
     fi
+    if test "$vhost_crypto" = "yes" ; then
+        echo "CONFIG_VHOST_CRYPTO=y" >> $config_target_mak
+    fi
 fi
 if supported_hax_target $target; then
     echo "CONFIG_HAX=y" >> $config_target_mak
include/sysemu/cryptodev-vhost.h new file +154 -0

154 lines not on this page · raw message

qemu-options.hx +21 -0
index 5ff741a..436191d 100644
@@ -4220,6 +4220,27 @@ which specify the queue number of cryptodev backend, the default of
    [...]
 @end example
 
+@item -object cryptodev-vhost-user,id=@var{id},chardev=@var{chardevid}[,queues=@var{queues}]
+
+Creates a vhost-user cryptodev backend, backed by a chardev @var{chardevid}.
+The @var{id} parameter is a unique ID that will be used to reference this
+cryptodev backend from the @option{virtio-crypto} device.
+The chardev should be a unix domain socket backed one. The vhost-user uses
+a specifically defined protocol to pass vhost ioctl replacement messages
+to an application on the other end of the socket.
+The @var{queues} parameter is optional, which specify the queue number
+of cryptodev backend for multiqueue vhost-user, the default of @var{queues} is 1.
+
+@example
+
+ # qemu-system-x86_64 \
+   [...] \
+       -chardev socket,id=chardev0,path=/path/to/socket \
+       -object cryptodev-vhost-user,id=cryptodev0,chardev=chardev0 \
+       -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0 \
+   [...]
+@end example
+
 @item -object secret,id=@var{id},data=@var{string},format=@var{raw|base64}[,keyid=@var{secretid},iv=@var{string}]
 @item -object secret,id=@var{id},file=@var{filename},format=@var{raw|base64}[,keyid=@var{secretid},iv=@var{string}]
 
vl.c +6 -0
index e725ecb..805c788 100644
@@ -2867,6 +2867,12 @@ static bool object_create_initial(const char *type)
         return false;
     }
 
+#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
+    if (g_str_equal(type, "cryptodev-vhost-user")) {
+        return false;
+    }
+#endif
+
     /*
      * return false for concrete netfilters since
      * they depend on netdevs already existing
Signature · 1 line
1.8.3.1

Jay Zhou

author
#0 lore raw

v6 cover cryptodev: add vhost support

From: Gonglei <[email protected]>

I posted the RFC verion a few months ago for DPDK vhost-crypto implmention, and now it's time to send the formal version. Because we need an user space scheme for better performance.

The vhost user crypto server side patches had been sent to DPDK community, pls see

[RFC PATCH 0/6] lib/librte_vhost: introduce new vhost_user crypto backend support
http://dpdk.org/ml/archives/dev/2017-November/081048.html

You also can get virtio-crypto polling mode driver from:

[PATCH] virtio: add new driver for crypto devices
http://dpdk.org/ml/archives/dev/2017-November/081985.html

v5 -> v6:
Fix compile error about backends/cryptodev-vhost-user.o and rebase on the master
v4 -> v5:
squash [PATCH v4 5/5] into previous patches [Michael]
v3 -> v4:
"[PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER" newly added to fix compilation dependency [Michael]
v2 -> v3:
New added vhost user messages should be sent only when feature has been successfully negotiated [Michael]
v1 -> v2:
Fix compile error on mingw32

Gonglei (4):
cryptodev: add vhost-user as a new cryptodev backend
cryptodev: add vhost support
cryptodev-vhost-user: add crypto session handler
cryptodev-vhost-user: set the key length

 backends/Makefile.objs                |   6 +
 backends/cryptodev-builtin.c          |   1 +
 backends/cryptodev-vhost-user.c       | 379 ++++++++++++++++++++++++++++++++++
 backends/cryptodev-vhost.c            | 347 +++++++++++++++++++++++++++++++
 configure                             |  15 ++
 docs/interop/vhost-user.txt           |  26 +++
 hw/virtio/Makefile.objs               |   2 +-
 hw/virtio/vhost-user.c                | 104 ++++++++++
 hw/virtio/virtio-crypto.c             |  70 +++++++
 include/hw/virtio/vhost-backend.h     |   8 +
 include/hw/virtio/virtio-crypto.h     |   1 +
 include/sysemu/cryptodev-vhost-user.h |  47 +++++
 include/sysemu/cryptodev-vhost.h      | 154 ++++++++++++++
 include/sysemu/cryptodev.h            |   8 +
 qemu-options.hx                       |  21 ++
 vl.c                                  |   6 +
 16 files changed, 1194 insertions(+), 1 deletion(-)
 create mode 100644 backends/cryptodev-vhost-user.c
 create mode 100644 backends/cryptodev-vhost.c
 create mode 100644 include/sysemu/cryptodev-vhost-user.h
 create mode 100644 include/sysemu/cryptodev-vhost.h

--
1.8.3.1

author
#4 lore raw

PATCH v6 2/4 cryptodev: add vhost support

From: Gonglei <[email protected]>

Impliment the vhost-crypto's funtions, such as startup, stop and notification etc. Introduce an enum QCryptoCryptoDevBackendOptionsType in order to identify the cryptodev vhost backend is vhost-user or vhost-kernel-module (If exist).

At this point, the cryptdoev-vhost-user works.

---
 backends/cryptodev-builtin.c          |   1 +
 backends/cryptodev-vhost-user.c       |  16 +++
 backends/cryptodev-vhost.c            | 258 ++++++++++++++++++++++++++++++++++
 hw/virtio/Makefile.objs               |   2 +-
 hw/virtio/virtio-crypto.c             |  70 +++++++++
 include/hw/virtio/virtio-crypto.h     |   1 +
 include/sysemu/cryptodev-vhost-user.h |  44 ++++++
 include/sysemu/cryptodev.h            |   8 ++
 8 files changed, 399 insertions(+), 1 deletion(-)
 create mode 100644 include/sysemu/cryptodev-vhost-user.h
backends/cryptodev-builtin.c +1 -0
index 657c0ba..9fb0bd5 100644
@@ -78,6 +78,7 @@ static void cryptodev_builtin_init(
               "cryptodev-builtin", NULL);
     cc->info_str = g_strdup_printf("cryptodev-builtin0");
     cc->queue_index = 0;
+    cc->type = CRYPTODEV_BACKEND_TYPE_BUILTIN;
     backend->conf.peers.ccs[0] = cc;
 
     backend->conf.crypto_services =
backends/cryptodev-vhost-user.c +16 -0
index 4e63ece..0b1f049 100644
@@ -29,6 +29,7 @@
 #include "standard-headers/linux/virtio_crypto.h"
 #include "sysemu/cryptodev-vhost.h"
 #include "chardev/char-fe.h"
+#include "sysemu/cryptodev-vhost-user.h"
 
 
 /**
@@ -58,6 +59,20 @@ cryptodev_vhost_user_running(
     return crypto ? 1 : 0;
 }
 
+CryptoDevBackendVhost *
+cryptodev_vhost_user_get_vhost(
+                         CryptoDevBackendClient *cc,
+                         CryptoDevBackend *b,
+                         uint16_t queue)
+{
+    CryptoDevBackendVhostUser *s =
+                      CRYPTODEV_BACKEND_VHOST_USER(b);
+    assert(cc->type == CRYPTODEV_BACKEND_TYPE_VHOST_USER);
+    assert(queue < MAX_CRYPTO_QUEUE_NUM);
+
+    return s->vhost_crypto[queue];
+}
+
 static void cryptodev_vhost_user_stop(int queues,
                           CryptoDevBackendVhostUser *s)
 {
@@ -190,6 +205,7 @@ static void cryptodev_vhost_user_init(
         cc->info_str = g_strdup_printf("cryptodev-vhost-user%lu to %s ",
                                        i, chr->label);
         cc->queue_index = i;
+        cc->type = CRYPTODEV_BACKEND_TYPE_VHOST_USER;
 
         backend->conf.peers.ccs[i] = cc;
 
backends/cryptodev-vhost.c +258 -0

277 lines not on this page · raw message

hw/virtio/Makefile.objs +1 -1
index 765d363..c65dca2 100644
@@ -7,7 +7,7 @@ common-obj-y += virtio-mmio.o
 obj-y += virtio.o virtio-balloon.o 
 obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
-obj-y += virtio-crypto.o
+obj-$(CONFIG_LINUX) += virtio-crypto.o
 obj-$(CONFIG_VIRTIO_PCI) += virtio-crypto-pci.o
 endif
 
hw/virtio/virtio-crypto.c +70 -0

88 lines not on this page · raw message

include/hw/virtio/virtio-crypto.h +1 -0
index a00a0bf..ca3a049 100644
@@ -96,6 +96,7 @@ typedef struct VirtIOCrypto {
     int multiqueue;
     uint32_t curr_queues;
     size_t config_size;
+    uint8_t vhost_started;
 } VirtIOCrypto;
 
 #endif /* _QEMU_VIRTIO_CRYPTO_H */
include/sysemu/cryptodev-vhost-user.h new file +44 -0

44 lines not on this page · raw message

include/sysemu/cryptodev.h +8 -0
index a9d0d1e..faeb6f8 100644
@@ -163,12 +163,20 @@ typedef struct CryptoDevBackendClass {
                      uint32_t queue_index, Error **errp);
 } CryptoDevBackendClass;
 
+typedef enum CryptoDevBackendOptionsType {
+    CRYPTODEV_BACKEND_TYPE_NONE = 0,
+    CRYPTODEV_BACKEND_TYPE_BUILTIN = 1,
+    CRYPTODEV_BACKEND_TYPE_VHOST_USER = 2,
+    CRYPTODEV_BACKEND_TYPE__MAX,
+} CryptoDevBackendOptionsType;
 
 struct CryptoDevBackendClient {
+    CryptoDevBackendOptionsType type;
     char *model;
     char *name;
     char *info_str;
     unsigned int queue_index;
+    int vring_enable;
     QTAILQ_ENTRY(CryptoDevBackendClient) next;
 };
 
Signature · 1 line
1.8.3.1
author
#8 lore raw

PATCH v6 4/4 cryptodev-vhost-user: set the key length

In reply to Jay Zhou

From: Gonglei <[email protected]>

---
 backends/cryptodev-vhost-user.c       | 4 ++++
 include/sysemu/cryptodev-vhost-user.h | 3 +++
 2 files changed, 7 insertions(+)
backends/cryptodev-vhost-user.c +4 -0
index 7bd0929..11b834b 100644
@@ -226,6 +226,10 @@ static void cryptodev_vhost_user_init(
                          1u << VIRTIO_CRYPTO_SERVICE_MAC;
     backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
     backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
+
+    backend->conf.max_size = UINT64_MAX;
+    backend->conf.max_cipher_key_len = VHOST_USER_MAX_AUTH_KEY_LEN;
+    backend->conf.max_auth_key_len = VHOST_USER_MAX_AUTH_KEY_LEN;
 }
 
 static int64_t cryptodev_vhost_user_sym_create_session(
include/sysemu/cryptodev-vhost-user.h +3 -0
index 937217b..6debf53 100644
@@ -23,6 +23,9 @@
 #ifndef CRYPTODEV_VHOST_USER_H
 #define CRYPTODEV_VHOST_USER_H
 
+#define VHOST_USER_MAX_AUTH_KEY_LEN    512
+#define VHOST_USER_MAX_CIPHER_KEY_LEN  64
+
 
 /**
  * cryptodev_vhost_user_get_vhost:
Signature · 1 line
1.8.3.1
author
#7 lore raw

PATCH v6 3/4 cryptodev-vhost-user: add crypto session handler

In reply to Jay Zhou

From: Gonglei <[email protected]>

Introduce two vhost-user meassges: VHOST_USER_CREATE_CRYPTO_SESSION and VHOST_USER_CLOSE_CRYPTO_SESSION. At this point, the QEMU side support crypto operation in cryptodev host-user backend.

---
 backends/cryptodev-vhost-user.c   |  48 ++++++++++++++----
 docs/interop/vhost-user.txt       |  26 ++++++++++
 hw/virtio/vhost-user.c            | 104 ++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |   8 +++
 4 files changed, 175 insertions(+), 11 deletions(-)
backends/cryptodev-vhost-user.c +37 -11
index 0b1f049..7bd0929 100644
@@ -233,7 +233,25 @@ static int64_t cryptodev_vhost_user_sym_create_session(
            CryptoDevBackendSymSessionInfo *sess_info,
            uint32_t queue_index, Error **errp)
 {
-    return 0;
+    CryptoDevBackendClient *cc =
+                   backend->conf.peers.ccs[queue_index];
+    CryptoDevBackendVhost *vhost_crypto;
+    uint64_t session_id = 0;
+    int ret;
+
+    vhost_crypto = cryptodev_vhost_user_get_vhost(cc, backend, queue_index);
+    if (vhost_crypto) {
+        struct vhost_dev *dev = &(vhost_crypto->dev);
+        ret = dev->vhost_ops->vhost_crypto_create_session(dev,
+                                                          sess_info,
+                                                          &session_id);
+        if (ret < 0) {
+            return -1;
+        } else {
+            return session_id;
+        }
+    }
+    return -1;
 }
 
 static int cryptodev_vhost_user_sym_close_session(
@@ -241,15 +259,23 @@ static int cryptodev_vhost_user_sym_close_session(
            uint64_t session_id,
            uint32_t queue_index, Error **errp)
 {
-    return 0;
-}
-
-static int cryptodev_vhost_user_sym_operation(
-                 CryptoDevBackend *backend,
-                 CryptoDevBackendSymOpInfo *op_info,
-                 uint32_t queue_index, Error **errp)
-{
-    return VIRTIO_CRYPTO_OK;
+    CryptoDevBackendClient *cc =
+                  backend->conf.peers.ccs[queue_index];
+    CryptoDevBackendVhost *vhost_crypto;
+    int ret;
+
+    vhost_crypto = cryptodev_vhost_user_get_vhost(cc, backend, queue_index);
+    if (vhost_crypto) {
+        struct vhost_dev *dev = &(vhost_crypto->dev);
+        ret = dev->vhost_ops->vhost_crypto_close_session(dev,
+                                                         session_id);
+        if (ret < 0) {
+            return -1;
+        } else {
+            return 0;
+        }
+    }
+    return -1;
 }
 
 static void cryptodev_vhost_user_cleanup(
@@ -328,7 +354,7 @@ cryptodev_vhost_user_class_init(ObjectClass *oc, void *data)
     bc->cleanup = cryptodev_vhost_user_cleanup;
     bc->create_session = cryptodev_vhost_user_sym_create_session;
     bc->close_session = cryptodev_vhost_user_sym_close_session;
-    bc->do_sym_op = cryptodev_vhost_user_sym_operation;
+    bc->do_sym_op = NULL;
 }
 
 static const TypeInfo cryptodev_vhost_user_info = {
docs/interop/vhost-user.txt +26 -0
index 9fcf48d..cb3a759 100644
@@ -368,6 +368,7 @@ Protocol features
 #define VHOST_USER_PROTOCOL_F_MTU            4
 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ      5
 #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN   6
+#define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
 
 Master message types
 --------------------
@@ -663,6 +664,31 @@ Master message types
       field, and slaves MUST NOT accept SET_CONFIG for read-only
       configuration space fields unless the live migration bit is set.
 
+* VHOST_USER_CREATE_CRYPTO_SESSION
+
+     Id: 26
+     Equivalent ioctl: N/A
+     Master payload: crypto session description
+     Slave payload: crypto session description
+
+     Create a session for crypto operation. The server side must return the
+     session id, 0 or positive for success, negative for failure.
+     This request should be sent only when VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
+     feature has been successfully negotiated.
+     It's a required feature for crypto devices.
+
+* VHOST_USER_CLOSE_CRYPTO_SESSION
+
+     Id: 27
+     Equivalent ioctl: N/A
+     Master payload: u64
+
+     Close a session for crypto operation which was previously
+     created by VHOST_USER_CREATE_CRYPTO_SESSION.
+     This request should be sent only when VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
+     feature has been successfully negotiated.
+     It's a required feature for crypto devices.
+
 Slave message types
 -------------------
 
hw/virtio/vhost-user.c +104 -0

144 lines not on this page · raw message

include/hw/virtio/vhost-backend.h +8 -0
index 592254f..5dac61f 100644
@@ -95,6 +95,12 @@ typedef int (*vhost_set_config_op)(struct vhost_dev *dev, const uint8_t *data,
 typedef int (*vhost_get_config_op)(struct vhost_dev *dev, uint8_t *config,
                                    uint32_t config_len);
 
+typedef int (*vhost_crypto_create_session_op)(struct vhost_dev *dev,
+                                              void *session_info,
+                                              uint64_t *session_id);
+typedef int (*vhost_crypto_close_session_op)(struct vhost_dev *dev,
+                                             uint64_t session_id);
+
 typedef struct VhostOps {
     VhostBackendType backend_type;
     vhost_backend_init vhost_backend_init;
@@ -130,6 +136,8 @@ typedef struct VhostOps {
     vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg;
     vhost_get_config_op vhost_get_config;
     vhost_set_config_op vhost_set_config;
+    vhost_crypto_create_session_op vhost_crypto_create_session;
+    vhost_crypto_close_session_op vhost_crypto_close_session;
 } VhostOps;
 
 extern const VhostOps user_ops;
Signature · 1 line
1.8.3.1
#9 lore raw
In reply to Jay Zhou

Hi Michael,
I am wondering whether this version is OK for you? Any comment will be appreciated, thanks.

Regards,
Jay

Quoted 73 lines

-----Original Message-----
From: Zhoujian (jay)
Sent: Sunday, January 21, 2018 8:55 PM
To: [email protected]
Cc: [email protected]; [email protected]; Huangweidong (C) <[email protected]>; [email protected]; Zhoujian (jay) <[email protected]>; [email protected]; longpeng <[email protected]>; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; wangxin (U) <[email protected]>
Subject: [PATCH v6 0/4] cryptodev: add vhost support

From: Gonglei <[email protected]>

I posted the RFC verion a few months ago for DPDK vhost-crypto implmention, and now it's time to send the formal version. Because we need an user space scheme for better performance.

The vhost user crypto server side patches had been sent to DPDK community, pls see

[RFC PATCH 0/6] lib/librte_vhost: introduce new vhost_user crypto backend support http://dpdk.org/ml/archives/dev/2017-November/081048.html

You also can get virtio-crypto polling mode driver from:

[PATCH] virtio: add new driver for crypto devices
http://dpdk.org/ml/archives/dev/2017-November/081985.html

v5 -> v6:
Fix compile error about backends/cryptodev-vhost-user.o and rebase on the master
v4 -> v5:
squash [PATCH v4 5/5] into previous patches [Michael]
v3 -> v4:
"[PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER" newly added to fix compilation dependency [Michael]
v2 -> v3:
New added vhost user messages should be sent only when feature has been successfully negotiated [Michael]
v1 -> v2:
Fix compile error on mingw32

Gonglei (4):
cryptodev: add vhost-user as a new cryptodev backend
cryptodev: add vhost support
cryptodev-vhost-user: add crypto session handler
cryptodev-vhost-user: set the key length

 backends/Makefile.objs                |   6 +
 backends/cryptodev-builtin.c          |   1 +
 backends/cryptodev-vhost-user.c       | 379
++++++++++++++++++++++++++++++++++
 backends/cryptodev-vhost.c            | 347 +++++++++++++++++++++++++++++++
 configure                             |  15 ++
 docs/interop/vhost-user.txt           |  26 +++
 hw/virtio/Makefile.objs               |   2 +-
 hw/virtio/vhost-user.c                | 104 ++++++++++
 hw/virtio/virtio-crypto.c             |  70 +++++++
 include/hw/virtio/vhost-backend.h     |   8 +
 include/hw/virtio/virtio-crypto.h     |   1 +
 include/sysemu/cryptodev-vhost-user.h |  47 +++++
 include/sysemu/cryptodev-vhost.h      | 154 ++++++++++++++
 include/sysemu/cryptodev.h            |   8 +
 qemu-options.hx                       |  21 ++
 vl.c                                  |   6 +
 16 files changed, 1194 insertions(+), 1 deletion(-)  create mode 100644
backends/cryptodev-vhost-user.c  create mode 100644 backends/cryptodev-
vhost.c  create mode 100644 include/sysemu/cryptodev-vhost-user.h
 create mode 100644 include/sysemu/cryptodev-vhost.h

--
1.8.3.1

#10 lore raw

Yes, I plan to merge it in the next pull.
Pls don't assume anything until it's merged upstream though, some issues surface late.

Quoted 80 lines · Zhoujian (jay)

Hi Michael,
I am wondering whether this version is OK for you? Any comment will be appreciated, thanks.

Regards,
Jay

Quoted 73 lines

-----Original Message-----
From: Zhoujian (jay)
Sent: Sunday, January 21, 2018 8:55 PM
To: [email protected]
Cc: [email protected]; [email protected]; Huangweidong (C) <[email protected]>; [email protected]; Zhoujian (jay) <[email protected]>; [email protected]; longpeng <[email protected]>; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; wangxin (U) <[email protected]>
Subject: [PATCH v6 0/4] cryptodev: add vhost support

From: Gonglei <[email protected]>

I posted the RFC verion a few months ago for DPDK vhost-crypto implmention, and now it's time to send the formal version. Because we need an user space scheme for better performance.

The vhost user crypto server side patches had been sent to DPDK community, pls see

[RFC PATCH 0/6] lib/librte_vhost: introduce new vhost_user crypto backend support http://dpdk.org/ml/archives/dev/2017-November/081048.html

You also can get virtio-crypto polling mode driver from:

[PATCH] virtio: add new driver for crypto devices
http://dpdk.org/ml/archives/dev/2017-November/081985.html

v5 -> v6:
Fix compile error about backends/cryptodev-vhost-user.o and rebase on the master
v4 -> v5:
squash [PATCH v4 5/5] into previous patches [Michael]
v3 -> v4:
"[PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER" newly added to fix compilation dependency [Michael]
v2 -> v3:
New added vhost user messages should be sent only when feature has been successfully negotiated [Michael]
v1 -> v2:
Fix compile error on mingw32

Gonglei (4):
cryptodev: add vhost-user as a new cryptodev backend
cryptodev: add vhost support
cryptodev-vhost-user: add crypto session handler
cryptodev-vhost-user: set the key length

 backends/Makefile.objs                |   6 +
 backends/cryptodev-builtin.c          |   1 +
 backends/cryptodev-vhost-user.c       | 379
++++++++++++++++++++++++++++++++++
 backends/cryptodev-vhost.c            | 347 +++++++++++++++++++++++++++++++
 configure                             |  15 ++
 docs/interop/vhost-user.txt           |  26 +++
 hw/virtio/Makefile.objs               |   2 +-
 hw/virtio/vhost-user.c                | 104 ++++++++++
 hw/virtio/virtio-crypto.c             |  70 +++++++
 include/hw/virtio/vhost-backend.h     |   8 +
 include/hw/virtio/virtio-crypto.h     |   1 +
 include/sysemu/cryptodev-vhost-user.h |  47 +++++
 include/sysemu/cryptodev-vhost.h      | 154 ++++++++++++++
 include/sysemu/cryptodev.h            |   8 +
 qemu-options.hx                       |  21 ++
 vl.c                                  |   6 +
 16 files changed, 1194 insertions(+), 1 deletion(-)  create mode 100644
backends/cryptodev-vhost-user.c  create mode 100644 backends/cryptodev-
vhost.c  create mode 100644 include/sysemu/cryptodev-vhost-user.h
 create mode 100644 include/sysemu/cryptodev-vhost.h

--
1.8.3.1

author
#11 lore raw
Quoted 4 lines · Michael S. Tsirkin

Yes, I plan to merge it in the next pull.
Pls don't assume anything until it's merged upstream though, some issues surface late.

Okay, I see. Thanks for reviewing!

Regards,
Jay

Quoted 84 lines · Zhoujian (jay)
Quoted 4 lines

Hi Michael,
I am wondering whether this version is OK for you? Any comment will be appreciated, thanks.

Quoted 76 lines

Regards,
Jay

Quoted 73 lines

-----Original Message-----
From: Zhoujian (jay)
Sent: Sunday, January 21, 2018 8:55 PM
To: [email protected]
Cc: [email protected]; [email protected]; Huangweidong (C) <[email protected]>; [email protected]; Zhoujian (jay) <[email protected]>; [email protected]; longpeng <[email protected]>; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; wangxin (U) <[email protected]>
Subject: [PATCH v6 0/4] cryptodev: add vhost support

From: Gonglei <[email protected]>

I posted the RFC verion a few months ago for DPDK vhost-crypto implmention, and now it's time to send the formal version. Because we need an user space scheme for better performance.

The vhost user crypto server side patches had been sent to DPDK community, pls see

[RFC PATCH 0/6] lib/librte_vhost: introduce new vhost_user crypto backend support http://dpdk.org/ml/archives/dev/2017-November/081048.html

You also can get virtio-crypto polling mode driver from:

[PATCH] virtio: add new driver for crypto devices
http://dpdk.org/ml/archives/dev/2017-November/081985.html

v5 -> v6:
Fix compile error about backends/cryptodev-vhost-user.o and rebase on the master
v4 -> v5:
squash [PATCH v4 5/5] into previous patches [Michael]
v3 -> v4:
"[PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER" newly added to fix compilation dependency [Michael]
v2 -> v3:
New added vhost user messages should be sent only when feature has been successfully negotiated [Michael]
v1 -> v2:
Fix compile error on mingw32

Gonglei (4):
cryptodev: add vhost-user as a new cryptodev backend
cryptodev: add vhost support
cryptodev-vhost-user: add crypto session handler
cryptodev-vhost-user: set the key length

  backends/Makefile.objs                |   6 +
  backends/cryptodev-builtin.c          |   1 +
  backends/cryptodev-vhost-user.c       | 379
++++++++++++++++++++++++++++++++++
  backends/cryptodev-vhost.c            | 347 +++++++++++++++++++++++++++++++
  configure                             |  15 ++
  docs/interop/vhost-user.txt           |  26 +++
  hw/virtio/Makefile.objs               |   2 +-
  hw/virtio/vhost-user.c                | 104 ++++++++++
  hw/virtio/virtio-crypto.c             |  70 +++++++
  include/hw/virtio/vhost-backend.h     |   8 +
  include/hw/virtio/virtio-crypto.h     |   1 +
  include/sysemu/cryptodev-vhost-user.h |  47 +++++
  include/sysemu/cryptodev-vhost.h      | 154 ++++++++++++++
  include/sysemu/cryptodev.h            |   8 +
  qemu-options.hx                       |  21 ++
  vl.c                                  |   6 +
  16 files changed, 1194 insertions(+), 1 deletion(-)  create mode 100644

backends/cryptodev-vhost-user.c create mode 100644 backends/cryptodev- vhost.c create mode 100644 include/sysemu/cryptodev-vhost-user.h
create mode 100644 include/sysemu/cryptodev-vhost.h

--
1.8.3.1

.

#5 lore raw
In reply to Jay Zhou

hw/virtio/Makefile.objs common-obj-y += virtio-mmio.o · line 13

Quoted 13 lines · Jay Zhou
hw/virtio/Makefile.objs +1 -1
index 765d363..c65dca2 100644
@@ -7,7 +7,7 @@ common-obj-y += virtio-mmio.o
 obj-y += virtio.o virtio-balloon.o 
 obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
-obj-y += virtio-crypto.o
+obj-$(CONFIG_LINUX) += virtio-crypto.o
 obj-$(CONFIG_VIRTIO_PCI) += virtio-crypto-pci.o
 endif
 

This disables virtio crypto completely on non-Linux, which is not nice. We should not break working configs.

In particular this causes test failures on non-Linux hosts. Peter Maydell was kind enough to debug this and reported this backtrace:

gdb --args ./aarch64-softmmu/qemu-system-aarch64 -device virtio-crypto-pci -machine virt [...]

#0  0x00007f7ff450e6fa in _lwp_kill () from /usr/lib/libc.so.12
#1  0x00007f7ff450e385 in abort () from /usr/lib/libc.so.12
#2  0x00007f7ff5c65da2 in g_assertion_message () from /usr/pkg/lib/libglib-2.0.so.0
#3  0x00007f7ff5c65e11 in g_assertion_message_expr () from /usr/pkg/lib/libglib-2.0.so.0
#4  0x000000000074dc16 in object_initialize_with_type (data=data@entry=0x7f7ff33a2170, size=<optimized out>, type=0x0)
    at /root/qemu/qom/object.c:372
#5  0x000000000074de33 in object_initialize (data=data@entry=0x7f7ff33a2170, size=<optimized out>, typename=<optimized out>)
    at /root/qemu/qom/object.c:392
#6  0x00000000004d2293 in virtio_instance_init_common (proxy_obj=0x7f7ff339a000, data=0x7f7ff33a2170, vdev_size=<optimized out>, 
    vdev_name=<optimized out>) at /root/qemu/hw/virtio/virtio.c:2232
#7  0x000000000074db0d in object_initialize_with_type (data=data@entry=0x7f7ff339a000, size=33664, type=type@entry=0x7f7ff7b79a80)
    at /root/qemu/qom/object.c:384

#8 0x000000000074dc66 in object_new_with_type (type=0x7f7ff7b79a80) at /root/qemu/qom/object.c:492
#9 0x000000000074deb9 in object_new (typename=typename@entry=0x7f7ff7b454e0 "virtio-crypto-pci") at /root/qemu/qom/object.c:502 #10 0x00000000005924d6 in qdev_device_add (opts=0x7f7ff7b4c070, errp=errp@entry=0x7f7fffffda10) at /root/qemu/qdev-monitor.c:615 #11 0x0000000000594d31 in device_init_func (opaque=<optimized out>, opts=<optimized out>, errp=<optimized out>) at /root/qemu/vl.c:2373 #12 0x0000000000826e56 in qemu_opts_foreach (list=<optimized out>, func=func@entry=0x594d0c <device_init_func>, opaque=opaque@entry=0x0,

    errp=errp@entry=0x0) at /root/qemu/util/qemu-option.c:1073

#13 0x00000000008b723d in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at /root/qemu/vl.c:4642

He explained:

<pm215> ... this is almost certainly the classic "device A depends on device B, device B is conditionally compiled but device A isn't" <pm215> the type that is missing is virtio-crypto-device
<pm215> virtio-crypto.o is built only if CONFIG_LINUX, but virtio-crypto-pci is in virtio-crypto-pci.c which is built if CONFIG_VIRTIO_PCI

Signature · 1 line
MST
#2 lore raw

Re: [Qemu-devel] [PATCH v6 1/4] cryptodev: add vhost-user as a new cryptodev backend

In reply to Jay Zhou
Quoted 72 lines · Jay Zhou
backends/cryptodev-vhost-user.c new file +66 -0
new file mode 100644
index 0000000..4e63ece
@@ -0,0 +1,333 @@
+/*
+ * QEMU Cryptodev backend for QEMU cipher APIs
+ *
+ * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
+ *
+ * Authors:
+ *    Gonglei <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "hw/boards.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
+#include "standard-headers/linux/virtio_crypto.h"
+#include "sysemu/cryptodev-vhost.h"
+#include "chardev/char-fe.h"
+
+
+/**
+ * @TYPE_CRYPTODEV_BACKEND_VHOST_USER:
+ * name of backend that uses vhost user server
+ */
+#define TYPE_CRYPTODEV_BACKEND_VHOST_USER "cryptodev-vhost-user"
+
+#define CRYPTODEV_BACKEND_VHOST_USER(obj) \
+    OBJECT_CHECK(CryptoDevBackendVhostUser, \
+                 (obj), TYPE_CRYPTODEV_BACKEND_VHOST_USER)
+
+
+typedef struct CryptoDevBackendVhostUser {
+    CryptoDevBackend parent_obj;
+
+    CharBackend chr;
+    char *chr_name;
+    bool opened;
+    CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM];
+} CryptoDevBackendVhostUser;
+
+static int
+cryptodev_vhost_user_running(
+             CryptoDevBackendVhost *crypto)
+{
+    return crypto ? 1 : 0;
+}
+
+static void cryptodev_vhost_user_stop(int queues,
+                          CryptoDevBackendVhostUser *s)
+{
+    size_t i;
+
+    for (i = 0; i < queues; i++) {

backends/cryptodev-vhost-user.c line 76

Quoted 10 lines
backends/cryptodev-vhost-user.c new file +10 -0
+        if (!cryptodev_vhost_user_running(s->vhost_crypto[i])) {
+            continue;
+        }
+
+        if (s->vhost_crypto) {
+            cryptodev_vhost_cleanup(s->vhost_crypto[i]);
+            s->vhost_crypto[i] = NULL;
+        }
+    }
+}

This test is problematic: clang build triggers an error:

Quoted 5 lines

/home/petmay01/linaro/qemu-for-merges/backends/cryptodev-vhost-user.c:86:16:
error: address of array 's->vhost_crypto' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

        if (s->vhost_crypto) {
        ~~  ~~~^~~~~~~~~~~~

I really don't see how this could do the right thing, which makes me suspect that either you did not test stop, or you always have all queues enabled.

Pls test a config with some queues disabled.

In particular this machinery needs some unit tests to catch errors like this.

Signature · 1 line
MST
#12 lore raw
In reply to Jay Zhou
Quoted 9 lines · Jay Zhou

From: Gonglei <[email protected]>

I posted the RFC verion a few months ago for DPDK vhost-crypto implmention, and now it's time to send the formal version. Because we need an user space scheme for better performance.

The vhost user crypto server side patches had been sent to DPDK community, pls see

I dropped the patchset from the latest pull request. Please address the issues found, test stop path some more and resumit.

Thanks!

Quoted 54 lines

[RFC PATCH 0/6] lib/librte_vhost: introduce new vhost_user crypto backend support
http://dpdk.org/ml/archives/dev/2017-November/081048.html

You also can get virtio-crypto polling mode driver from:

[PATCH] virtio: add new driver for crypto devices
http://dpdk.org/ml/archives/dev/2017-November/081985.html

v5 -> v6:
Fix compile error about backends/cryptodev-vhost-user.o and rebase on the master
v4 -> v5:
squash [PATCH v4 5/5] into previous patches [Michael]
v3 -> v4:
"[PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER" newly added to fix compilation dependency [Michael]
v2 -> v3:
New added vhost user messages should be sent only when feature has been successfully negotiated [Michael]
v1 -> v2:
Fix compile error on mingw32

Gonglei (4):
cryptodev: add vhost-user as a new cryptodev backend
cryptodev: add vhost support
cryptodev-vhost-user: add crypto session handler
cryptodev-vhost-user: set the key length

 backends/Makefile.objs                |   6 +
 backends/cryptodev-builtin.c          |   1 +
 backends/cryptodev-vhost-user.c       | 379 ++++++++++++++++++++++++++++++++++
 backends/cryptodev-vhost.c            | 347 +++++++++++++++++++++++++++++++
 configure                             |  15 ++
 docs/interop/vhost-user.txt           |  26 +++
 hw/virtio/Makefile.objs               |   2 +-
 hw/virtio/vhost-user.c                | 104 ++++++++++
 hw/virtio/virtio-crypto.c             |  70 +++++++
 include/hw/virtio/vhost-backend.h     |   8 +
 include/hw/virtio/virtio-crypto.h     |   1 +
 include/sysemu/cryptodev-vhost-user.h |  47 +++++
 include/sysemu/cryptodev-vhost.h      | 154 ++++++++++++++
 include/sysemu/cryptodev.h            |   8 +
 qemu-options.hx                       |  21 ++
 vl.c                                  |   6 +
 16 files changed, 1194 insertions(+), 1 deletion(-)
 create mode 100644 backends/cryptodev-vhost-user.c
 create mode 100644 backends/cryptodev-vhost.c
 create mode 100644 include/sysemu/cryptodev-vhost-user.h
 create mode 100644 include/sysemu/cryptodev-vhost.h

--
1.8.3.1

#3 lore raw

Re: [Qemu-devel] [PATCH v6 1/4] cryptodev: add vhost-user as a new cryptodev backend

In reply to Michael S. Tsirkin
Quoted 87 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, February 14, 2018 12:46 AM
To: Zhoujian (jay) <[email protected]>
Cc: [email protected]; [email protected]; Huangweidong (C) <[email protected]>; [email protected]; [email protected]; longpeng <[email protected]>; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; wangxin (U) <[email protected]>
Subject: Re: [PATCH v6 1/4] cryptodev: add vhost-user as a new cryptodev backend

Quoted 16 lines · Jay Zhou
(quoted diff) +0 -0

b/backends/cryptodev-vhost-user.c new file mode 100644 index 0000000..4e63ece

backends/cryptodev-vhost-user.c new file +10 -0
@@ -0,0 +1,333 @@
+/*
+ * QEMU Cryptodev backend for QEMU cipher APIs
+ *
+ * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
+ *
+ * Authors:
+ *    Gonglei <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public

backends/cryptodev-vhost-user.c line 20

Quoted 10 lines
backends/cryptodev-vhost-user.c new file +10 -0
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see

<http://www.gnu.org/licenses/>.

Quoted 47 lines
backends/cryptodev-vhost-user.c new file +47 -0
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "hw/boards.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
+#include "standard-headers/linux/virtio_crypto.h"
+#include "sysemu/cryptodev-vhost.h"
+#include "chardev/char-fe.h"
+
+
+/**
+ * @TYPE_CRYPTODEV_BACKEND_VHOST_USER:
+ * name of backend that uses vhost user server  */ #define
+TYPE_CRYPTODEV_BACKEND_VHOST_USER "cryptodev-vhost-user"
+
+#define CRYPTODEV_BACKEND_VHOST_USER(obj) \
+    OBJECT_CHECK(CryptoDevBackendVhostUser, \
+                 (obj), TYPE_CRYPTODEV_BACKEND_VHOST_USER)
+
+
+typedef struct CryptoDevBackendVhostUser {
+    CryptoDevBackend parent_obj;
+
+    CharBackend chr;
+    char *chr_name;
+    bool opened;
+    CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM];
+} CryptoDevBackendVhostUser;
+
+static int
+cryptodev_vhost_user_running(
+             CryptoDevBackendVhost *crypto) {
+    return crypto ? 1 : 0;
+}
+
+static void cryptodev_vhost_user_stop(int queues,
+                          CryptoDevBackendVhostUser *s) {
+    size_t i;
+
+    for (i = 0; i < queues; i++) {
+        if (!cryptodev_vhost_user_running(s->vhost_crypto[i])) {
+            continue;
+        }
+
Quoted 13 lines

backends/cryptodev-vhost-user.c line 76

Quoted 6 lines
backends/cryptodev-vhost-user.c new file +6 -0
+        if (s->vhost_crypto) {
+            cryptodev_vhost_cleanup(s->vhost_crypto[i]);
+            s->vhost_crypto[i] = NULL;
+        }
+    }
+}

This test is problematic: clang build triggers an error:

Quoted 5 lines

/home/petmay01/linaro/qemu-for-merges/backends/cryptodev-vhost-user.c:86:16:
error: address of array 's->vhost_crypto' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

        if (s->vhost_crypto) {
        ~~  ~~~^~~~~~~~~~~~

This line should be

            if (s->vhost_crypto[i]) {
Quoted 7 lines

I really don't see how this could do the right thing, which makes me suspect that either you did not test stop, or you always have all queues enabled.

Pls test a config with some queues disabled.

In particular this machinery needs some unit tests to catch errors like this.

Okay, will do more tests, sorry about that.

Regards,
Jay

Quoted 4 lines

--
MST

#13 lore raw
In reply to Michael S. Tsirkin
Quoted 18 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, February 14, 2018 12:47 AM
To: Zhoujian (jay) <[email protected]>
Cc: [email protected]; [email protected]; Huangweidong (C) <[email protected]>; [email protected]; [email protected]; longpeng <[email protected]>; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; wangxin (U) <[email protected]>
Subject: Re: [PATCH v6 0/4] cryptodev: add vhost support

Quoted 6 lines · Jay Zhou

From: Gonglei <[email protected]>

I posted the RFC verion a few months ago for DPDK vhost-crypto implmention, and now it's time to send the formal version. Because we need an user space scheme for better performance.

Quoted 5 lines
Quoted 2 lines

The vhost user crypto server side patches had been sent to DPDK community, pls see

I dropped the patchset from the latest pull request.
Please address the issues found, test stop path some more and resumit.

Hi Michael,
Thanks for your help, I'll respin this patchset when the issues are solved.

Regards,
Jay

Quoted 60 lines

Thanks!

Quoted 30 lines

[RFC PATCH 0/6] lib/librte_vhost: introduce new vhost_user crypto backend support
http://dpdk.org/ml/archives/dev/2017-November/081048.html

You also can get virtio-crypto polling mode driver from:

[PATCH] virtio: add new driver for crypto devices
http://dpdk.org/ml/archives/dev/2017-November/081985.html

v5 -> v6:
Fix compile error about backends/cryptodev-vhost-user.o and rebase on the master
v4 -> v5:
squash [PATCH v4 5/5] into previous patches [Michael]
v3 -> v4:
"[PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER" newly added to fix compilation dependency
[Michael]
v2 -> v3:
New added vhost user messages should be sent only when feature has been successfully negotiated [Michael]
v1 -> v2:
Fix compile error on mingw32

Gonglei (4):
cryptodev: add vhost-user as a new cryptodev backend
cryptodev: add vhost support
cryptodev-vhost-user: add crypto session handler
cryptodev-vhost-user: set the key length

Quoted 3 lines
 backends/Makefile.objs                |   6 +
 backends/cryptodev-builtin.c          |   1 +
 backends/cryptodev-vhost-user.c       | 379

++++++++++++++++++++++++++++++++++

Quoted 1 line
 backends/cryptodev-vhost.c            | 347

+++++++++++++++++++++++++++++++

Quoted 21 lines
 configure                             |  15 ++
 docs/interop/vhost-user.txt           |  26 +++
 hw/virtio/Makefile.objs               |   2 +-
 hw/virtio/vhost-user.c                | 104 ++++++++++
 hw/virtio/virtio-crypto.c             |  70 +++++++
 include/hw/virtio/vhost-backend.h     |   8 +
 include/hw/virtio/virtio-crypto.h     |   1 +
 include/sysemu/cryptodev-vhost-user.h |  47 +++++
 include/sysemu/cryptodev-vhost.h      | 154 ++++++++++++++
 include/sysemu/cryptodev.h            |   8 +
 qemu-options.hx                       |  21 ++
 vl.c                                  |   6 +
 16 files changed, 1194 insertions(+), 1 deletion(-)  create mode
100644 backends/cryptodev-vhost-user.c  create mode 100644
backends/cryptodev-vhost.c  create mode 100644
include/sysemu/cryptodev-vhost-user.h
 create mode 100644 include/sysemu/cryptodev-vhost.h

--
1.8.3.1

#6 lore raw
In reply to Michael S. Tsirkin
Quoted 12 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, February 14, 2018 12:44 AM
To: Zhoujian (jay) <[email protected]>
Cc: [email protected]; [email protected]; Huangweidong (C) <[email protected]>; [email protected]; [email protected]; longpeng <[email protected]>; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; wangxin (U) <[email protected]>
Subject: Re: [PATCH v6 2/4] cryptodev: add vhost support

On Sun, Jan 21, 2018 at 08:54:48PM +0800, Jay Zhou wrote:

Quoted 14 lines
Quoted 11 lines
hw/virtio/Makefile.objs index renamed from hw/virtio/Makefile.objs +0 -0

765d363..c65dca2 100644

hw/virtio/Makefile.objs +0 -0
@@ -7,7 +7,7 @@ common-obj-y += virtio-mmio.o  obj-y += virtio.o

virtio-balloon.o
obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o -obj-y += virtio-crypto.o
+obj-$(CONFIG_LINUX) += virtio-crypto.o
obj-$(CONFIG_VIRTIO_PCI) += virtio-crypto-pci.o endif

This disables virtio crypto completely on non-Linux, which is not nice. We should not break working configs.

So If I understand correctly, the virtio crypto device should be compiled in unconditionally, which is like this:

    obj-y += virtio-crypto.o
Quoted 39 lines

In particular this causes test failures on non-Linux hosts. Peter Maydell was kind enough to debug this and reported this backtrace:

gdb --args ./aarch64-softmmu/qemu-system-aarch64 -device virtio-crypto-pci - machine virt [...]

#0  0x00007f7ff450e6fa in _lwp_kill () from /usr/lib/libc.so.12
#1  0x00007f7ff450e385 in abort () from /usr/lib/libc.so.12
#2  0x00007f7ff5c65da2 in g_assertion_message () from /usr/pkg/lib/libglib-

2.0.so.0
#3 0x00007f7ff5c65e11 in g_assertion_message_expr () from /usr/pkg/lib/libglib-2.0.so.0
#4 0x000000000074dc16 in object_initialize_with_type (data=data@entry=0x7f7ff33a2170, size=<optimized out>, type=0x0)

    at /root/qemu/qom/object.c:372
#5  0x000000000074de33 in object_initialize (data=data@entry=0x7f7ff33a2170,
size=<optimized out>, typename=<optimized out>)
    at /root/qemu/qom/object.c:392

#6 0x00000000004d2293 in virtio_instance_init_common (proxy_obj=0x7f7ff339a000, data=0x7f7ff33a2170, vdev_size=<optimized out>,
vdev_name=<optimized out>) at /root/qemu/hw/virtio/virtio.c:2232
#7 0x000000000074db0d in object_initialize_with_type (data=data@entry=0x7f7ff339a000, size=33664, type=type@entry=0x7f7ff7b79a80)

    at /root/qemu/qom/object.c:384

#8 0x000000000074dc66 in object_new_with_type (type=0x7f7ff7b79a80) at /root/qemu/qom/object.c:492
#9 0x000000000074deb9 in object_new (typename=typename@entry=0x7f7ff7b454e0 "virtio-crypto-pci") at /root/qemu/qom/object.c:502
#10 0x00000000005924d6 in qdev_device_add (opts=0x7f7ff7b4c070, errp=errp@entry=0x7f7fffffda10) at /root/qemu/qdev-monitor.c:615 #11 0x0000000000594d31 in device_init_func (opaque=<optimized out>, opts=<optimized out>, errp=<optimized out>) at /root/qemu/vl.c:2373 #12 0x0000000000826e56 in qemu_opts_foreach (list=<optimized out>, func=func@entry=0x594d0c <device_init_func>, opaque=opaque@entry=0x0,

    errp=errp@entry=0x0) at /root/qemu/util/qemu-option.c:1073

#13 0x00000000008b723d in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at /root/qemu/vl.c:4642

Quoted 8 lines

He explained:

<pm215> ... this is almost certainly the classic "device A depends on device B, device B is conditionally compiled but device A isn't" <pm215> the type that is missing is virtio-crypto-device <pm215> virtio- crypto.o is built only if CONFIG_LINUX, but virtio-crypto-pci is in virtio- crypto-pci.c which is built if CONFIG_VIRTIO_PCI

Okay, I see. Thanks for Peter's help.

Regards,
Jay

Quoted 4 lines

--
MST