From patchwork Wed Dec 6 19:43:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 120897 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7469079qgn; Wed, 6 Dec 2017 11:44:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMbuoKOiWI/FAyUwtGf2UaeK58KHu7B2/Vpf0DlupBQXwn4D7dXvMHzJfKu3HxOuzeF+Aa9J X-Received: by 10.159.206.200 with SMTP id x8mr23334305plo.273.1512589487307; Wed, 06 Dec 2017 11:44:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512589487; cv=none; d=google.com; s=arc-20160816; b=rNbuEQNpsdg0p/8kELlUft+VeU4A47xEFI3clmVh4sB56C9NU5E4Pu03VS4SBrzvR0 ukZSnIUG9QTpnJo1e3x0fcfQQLzKXfd7Td72Ut17pDKFEozc6HZpulRrvxTAIVsTugNN 2QGKbCq/D/WI3WBiEXYQ5IvKwBKE643T68SU6ieaEmgNquerUOuA6J+LEi4l3ZOZWOle oGfVYfasQO6411f7PMoQHqW7eowzi51PuRaS/sUAgIpz4pX+yIfkV29YZdnkXZ36nQtP QUennZNz/SKFBcU44ikQFUczzIe5hG3zG/1d8ASF04gr4PpIYfBwQPlk/pTm6SWMN4ac v1aw== 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=5bs8bmz/xGK0vd/p/LPYi8SYYVEzH8WkohdDzp8Esr0=; b=OTty4fEdfzJOkrfJHOf1lHIYKUgY089AADAAOnJsX6BTyu5dz/DNC1JLz/62gJYnTB EzdLzqQAzZROPLSAySDQF+Vr0TlwlBtmB9vXs5HRVlO4/Xg9+UDoNEM1gYr6MRK4UcyY AzWF0/KHvMuGGgXCm5CDFd3LkXZv+S1e47Bll/eAuJfuSxU7UVgZrR0tYaf0R3Kp/4ex K4Go4sjRUPlZCXouq/UJU/9W9ecphJoDNDMJsXJ4a+xVdUXmwwK537t8eC6UzJ4X1VgL knN8xyD25mcm4k69E9P6dGeUmRJaHgwKT474+qs/zcPXG7Uun7qtXRZ9E3ul8kNv1IkB ptxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ro2PH8dR; 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.47; Wed, 06 Dec 2017 11:44:47 -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=Ro2PH8dR; 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 S1751208AbdLFTop (ORCPT + 4 others); Wed, 6 Dec 2017 14:44:45 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:43048 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752362AbdLFToe (ORCPT ); Wed, 6 Dec 2017 14:44:34 -0500 Received: by mail-wm0-f65.google.com with SMTP id n138so9219048wmg.2 for ; Wed, 06 Dec 2017 11:44:34 -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=lA1WyRfGamNxDChcuAimYdrPatx8IosIFMhWUn71St8=; b=Ro2PH8dRZJ0y+ZQp+UYPvExjl2FvuKovCaX74xBJeqGaNQD8CGA35Wl6LpwXn212tg f4TMJHGi+bYyfEw5hXnsQReHH814blH7o4FHX7u0YBeBp3o4qKYwCKYFwF6qC24SSKfj /VtWh6D9LyEEKLZiACg6DL876IHPBdN2YEVoY= 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=lA1WyRfGamNxDChcuAimYdrPatx8IosIFMhWUn71St8=; b=T0xXXkwvLLxy+LzJRIGgO7CQLbOdUkq02chbxBjGCULZT7DGi5eU+QUaiQ3GoKn73b +v0c1nlIgcmNZgd2LRtj6rVQ+bw2nNUouwMiru+iKTghmaz3fPC1vk6z0edLSmeCvPsN +q6s3ve55fPx/kwg+A02gHOgqNyjcst46zj2pGk7MjtV9jO3HM5Smb2tqt0PeM2mMWja 2rEllcBo7iFGrHZWikNo2Kls6lK96DRa3ZTv+FfixuGqoYmEGcXb8EJTBbEtVpqrl59f n+jNKM5S0dfXmFcTeqLtorOo5oGnDqWxdgxfoYOsZy4XFpFKEmv8n2NbI1mVXmly9tyd D3Dg== X-Gm-Message-State: AKGB3mLvWwRGzKx5gZ9zJ+57W23yuJF1zndcg54djrWaDLxlJrtzQfoi sah6hVcQodUHLRDSCV8g+VmPUQ== X-Received: by 10.28.193.66 with SMTP id r63mr12262059wmf.18.1512589473602; Wed, 06 Dec 2017 11:44:33 -0800 (PST) Received: from localhost.localdomain ([105.150.171.234]) by smtp.gmail.com with ESMTPSA id b66sm3596594wmh.32.2017.12.06.11.44.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 11:44:32 -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 13/20] crypto: arm64/sha2-ce - yield NEON after every block of input Date: Wed, 6 Dec 2017 19:43:39 +0000 Message-Id: <20171206194346.24393-14-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/sha2-ce-core.S | 37 ++++++++++++++------ 1 file changed, 26 insertions(+), 11 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/sha2-ce-core.S b/arch/arm64/crypto/sha2-ce-core.S index 679c6c002f4f..7709455dae92 100644 --- a/arch/arm64/crypto/sha2-ce-core.S +++ b/arch/arm64/crypto/sha2-ce-core.S @@ -77,30 +77,36 @@ * int blocks) */ ENTRY(sha2_ce_transform) + frame_push 3 + + mov x19, x0 + mov x20, x1 + mov x21, x2 + /* load round constants */ - adr x8, .Lsha2_rcon +0: adr x8, .Lsha2_rcon ld1 { v0.4s- v3.4s}, [x8], #64 ld1 { v4.4s- v7.4s}, [x8], #64 ld1 { v8.4s-v11.4s}, [x8], #64 ld1 {v12.4s-v15.4s}, [x8] /* load state */ - ld1 {dgav.4s, dgbv.4s}, [x0] + ld1 {dgav.4s, dgbv.4s}, [x19] /* load sha256_ce_state::finalize */ ldr_l w4, sha256_ce_offsetof_finalize, x4 - ldr w4, [x0, x4] + ldr w4, [x19, x4] /* load input */ -0: ld1 {v16.4s-v19.4s}, [x1], #64 - sub w2, w2, #1 +1: ld1 {v16.4s-v19.4s}, [x20], #64 + sub w21, w21, #1 CPU_LE( rev32 v16.16b, v16.16b ) CPU_LE( rev32 v17.16b, v17.16b ) CPU_LE( rev32 v18.16b, v18.16b ) CPU_LE( rev32 v19.16b, v19.16b ) -1: add t0.4s, v16.4s, v0.4s +2: add t0.4s, v16.4s, v0.4s mov dg0v.16b, dgav.16b mov dg1v.16b, dgbv.16b @@ -129,16 +135,24 @@ CPU_LE( rev32 v19.16b, v19.16b ) add dgbv.4s, dgbv.4s, dg1v.4s /* handled all input blocks? */ - cbnz w2, 0b + cbz w21, 3f + + if_will_cond_yield_neon + st1 {dgav.4s, dgbv.4s}, [x19] + 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, sha256_ce_offsetof_count, x4 - ldr x4, [x0, x4] + ldr x4, [x19, x4] movi v17.2d, #0 mov x8, #0x80000000 movi v18.2d, #0 @@ -147,9 +161,10 @@ CPU_LE( rev32 v19.16b, v19.16b ) mov x4, #0 mov v19.d[0], xzr mov v19.d[1], x7 - b 1b + b 2b /* store new state */ -3: st1 {dgav.4s, dgbv.4s}, [x0] +4: st1 {dgav.4s, dgbv.4s}, [x19] + frame_pop 3 ret ENDPROC(sha2_ce_transform)