From patchwork Wed Dec 6 19:43:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 120896 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7469021qgn; Wed, 6 Dec 2017 11:44:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMbTUwTvYKAKDHyXpxYjFZrt1bLUZnJl13bOUX5niD1CgGefhuK60UuQ6nbbNGK2dr9AZE2V X-Received: by 10.99.154.66 with SMTP id e2mr22442287pgo.8.1512589483706; Wed, 06 Dec 2017 11:44:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512589483; cv=none; d=google.com; s=arc-20160816; b=POOeG4huSs/bjzPnsQ+ESptjXa4CT8YfvX56kwt/gvWpsq+NaHncbMXvQd4OuOOSoP bGpp8CDNu+Wr/TvrN6IamN09SkgrUOjklFFVv/0gr1uf/+PnZXZtMPLvYm6y0Q7MO+sG S2afqWFMYeCofxeZ0U6rusmi8XZVqia4iRLT89z741vRRGvAnydz1PLZiMD5c7leRGNl wA3AkSwyfOt96IMiuql7Xb1SaQHWInH+T+XrJlUK7ngcSHkzWmSh4EFGfwKtmQokrbwN AYuvjXGweBUmHcfB/irnvZn11LAvEKdOKy9pHzBekWa/nx8ePnWK/4OodKzzAyCPHoRG Icrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=nfy5zys5sGPk+2nXssI9aGBPiaq2uVy9hW55bCXgA9g=; b=QRQNfzC5vRkDfNxH4SoodTDL9+h4tysyNZw//TnXn8aWWenT5MFgEU+yvlHkKKLkpS qwLDGZz8g2Jl6m7M/ZU5CKelLJBTPEy8D/InVtngCfhb02R8FmgDwBU/8ZvYHRa9I/yu Dij1DLI7kY0gxf6haFEzu0KAt5eKQ7aMuSJrQWdkAk+I3G5Gis58InV2wjWB11MgbVxA lgszDOdaafsrSSJPbszTEuH8O7sOcQpzAbIGItt/aHCAVD4ZLmpSSAWS9jZcWzhXXeeQ TtsSb8vHNm7fESdJnih59xDgQY6KItPYXzK2Q6UOVoKBoAxCaCsvFbZPNmMgw1ZPnlhF 6o5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OxEpuixC; spf=pass (google.com: best guess record for domain of linux-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-rt-users-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i16si2382524pgv.496.2017.12.06.11.44.43; Wed, 06 Dec 2017 11:44:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OxEpuixC; spf=pass (google.com: best guess record for domain of linux-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-rt-users-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbdLFTom (ORCPT + 4 others); Wed, 6 Dec 2017 14:44:42 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34532 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752132AbdLFTob (ORCPT ); Wed, 6 Dec 2017 14:44:31 -0500 Received: by mail-wr0-f196.google.com with SMTP id y21so5132801wrc.1 for ; Wed, 06 Dec 2017 11:44:30 -0800 (PST) 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=Rz5PcTd8nEXxwHJxDvYFukQ1E4CKqQgN4lX4bhAfRbM=; b=OxEpuixCWaYpY1LYPWVoryEs43gWtjVNdTEFKnnrraCYg+r8FaP/hHoLght5TJVGZQ yBEa7FSzJ99yaD8Mp/wdVJkfALB6IUwqWQ+rBV+6/G1RU9p6jrgF9JyaFLMA7bGAewpq 9Ri6FHIokNo6QLBiCK6cAZYPjtOPdtSF6beRA= 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=Rz5PcTd8nEXxwHJxDvYFukQ1E4CKqQgN4lX4bhAfRbM=; b=AroMKow332qyCvaiSvjyDoQHfvCNpKrkVCjIdSYTE6Y71s9mnhcBfhzrPoBEJeoFwO yHV1tQ7CrFxUZftEEQMD27fYIFwwuo66Jm/NOhPwzeuA3AeUfZzL+1zQ7bWQ7Xv6c+5u 9xAlGir/Ma+GFxJ0HzYuGMqgMz9mMQZtpr7Oy8g4m3d+6RRVAqjrz3+ziJQtcScjyZJL UIiCpsfmEA0/2QfZqchSk9Q3G2iZSg8acbZ84nDl6GZQxJkYsLHfneMW1xti07U+jyWf ExfTkGGuZaB00Sf/u9hTDryFG153lRhKEPOc32jjfM0FEbkYFAcIM2md4AGwn9SarOGt 4Dpw== X-Gm-Message-State: AJaThX73SwYx36G5fZuRkivFgKmtMfW68dtOBXghaa0sxNKEkFTIFY4l esDuj3w7qcvEH1M9kABorfz2tw== X-Received: by 10.223.186.197 with SMTP id w5mr19426807wrg.201.1512589470200; Wed, 06 Dec 2017 11:44:30 -0800 (PST) Received: from localhost.localdomain ([105.150.171.234]) by smtp.gmail.com with ESMTPSA id b66sm3596594wmh.32.2017.12.06.11.44.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 11:44:29 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Dave Martin , Russell King - ARM Linux , Sebastian Andrzej Siewior , Mark Rutland , linux-rt-users@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Will Deacon , Steven Rostedt , Thomas Gleixner Subject: [PATCH v3 12/20] crypto: arm64/sha1-ce - yield NEON after every block of input Date: Wed, 6 Dec 2017 19:43:38 +0000 Message-Id: <20171206194346.24393-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171206194346.24393-1-ard.biesheuvel@linaro.org> References: <20171206194346.24393-1-ard.biesheuvel@linaro.org> Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org 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(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/crypto/sha1-ce-core.S b/arch/arm64/crypto/sha1-ce-core.S index 8550408735a0..3139206e8787 100644 --- a/arch/arm64/crypto/sha1-ce-core.S +++ b/arch/arm64/crypto/sha1-ce-core.S @@ -70,31 +70,37 @@ * int blocks) */ ENTRY(sha1_ce_transform) + frame_push 3 + + mov x19, x0 + mov x20, x1 + mov x21, x2 + /* load round constants */ - adr x6, .Lsha1_rcon +0: adr x6, .Lsha1_rcon ld1r {k0.4s}, [x6], #4 ld1r {k1.4s}, [x6], #4 ld1r {k2.4s}, [x6], #4 ld1r {k3.4s}, [x6] /* 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 @@ -125,16 +131,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 @@ -143,10 +158,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 3 ret ENDPROC(sha1_ce_transform)