From patchwork Mon Apr 30 16:18:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10372053 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 CE0386032A for ; Mon, 30 Apr 2018 16:20:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC98D28B61 for ; Mon, 30 Apr 2018 16:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B18A428B64; Mon, 30 Apr 2018 16:20:00 +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 5924528B61 for ; Mon, 30 Apr 2018 16:20:00 +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=WQVTZL16DYJ5LqaFTTwwvLs+ZDgwZ4XTLF3zn+nvITc=; b=Aa/4BVS4cES+/qn0r7XfdvnZ+Q 0wcHd65AFSMQHXec/qStuTi48aOcQ9Ll7qq/i1cYx/IfF/4SAQB9vSX6D5UPq84LmsvJjnGwBtgWy neP/ZXhwa8NIRrvJyQbRobWQdNOWSQjZjrp89+jYUm5K9gadERcWCBEQQUwjX+s/QOXpTWgl/5c1C Yhz/MWaoRRgkf2G7DgBYnxdMc4dmNIBTSl3Jy4R1DygwCpYI46ycwPLIaredMfJP35ZR2iDx1/eGk l9fTmeiJ5SRS/ID8WyRrs/7qlO9fEoqXozRYD8S7KGyOj7xVZK2BRBUJ+j4AHUyrMvkiZQ7TzsZFB ML17+3Pg==; 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 1fDBWj-0003gF-4k; Mon, 30 Apr 2018 16:19:45 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDBVt-0003MM-LK for linux-arm-kernel@lists.infradead.org; Mon, 30 Apr 2018 16:18:55 +0000 Received: by mail-wr0-x244.google.com with SMTP id o15-v6so8576432wro.11 for ; Mon, 30 Apr 2018 09:18:47 -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=lcnypoy5h+AqrQvMvZmSK8KhkPa+m+lRmvG+TuuFmwE=; b=H8qZ/2Lqd0t5ycvwoJPlkb9wZ3L8uQDqV4qKM3EhblnBjJoar+FgqktZ7LKj1zOERt qDBXjJilmiIwl3SvPwHNeJDzpUR1xSymyAQY0x7Jzs2IBiU7cr/R0W4I3uOtjzfNzGT/ /GMDKjiLag1S3SuWsZvACoH1+SOmNFotePMqw= 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=lcnypoy5h+AqrQvMvZmSK8KhkPa+m+lRmvG+TuuFmwE=; b=H4MIsontpeGhqtP4Ao0cTjK0jm07NJ75lwngGat3sPew+NnDuP6bvvThFPcTpfAgaT QiHnd0/46pbqywIGNef1TnZ+wUtFCSIjXLHFArNq9xdeR/nx0oFLyQZDRyxqyUhHQEBa tgSu1As83r46IhO/K3SjDN5uTQ4uY+1PRFQFtsI1WYMfNQ/9nRSYUCp79vdkWMuPut9p EO3p158NNJs1DW83qlZP4yV05Ahiq08pJKw6nX8aybZhcquZRWL2YamkBPeLtRhyQM29 dr+wwCzkQ2TGvwKkPoRxpD1fJB3hTslqDS6oXs4zfYRrVM16LNTRzGc6nFkqaRPj9Gc7 nWGw== X-Gm-Message-State: ALQs6tBl7AP7xHl/I8fWXpbTMa9qHxWqIeWdoX/BmkHGEqGzCmn45c3l H2boGMGmCQxzl/tHB9wQ+1Xrdg== X-Google-Smtp-Source: AB8JxZrSPY3EOkAYOH9bsTRZu7O1CZiCwJBXUrX1eSlNm/8p4cJeC5UeyzYKdS/LQuD9wYE/eMbaoQ== X-Received: by 2002:adf:9a27:: with SMTP id z36-v6mr8843321wrb.47.1525105125913; Mon, 30 Apr 2018 09:18:45 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 09:18:45 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Subject: [PATCH resend 02/10] crypto: arm64/sha2-ce - yield NEON after every block of input Date: Mon, 30 Apr 2018 18:18:22 +0200 Message-Id: <20180430161830.14892-3-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_091853_713768_342EC9C3 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: 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/sha2-ce-core.S | 37 ++++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/arch/arm64/crypto/sha2-ce-core.S b/arch/arm64/crypto/sha2-ce-core.S index 4c3c89b812ce..cd8b36412469 100644 --- a/arch/arm64/crypto/sha2-ce-core.S +++ b/arch/arm64/crypto/sha2-ce-core.S @@ -79,30 +79,36 @@ */ .text ENTRY(sha2_ce_transform) + frame_push 3 + + mov x19, x0 + mov x20, x1 + mov x21, x2 + /* load round constants */ - adr_l x8, .Lsha2_rcon +0: adr_l 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 @@ -131,16 +137,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 @@ -149,9 +163,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 ret ENDPROC(sha2_ce_transform)