From patchwork Sat Nov 17 01:26:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10687301 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 0E45613B5 for ; Sat, 17 Nov 2018 01:32:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F03F02C428 for ; Sat, 17 Nov 2018 01:32:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E31432C494; Sat, 17 Nov 2018 01:32:10 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham 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 84A7E2C428 for ; Sat, 17 Nov 2018 01:32:10 +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:References:In-Reply-To: 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: List-Owner; bh=cGcUzQE2WE5SSmW3QZWvrRM/pj2Ps5+08M3Vm5NC6YE=; b=Aq5cV0QDonUlWf C3cCfb6LmAEZic5ka9mhkMj+ttY0fveZ7VFZ8Y9xATXjujrwlmVlC3zAPAAjJIpinJD9OZICiuGTq jvJHILBRJGxm3N06YSHFWr5vUdMuadqEFQSjL4bD7Ppfkducx4pOaKj/o9lDn5mPNorY2oWvzgEQt 1xiD89hMRX951w52gXRdgP19I1iaHSZmBkGVScJgrvA965yOabc/c5kFRaS5XldvmWOx81OLTKLWF kYhv2RD48NCrOKg3KBAqVcro3PERlkzENLOwZ7hv/Ratd18hViiwAzsAULVcK98+ogsYdQZZyCVk6 mvScZrRu0nk4D51j+AtQ==; 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 1gNpSr-0005QD-NP; Sat, 17 Nov 2018 01:32:01 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNpQD-0001hI-TE for linux-arm-kernel@bombadil.infradead.org; Sat, 17 Nov 2018 01:29:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J/Z7d1CpGMUvj7KUKIbO0LsSOiakQu6cB1TMe9HpyGk=; b=Eke4Ppod0YdK0yFV3Mol2/kURJ p7qYVdZEmX0W9nVOMNtZOHkwDmFRxFG7uTN7z+aWG4cHOIAkD+EQF++Vg3mH1oA2+6P8CA0x2NAur yY67R2OLl7K3ENNThwUlvVqm+reQQEbkIFVCUeUsRL7FwO3s0zC+natLg+up+OoSSseynz4cA/KuR KQx5YNzr8WjKaAMMsE/Yj0OA5RLDEc7bUqDeeDyXmVbGoANKEBeMQ0g1Bp/8305yZnXYVfaeheXYs te5OlqXc1Gq65ef3CgVgh2xrP2e6874kmJaP4qatYiZGQtLJ7OtueveEynpe2bMjiL8nL0bf1kb5t pC6Rmz/w==; Received: from mail.kernel.org ([198.145.29.99]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNpQA-0002SR-PQ for linux-arm-kernel@lists.infradead.org; Sat, 17 Nov 2018 01:29:16 +0000 Received: from ebiggers.mtv.corp.google.com (unknown [104.132.1.85]) (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 B52B42146D; Sat, 17 Nov 2018 01:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542418132; bh=qb6CCsHUvCgRgS2UWYdRQw19X72M+BvYRJxK3RDiYu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BvsSTVihBpY6HYcshODyIGDhkWCSuINSyrFnFl6guK5y5F4n96uLRs/KvRaDBdUBS 2n73nj5NSsMRFliCQNmKttXRrXj+4+RBRWL9CXZN7Cn4Tr8NK6KeIoQlU5u52poZq/ yOvb9yAdMpdseS9KuNL/opk/aBHBTeq+F8sbV0wg= From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Subject: [PATCH v4 06/14] crypto: arm/chacha20 - limit the preemption-disabled section Date: Fri, 16 Nov 2018 17:26:23 -0800 Message-Id: <20181117012631.23528-7-ebiggers@kernel.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog In-Reply-To: <20181117012631.23528-1-ebiggers@kernel.org> References: <20181117012631.23528-1-ebiggers@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181117_012914_997368_E8392E27 X-CRM114-Status: GOOD ( 12.65 ) 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" , Greg Kaiser , Tomer Ashur , Eric Biggers , Samuel Neves , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-fscrypt@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 From: Eric Biggers To improve responsivesess, disable preemption for each step of the walk (which is at most PAGE_SIZE) rather than for the entire encryption/decryption operation. Suggested-by: Ard Biesheuvel Signed-off-by: Eric Biggers --- arch/arm/crypto/chacha20-neon-glue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/crypto/chacha20-neon-glue.c b/arch/arm/crypto/chacha20-neon-glue.c index 7386eb1c1889..2bc035cb8f23 100644 --- a/arch/arm/crypto/chacha20-neon-glue.c +++ b/arch/arm/crypto/chacha20-neon-glue.c @@ -68,22 +68,22 @@ static int chacha20_neon(struct skcipher_request *req) if (req->cryptlen <= CHACHA_BLOCK_SIZE || !may_use_simd()) return crypto_chacha_crypt(req); - err = skcipher_walk_virt(&walk, req, true); + err = skcipher_walk_virt(&walk, req, false); crypto_chacha_init(state, ctx, walk.iv); - kernel_neon_begin(); while (walk.nbytes > 0) { unsigned int nbytes = walk.nbytes; if (nbytes < walk.total) nbytes = round_down(nbytes, walk.stride); + kernel_neon_begin(); chacha20_doneon(state, walk.dst.virt.addr, walk.src.virt.addr, nbytes); + kernel_neon_end(); err = skcipher_walk_done(&walk, walk.nbytes - nbytes); } - kernel_neon_end(); return err; }