From patchwork Tue Dec 4 03:52:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10711093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B757C13AF for ; Tue, 4 Dec 2018 03:56:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8ABB2A93A for ; Tue, 4 Dec 2018 03:56:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CA342A947; Tue, 4 Dec 2018 03:56:36 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BF072A915 for ; Tue, 4 Dec 2018 03:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=95f1GKQTW2AsHCf+XAlLoJ5XDqfek+yjVaWD8JTKFb8=; b=GnwBMiQhpBZmWV gKqvHU2F8C1NzJVpJH93wvcJYH6qbSUs7TN8lLjdFMSTgEMCkx6iYjUT3JPBkyCAk0eijZCfkKG3r y51MS+owHdXQ1wBrk1NLCotAE739B9QQ+Q9UVZvpBRCaus8sCsFpoWcgeYoX9eZTVMy066tifNsn6 6ei2z1a7O+8V5LTo/bB+hFUzZuoTFtf8vLOtvnP+wCTpBL+YeTYEkb8SFZrE0U6aVbbuP+tjBzdKt W5dNcYtq63C9GpmCJmkO5XVPLJ8zAVcBv2lC96KyCxOzJgPL6a8uB0e4RlHdvlzBYFR4XN7YneYrD j4MMG8g00EJqj2z8ZNmw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU1p0-0005Cx-Pk; Tue, 04 Dec 2018 03:56:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU1oo-00054o-HZ for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 03:56:20 +0000 Received: from sol.localdomain (c-24-23-142-8.hsd1.ca.comcast.net [24.23.142.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8018820850; Tue, 4 Dec 2018 03:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543895767; bh=dsZdKhxiXHRtHC8kR7xOWADk3Xigamj3ZRqAAI73dZk=; h=From:To:Cc:Subject:Date:From; b=Xy4kgkVQEGMi2I+i8RmN7tNjWW243412p3K/mEKOWEz+Y6p5yk2Ek3KYSZBjxXLRE ctuEti6sCcwgINnFBdg0/OzhbDMMkb4SOQCp4gPfsJ3VCi0lkZiMQsrCww0SckDoHO GtF6xmJ81H68m5EItEtIcODvm4TNRPmPkETh5cSs= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH v2 0/4] crypto: ARM64 NEON optimized XChaCha and NHPoly1305 (for Adiantum) Date: Mon, 3 Dec 2018 19:52:48 -0800 Message-Id: <20181204035252.14853-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_195618_607039_A9DF4415 X-CRM114-Status: GOOD ( 12.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A . Donenfeld" , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paul Crowley Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hello, This series optimizes the Adiantum encryption mode for ARM64 by adding an ARM64 NEON accelerated implementation of NHPoly1305, specifically the NH part; and by modifying the existing ARM64 NEON implementation of ChaCha20 to support XChaCha20 and XChaCha12. This greatly improves Adiantum performance on ARM64. For example, encrypting 4096-byte messages (single-threaded) on a Raspberry Pi 3 Model B v1.2, which has a Cortex-A53 processor: Before After --------- --------- adiantum(xchacha12,aes) 44.1 MB/s 82.7 MB/s adiantum(xchacha20,aes) 35.5 MB/s 65.7 MB/s Decryption is almost exactly the same speed as encryption. The biggest benefit comes from accelerating XChaCha. Accelerating NH gives a somewhat smaller, but still significant benefit. Performance on 512-byte inputs is also improved, though that is much slower in the first place. When Adiantium is used with dm-crypt (or cryptsetup), we recommend using a 4096-byte sector size. For comparison, on the same hardware AES-256-XTS encryption is only 24.5 MB/s and decryption 21.6 MB/s, both using the NEON-bitsliced implementation ("xts-aes-neonbs"). That is the fastest AES-256-XTS implementation on this processor, since it doesn't have the ARMv8 Cryptography Extensions. This is despite Adiantum also being a super- pseudorandom permutation (SPRP) over the entire sector, unlike XTS. Note that XChaCha20 and XChaCha12 can be used for other purposes too. Changed since v1: - Create full stack frame in hchacha_block_neon() and chacha_block_xor_neon(). - Use x30 instead of lr. - Fix whitespace in nh-neon-core.S. Eric Biggers (4): crypto: arm64/nhpoly1305 - add NEON-accelerated NHPoly1305 crypto: arm64/chacha20 - add XChaCha20 support crypto: arm64/chacha20 - refactor to allow varying number of rounds crypto: arm64/chacha - add XChaCha12 support arch/arm64/crypto/Kconfig | 7 +- arch/arm64/crypto/Makefile | 7 +- ...hacha20-neon-core.S => chacha-neon-core.S} | 92 +++++--- arch/arm64/crypto/chacha-neon-glue.c | 207 ++++++++++++++++++ arch/arm64/crypto/chacha20-neon-glue.c | 133 ----------- arch/arm64/crypto/nh-neon-core.S | 103 +++++++++ arch/arm64/crypto/nhpoly1305-neon-glue.c | 77 +++++++ 7 files changed, 461 insertions(+), 165 deletions(-) rename arch/arm64/crypto/{chacha20-neon-core.S => chacha-neon-core.S} (90%) create mode 100644 arch/arm64/crypto/chacha-neon-glue.c delete mode 100644 arch/arm64/crypto/chacha20-neon-glue.c create mode 100644 arch/arm64/crypto/nh-neon-core.S create mode 100644 arch/arm64/crypto/nhpoly1305-neon-glue.c