From patchwork Mon Dec 4 12:26: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: 120523 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4365938qgn; Mon, 4 Dec 2017 04:27:40 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ4+MNWMyJrXqtijos4WDnFqyol4BMmTHG6qYzKoCqCQoFzIVUXvoOeUFMPoh8iZYutcTFv X-Received: by 10.101.93.66 with SMTP id e2mr13603420pgt.50.1512390460388; Mon, 04 Dec 2017 04:27:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512390460; cv=none; d=google.com; s=arc-20160816; b=hxsK2sfO1xTaVSE6cbCB3nnWHZA7p+PJ1GGYZWQJ53vEcbZfsy77fBc+gvOy4mi/2d s/98nRXAq5Hvsx/ka+z+x6OL+NpVoLeR2/+fr9Qno9ptlln6p1EV/l6faPaAQVO0IIaD lk40gR8yEkSeCov9IRJM9Y5bqH29CFnp6+xcrbcIJnVq/SbnCdBYAfc3sp9bGl/9ojVI ILSaLqohaMtG7Bs6E/pjFrxUy3BvZ9K/fb1bd61LACxRvgD0GO9gOwVJhVnZBVjxTMIV +N+GUQ3HXe8a0ORix69SVn09PiyYI1aOipmOTakkF5fspbYbKsrV4DO7TuqC0YyFokoR S1tw== 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=xSFgGyz/QA6McsrvLRYgl+6glDDyuMVCrp5yatFBP+4=; b=U25FClDk7S18dJ/VwqTIZsVt/rYFpzyQG3CeCK4ruf9fX5+hyY8KVvlUY5KU6/EZIi TPY/Cd1iNNNKaJ5vjj7PfrDjsB9ymHbdtYjv/PJQuwBFZfuGUIJLcxsrnvUpsqA1nNPs kSq1zI/7ATUvGLaJ8yrtHE5JMIwn0fxKOosfYxvTxa7glmykm6Ojo4WkPNts1sZO0ngs YzsrOAU9IKtYioqu0lYjz98xQpWNpXnEuEqy6AyWaJUW/L8t6a7Toinze6JI3sDOjGKk lawvX3dAbYdFY/hPfqZvY/lRirwaXrG00t2e7TtkAbykZiTeY86vMhQUgXSXw67Qh5UR 0DOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cvAw/rnJ; 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 d23si10177768pfe.339.2017.12.04.04.27.40; Mon, 04 Dec 2017 04:27:40 -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=cvAw/rnJ; 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 S1753301AbdLDM1i (ORCPT + 4 others); Mon, 4 Dec 2017 07:27:38 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:42490 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753236AbdLDM1f (ORCPT ); Mon, 4 Dec 2017 07:27:35 -0500 Received: by mail-wm0-f65.google.com with SMTP id l141so5457395wmg.1 for ; Mon, 04 Dec 2017 04:27:35 -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=6yLZNW8Fw1ecLARQdV8vuI/4yHgTezAb/YpOxb5m0bc=; b=cvAw/rnJb9xnJdlhA06WUIZ//k5k5EOZNFDp1+tCsqXGYKWLDCat7XhP9iIJsTFY8T HsgyuC8z0lPExH6J0dSrBiEjE1YRtu5v3xf2XduKVvmfesIOkt2ISXHFbFPLw2J8Bzkw ACtfwD2d0URjsrTjb5UIPptk+3kfIA58q9nWk= 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=6yLZNW8Fw1ecLARQdV8vuI/4yHgTezAb/YpOxb5m0bc=; b=oKvLA0Ad9BGCCJGe4KaMzHIJMxa65bbA5iHdNzzJun2wghPgS7+IrovLM0GFR9GXQj hhi5Cl1XboUCpvVYz1I6rK03zss51y6WrWxVYrH5RjLWwjIN31iVLJa3CCGzlk8q3x6P QxYAGSnZMWi5r4pEnbiAaP3PDTtrYTKmUE9c7FG3fxIhohmpFaIFQ8cDpLyLYLDhDXW0 5Vph9O3R+Wyjso7QI+yqPX/86vp175iTwolfbND96Gs9VeZw7vsfSsCp8z3PSGOuPjIi JcF6jFEJHCfLperSYuiqL4OaBNOpECAHzPE8qb+PIfcBoiaC8xaFwFYs0y2yA5zgxZ1s I01w== X-Gm-Message-State: AJaThX79FPSsX6ZOiafZOfispCkUumHDTpXo3ys999mv/2EkvZBieJLf q3USz5m+R0UmuJvlS7YELH4StQ== X-Received: by 10.28.131.73 with SMTP id f70mr7440276wmd.153.1512390454504; Mon, 04 Dec 2017 04:27:34 -0800 (PST) Received: from localhost.localdomain ([105.150.171.234]) by smtp.gmail.com with ESMTPSA id a8sm7665839wmh.41.2017.12.04.04.27.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 04:27:33 -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 v2 13/19] crypto: arm64/sha2-ce - yield every 8 blocks of input Date: Mon, 4 Dec 2017 12:26:39 +0000 Message-Id: <20171204122645.31535-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171204122645.31535-1-ard.biesheuvel@linaro.org> References: <20171204122645.31535-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 every 8 blocks of input. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/sha2-ce-core.S | 40 ++++++++++++++------ 1 file changed, 29 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..d156b3ae967c 100644 --- a/arch/arm64/crypto/sha2-ce-core.S +++ b/arch/arm64/crypto/sha2-ce-core.S @@ -77,30 +77,39 @@ * int blocks) */ ENTRY(sha2_ce_transform) + stp x29, x30, [sp, #-48]! + mov x29, sp + stp x19, x20, [sp, #16] + str x21, [sp, #32] + + 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 +138,22 @@ CPU_LE( rev32 v19.16b, v19.16b ) add dgbv.4s, dgbv.4s, dg1v.4s /* handled all input blocks? */ - cbnz w2, 0b + cbz w21, 3f + + yield_neon_pre w21, 3, 1, 1b // yield every 8 blocks + st1 {dgav.4s, dgbv.4s}, [x19] + yield_neon_post 0b + + 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 +162,12 @@ 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] + ldp x19, x20, [sp, #16] + ldr x21, [sp, #32] + ldp x29, x30, [sp], #48 ret ENDPROC(sha2_ce_transform)