From patchwork Mon Apr 30 16:18:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10372059 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 4DED46032A for ; Mon, 30 Apr 2018 16:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DA3128957 for ; Mon, 30 Apr 2018 16:20:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3234828B62; Mon, 30 Apr 2018 16:20:53 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 AB67E28957 for ; Mon, 30 Apr 2018 16:20:52 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=BlweSSMr48SoljFtZZt8MI4BbDWdX7fNo9zpnjVRLsA=; b=JU6uVfOC8Ip8w0RkitFpaP9Hna hrLeg1l2skAX3r6K+QKWK/A2GXQeDqUMeFfxunMHReVzGihHk0mHjyb1qm7n7ZdPKIlxiWdyPfwHL +Vns6mXQtD7lUYtjUKLcNQuMI2hCmYNltANC2HVxk9wGrnS9X5lHaG3QbNKLiffzObPRSATBTNZZW ftoNG30f6/2tkxJMnlqH2FIs8xKfpKkhOl78I1g/pqX0NFumQmYyWYnEU4AA8hHfIr/p58D5M/0Fv Um04DX1YS+o2L7ebcQzWJaasGqOUjJXusVCgnSTwUvIVSniaZltM6BxMClSH0TURm8/jhZCZXjjeH Iu6v3P9A==; 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 1fDBXg-0005Ej-7H; Mon, 30 Apr 2018 16:20:44 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDBVv-0003MJ-Dr for linux-arm-kernel@lists.infradead.org; Mon, 30 Apr 2018 16:18:57 +0000 Received: by mail-wr0-x241.google.com with SMTP id 94-v6so7262763wrf.5 for ; Mon, 30 Apr 2018 09:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/ROUsVQ72jriRGED9Y0Y0oJI4uCTW/zuVCxx/jeBvxE=; b=Qc48Urayw1AUecUkdgI+fU7zZWL4gvmYOIQrwOqMUi4QNotZX28QY82l1ImOjYMtMN K1FVw4lCLPue2cVlGGGkfU/OnkMngngqmsLrRXYZQRpvIr9ZD5umFcfjCoOyQYousOxn nJ95A5Byhh/GX7HU2WlyVe2MmVS4m36yJH3Es= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/ROUsVQ72jriRGED9Y0Y0oJI4uCTW/zuVCxx/jeBvxE=; b=iBIyqCz2uYXjEFmkvCPHuLS0PCk2YbVj0+Qdfx2rHah0iVQKm7qZBI+0TQKv41f8dA Fi6KQeaHh7kv3bUgRzmqpsrkM103zFSSbv4xbSdxdmgMFd3+M7zRZwXIl/QuIeGRKftb owKylW9iTdITmCcop3u15LJx5XA5t9NaFVWctsrQDk8OvU/Duwn7dc258KSrlkpPvq6B /GFrfpjF9I2/VfOkgIUP5whonBs6LS/yy3cU+TzNNldxR/tmS0874r1U6sVUGqVgMUv0 ZrA19+AerOXvVQFmK2qgYrdHLqUKfjFQUUSl7qyZQI0lfdUSd0bcYT3RahhYZR+QBUzS Ez/w== X-Gm-Message-State: ALQs6tA+2qF2wZaAkoJDgM+IIy2109qppkjo1WkRy42Zx4+QEYy0vnyL 95VM5yp1NegbPNi5lyWWjq0QkA== X-Google-Smtp-Source: AB8JxZqdhXJeyNIge/KuuOn4hwTdXT4YFFq1MGTC2yrvShB7BpvFeEI6eJ5ON0ekdWs2LzrBplcvwA== X-Received: by 2002:adf:db85:: with SMTP id u5-v6mr8827903wri.278.1525105123738; Mon, 30 Apr 2018 09:18:43 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id l1-v6sm5753845wre.54.2018.04.30.09.18.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 09:18:42 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Subject: [PATCH resend 01/10] crypto: arm64/sha1-ce - yield NEON after every block of input Date: Mon, 30 Apr 2018 18:18:21 +0200 Message-Id: <20180430161830.14892-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430161830.14892-1-ard.biesheuvel@linaro.org> References: <20180430161830.14892-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180430_091855_504735_C010010B X-CRM114-Status: GOOD ( 11.75 ) 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: will.deacon@arm.com, dave.martin@arm.com, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel MIME-Version: 1.0 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 Avoid excessive scheduling delays under a preemptible kernel by yielding the NEON after every block of input. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/sha1-ce-core.S | 42 ++++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/arch/arm64/crypto/sha1-ce-core.S b/arch/arm64/crypto/sha1-ce-core.S index 46049850727d..78eb35fb5056 100644 --- a/arch/arm64/crypto/sha1-ce-core.S +++ b/arch/arm64/crypto/sha1-ce-core.S @@ -69,30 +69,36 @@ * int blocks) */ ENTRY(sha1_ce_transform) + frame_push 3 + + mov x19, x0 + mov x20, x1 + mov x21, x2 + /* load round constants */ - loadrc k0.4s, 0x5a827999, w6 +0: loadrc k0.4s, 0x5a827999, w6 loadrc k1.4s, 0x6ed9eba1, w6 loadrc k2.4s, 0x8f1bbcdc, w6 loadrc k3.4s, 0xca62c1d6, w6 /* load state */ - ld1 {dgav.4s}, [x0] - ldr dgb, [x0, #16] + ld1 {dgav.4s}, [x19] + ldr dgb, [x19, #16] /* load sha1_ce_state::finalize */ ldr_l w4, sha1_ce_offsetof_finalize, x4 - ldr w4, [x0, x4] + ldr w4, [x19, x4] /* load input */ -0: ld1 {v8.4s-v11.4s}, [x1], #64 - sub w2, w2, #1 +1: ld1 {v8.4s-v11.4s}, [x20], #64 + sub w21, w21, #1 CPU_LE( rev32 v8.16b, v8.16b ) CPU_LE( rev32 v9.16b, v9.16b ) CPU_LE( rev32 v10.16b, v10.16b ) CPU_LE( rev32 v11.16b, v11.16b ) -1: add t0.4s, v8.4s, k0.4s +2: add t0.4s, v8.4s, k0.4s mov dg0v.16b, dgav.16b add_update c, ev, k0, 8, 9, 10, 11, dgb @@ -123,16 +129,25 @@ CPU_LE( rev32 v11.16b, v11.16b ) add dgbv.2s, dgbv.2s, dg1v.2s add dgav.4s, dgav.4s, dg0v.4s - cbnz w2, 0b + cbz w21, 3f + + if_will_cond_yield_neon + st1 {dgav.4s}, [x19] + str dgb, [x19, #16] + do_cond_yield_neon + b 0b + endif_yield_neon + + b 1b /* * Final block: add padding and total bit count. * Skip if the input size was not a round multiple of the block size, * the padding is handled by the C code in that case. */ - cbz x4, 3f +3: cbz x4, 4f ldr_l w4, sha1_ce_offsetof_count, x4 - ldr x4, [x0, x4] + ldr x4, [x19, x4] movi v9.2d, #0 mov x8, #0x80000000 movi v10.2d, #0 @@ -141,10 +156,11 @@ CPU_LE( rev32 v11.16b, v11.16b ) mov x4, #0 mov v11.d[0], xzr mov v11.d[1], x7 - b 1b + b 2b /* store new state */ -3: st1 {dgav.4s}, [x0] - str dgb, [x0, #16] +4: st1 {dgav.4s}, [x19] + str dgb, [x19, #16] + frame_pop ret ENDPROC(sha1_ce_transform)