From patchwork Tue Jan 16 14:21:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhoujian (jay)" X-Patchwork-Id: 10167423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE62D601E7 for ; Tue, 16 Jan 2018 15:11:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEB622817F for ; Tue, 16 Jan 2018 15:11:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D342A2842E; Tue, 16 Jan 2018 15:11:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 14BC12817F for ; Tue, 16 Jan 2018 15:11:50 +0000 (UTC) Received: from localhost ([::1]:39809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebStx-0006UZ-55 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jan 2018 10:11:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebS7Y-0006Mc-0O for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:21:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebS7U-0006vV-NH for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:21:47 -0500 Received: from [45.249.212.255] (port=55157 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebS7U-0006uU-0e for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:21:44 -0500 Received: from DGGEMM401-HUB.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id 3F06DCE61427F; Tue, 16 Jan 2018 22:21:39 +0800 (CST) Received: from DGGEMM424-HUB.china.huawei.com (10.1.198.41) by DGGEMM401-HUB.china.huawei.com (10.3.20.209) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 16 Jan 2018 22:21:40 +0800 Received: from DGGEMM505-MBS.china.huawei.com ([169.254.2.114]) by dggemm424-hub.china.huawei.com ([10.1.198.41]) with mapi id 14.03.0361.001; Tue, 16 Jan 2018 22:21:33 +0800 From: "Zhoujian (jay)" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 0/4] cryptodev: add vhost support Thread-Index: AQHTjtNwqxuBriPNGEmwLGrMjGxui6N2igKg Date: Tue, 16 Jan 2018 14:21:32 +0000 Message-ID: References: <1516111613-18988-1-git-send-email-jianjay.zhou@huawei.com> In-Reply-To: <1516111613-18988-1-git-send-email-jianjay.zhou@huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.19.14] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.255 Subject: Re: [Qemu-devel] [PATCH v3 0/4] cryptodev: add vhost support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "pasic@linux.vnet.ibm.com" , "Huangweidong \(C\)" , "mst@redhat.com" , "xin.zeng@intel.com" , "Gonglei \(Arei\)" , "roy.fan.zhang@intel.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" , longpeng Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP VHOST_USER_CREATE_CRYPTO_SESSION and VHOST_USER_CLOSE_CRYPTO_SESSION are new added messages, they should be sent only when VHOST_USER_PROTOCOL_F_CRYPTO_SESSION feature has been successfully negotiated. The differs between v2 and v3 are listed below, pls review, thanks! --- > -----Original Message----- > From: Zhoujian (jay) > Sent: Tuesday, January 16, 2018 10:07 PM > To: qemu-devel@nongnu.org > Cc: mst@redhat.com; pbonzini@redhat.com; Huangweidong (C) > ; stefanha@redhat.com; Zhoujian (jay) > ; pasic@linux.vnet.ibm.com; longpeng > ; xin.zeng@intel.com; roy.fan.zhang@intel.com; Gonglei > (Arei) > Subject: [PATCH v3 0/4] cryptodev: add vhost support > > From: Gonglei > > 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 > > 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 | 4 + > backends/cryptodev-builtin.c | 1 + > backends/cryptodev-vhost-user.c | 381 > ++++++++++++++++++++++++++++++++++ > backends/cryptodev-vhost.c | 297 ++++++++++++++++++++++++++ > 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 | 4 + > 15 files changed, 1127 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 > diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt index f43c63d..3aec685 100644 --- a/docs/interop/vhost-user.txt +++ b/docs/interop/vhost-user.txt @@ -327,6 +327,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 -------------------- @@ -605,6 +606,9 @@ Master message types 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 @@ -614,6 +618,9 @@ Master message types 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 ------------------- diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 7865c6d..f779512 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -35,6 +35,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_NET_MTU = 4, VHOST_USER_PROTOCOL_F_SLAVE_REQ = 5, VHOST_USER_PROTOCOL_F_CROSS_ENDIAN = 6, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION = 7, VHOST_USER_PROTOCOL_F_MAX }; @@ -941,6 +942,8 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, void *session_info, uint64_t *session_id) { + bool crypto_session = virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION); CryptoDevBackendSymSessionInfo *sess_info = session_info; VhostUserMsg msg = { .request = VHOST_USER_CREATE_CRYPTO_SESSION, @@ -950,6 +953,11 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); + if (!crypto_session) { + error_report("vhost-user trying to send unhandled ioctl"); + return -1; + } + memcpy(&msg.payload.session.session_setup_data, sess_info, sizeof(CryptoDevBackendSymSessionInfo)); if (sess_info->key_len) { @@ -994,6 +1002,8 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, static int vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id) { + bool crypto_session = virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION); VhostUserMsg msg = { .request = VHOST_USER_CLOSE_CRYPTO_SESSION, .flags = VHOST_USER_VERSION, @@ -1001,6 +1011,11 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id) }; msg.payload.u64 = session_id; + if (!crypto_session) { + error_report("vhost-user trying to send unhandled ioctl"); + return -1; + } + if (vhost_user_write(dev, &msg, NULL, 0) < 0) { error_report("vhost_user_write() return -1, close session failed"); return -1;