Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp225506imm; Wed, 18 Jul 2018 00:44:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfrpUm78UrtKqtm8M/FIFzW1GAkr93g/XrxX00ajh0DRgvDG/w39SmE5Kyt5s0Bh+t2/2Ws X-Received: by 2002:a65:65c6:: with SMTP id y6-v6mr4811436pgv.20.1531899889589; Wed, 18 Jul 2018 00:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531899889; cv=none; d=google.com; s=arc-20160816; b=F7u/sTTRqGQGcCYqjTZo0B6UeTdMW89vCMvhaJfH7NEs7GGv9Cv/0Rm4iw/1ztYbab osPVsmy0AfDwTRMPF3PDL/VeDB7Ej7EY1qChuxgViREms/fyvekEBghr/40MkDAmlevs MO6Ky48xMyDo/3PZ15tJaXQTb4KwfjuR3tekflvS8dv6N8kJ7seVKNxbUMTNLDE6qrSe nao5EEmOIgazobWdZDtQnhAFtNf3znzXWYwOK7NW/8ImxOQtQ0zcuO7HT3yklo726l83 DsMw9C0bXAsp/1ajknjszPPZr4uWX5Y3m/VEHkMm/ku5F8DptSsxRbrL37D3xo+J/wDn nsyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=4bEZWXmHBTLXOiAbdhKoHzje6brqfGatkNmzHr2FifY=; b=dbtuD5Y6Q6eyHgRoAtTq5AiR2zK1z63RrMt7KdiZmvZoOVTOR3zR6cGj1e3Yl1YLaA C4XSMzH8ccPJobua26GYrVboQqBGL+phvddGw1SHFc34TsWrGVJYmvM1P3wqE0vA5DKV JtMgtMUypY4pz3yTaGxzuLfY9LxRf+Tbs8ybR7kEveEX+IM8agMkvhDQbw/KlyqavpvT T5zn0nqM0zyPfM7uqXl9wTrBET5iBWgBfFn9Woh7Wo5P55iywPIwinFgs6aKPCz2SKSG B71inkaGVxRqvAJUMWdFYZ3nADsvS6jsVbgkt5WyK0wvqVmbI6rOjbYOvQmNVXsZ2f6t 1Abg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66-v6si2898242pfx.67.2018.07.18.00.44.34; Wed, 18 Jul 2018 00:44:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729230AbeGRITP (ORCPT + 99 others); Wed, 18 Jul 2018 04:19:15 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9644 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728912AbeGRITO (ORCPT ); Wed, 18 Jul 2018 04:19:14 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7A9A0311CEFB1; Wed, 18 Jul 2018 15:42:28 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Wed, 18 Jul 2018 15:42:19 +0800 From: Xiongfeng Wang To: , , CC: , , , , , Subject: [PATCH 0/5] crypto: add IV generation templates Date: Wed, 18 Jul 2018 15:30:50 +0800 Message-ID: <1531899055-29362-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the iv generation algorithms are implemented in dm-crypt.c. This patchset moves these algorithms from the dm layer to the kernel crypto layer by implementing them as template ciphers so they can be implemented in hardware for performance. We modify the dm layer to send a whole 'bio' rather than a sector at a time, so the dm layer needs to called into the crypto layer less times. Each bio contains an in memory representation of physically contiguous disk blocks. The dm layer sets up a chained scatterlist of these blocks split into physically contiguous segments in memory so that DMA can be performed. This patchset is based on the patchset originally started by Binoy Jayan ( crypto: Add IV generation algorithms https://patchwork.kernel.org/patch/9803469/ ) I tested the performance of software implemented ciphers before and after applying this patchset. The performance didn't change much except for slight regression when writting. The detail information is as follows. The command I used: cryptsetup -y -c aes-xts-plain -s 256 --hash sha256 luksFormat /dev/sdd1 cryptsetup -y -c aes-cbc-essiv:sha256 -s 256 --hash sha256 luksFormat /dev/sdd1 cryptsetup -y -c aes-cbc-benbi -s 256 --hash sha256 luksFormat /dev/sdd1 cryptsetup luksOpen /dev/sdd1 crypt_fun time dd if=/dev/mapper/crypt_fun of=/dev/null bs=1M count=500 iflag=direct time dd if=/dev/zero of=/dev/mapper/crypt_fun bs=1M count=500 oflag=direct Performance comparision: -------------------------------------------------------- algorithms | before applying | after applying -------------------------------------------------------- | read | write | read | write -------------------------------------------------------- aes-xts-plain | 145.34 | 145.09 | 145.89 | 144.2 -------------------------------------------------------- aes-cbc-essiv | 146.87 | 144.62 | 146.74 | 143.41 -------------------------------------------------------- aes-cbc-benbi | 146.03 | 144.74 | 146.77 | 144.46 -------------------------------------------------------- Xiongfeng Wang (5): crypto: api - introduce API to (un)register a array of templates crypto: ccm - use template array registering API to simplify the code crypto: gcm - use template array registering API to simplify the code crypto: Add IV generation templates dm-crypt: modify dm-crypt to rely on IV generation templates crypto/Kconfig | 7 + crypto/Makefile | 1 + crypto/algapi.c | 27 + crypto/ccm.c | 82 +- crypto/gcm.c | 76 +- crypto/geniv.c | 2240 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/md/Kconfig | 1 + drivers/md/dm-crypt.c | 1697 ++++++++--------------------------- include/crypto/algapi.h | 2 + include/crypto/geniv.h | 47 + 10 files changed, 2722 insertions(+), 1458 deletions(-) create mode 100644 crypto/geniv.c create mode 100644 include/crypto/geniv.h -- 1.7.12.4