From patchwork Mon Apr 30 16:18:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10372091 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 5CC5F6038F for ; Mon, 30 Apr 2018 16:25:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB9C212D5 for ; Mon, 30 Apr 2018 16:25:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4109E28AED; Mon, 30 Apr 2018 16:25:21 +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 B4FAD212D5 for ; Mon, 30 Apr 2018 16:25:20 +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=0+H9GIdWd9aHeb9RrHu5u/JvwAb6WFEHIjdmAygmxaE=; b=S0jzC8BgcBUfc2F6hXy0T/mfH8 nVGN5NNrfDr+wzLDaLr9/zkLIhn+dRa33cc3K2ga/2+FwJKhc9PbHwH9iQroCIHYCiasahAxbpt+s 63vc4Kh+EYbu3ruKopIVga23ZIGWyaMTmaROY/sp1rfsj3nbv/2jPJiLaeVWMsFvMGEJve86qOKxf wQaE7u+wpV0E52IiPJdArYex1/n+6mkqZGhjXQ0oQPmxmfqOXdWn/1ymJskGcjEYw5srI3RRAV0zU HXhRZ7QN0eatnqbiqNqQFuSIiTBlEHtxucXLApo2a5V2j1mle1HQfXbDg/t/mhgQR1395lLoeyBlK DlUq//5w==; 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 1fDBc0-0007IL-NT; Mon, 30 Apr 2018 16:25:12 +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 1fDBW6-0003OC-9i for linux-arm-kernel@lists.infradead.org; Mon, 30 Apr 2018 16:19:08 +0000 Received: by mail-wr0-x241.google.com with SMTP id o4-v6so8580761wrm.0 for ; Mon, 30 Apr 2018 09:18:58 -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=uiAXX4mnFgx+3v/OaTR5aCkx9BqrwLW+ytg1HxR66po=; b=bAKgMcVVrWVqOUgXOgoRWiKzOj7Mdpn8yzV7FLMKgTc2x87rdCNdK+lvnTPEO5rMRh YPppZeNdJD5oP7hBlnTUkF+d/65pRwDdJoslNxAeltEmShFmH8uZl+WrqxMLWGRhyJwn uI4liPNHm1y+FaNlqI1j7kIId41GHElnIDHh4= 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=uiAXX4mnFgx+3v/OaTR5aCkx9BqrwLW+ytg1HxR66po=; b=BYGQcGQQEgmAKNuo2rmdtalXw++SGF9EubgWcn0E8TxH8cFK9OhJBHkt3BFogyQsHC X42HVUlMgKB+JEw35tT1WMV8KRvUtQsNKnEST2AfEShzvDUng4gx0NYXc+1rUzeAPW+n mzsMkpRwHEBlVxfA8u+FbzN13MrwcftSCX3lE5JWn/pzBPzOhqRu2lE8tSW9I2uGiyvt LpFRFbMtJKipY76w1lPYTQyYhFjS/zrrhSxntW8uxc0lgZrFvggo/VjfyDgjyq+ep/NO xUXFnERxX1d2OUGbXrmtecoRa+gQqC2RmTamA6Byjrn2OKzprFrMeaTn80f4jT8RBoQf x9/A== X-Gm-Message-State: ALQs6tDYXCxEQeL8Wz8I4Qhw/V2Si06PRX+s8xoa2JdF32SMa27LrIoF c+dNdYXbDgzuzqD0Px8Wl3YG6g== X-Google-Smtp-Source: AB8JxZpjfwf/tYsgGnghdu/JS1EQvVyrxrcWSCSKJlCIfShH3II5JsBDFXCadp5pvxCGlqCL50ISQQ== X-Received: by 2002:adf:b352:: with SMTP id k18-v6mr8908101wrd.95.1525105136905; Mon, 30 Apr 2018 09:18:56 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 09:18:56 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Subject: [PATCH resend 07/10] crypto: arm64/crc32-ce - yield NEON after every block of input Date: Mon, 30 Apr 2018 18:18:27 +0200 Message-Id: <20180430161830.14892-8-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_091906_386536_4F2D711C X-CRM114-Status: GOOD ( 10.58 ) 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/crc32-ce-core.S | 40 +++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/arch/arm64/crypto/crc32-ce-core.S b/arch/arm64/crypto/crc32-ce-core.S index 16ed3c7ebd37..8061bf0f9c66 100644 --- a/arch/arm64/crypto/crc32-ce-core.S +++ b/arch/arm64/crypto/crc32-ce-core.S @@ -100,9 +100,10 @@ dCONSTANT .req d0 qCONSTANT .req q0 - BUF .req x0 - LEN .req x1 - CRC .req x2 + BUF .req x19 + LEN .req x20 + CRC .req x21 + CONST .req x22 vzr .req v9 @@ -123,7 +124,14 @@ ENTRY(crc32_pmull_le) ENTRY(crc32c_pmull_le) adr_l x3, .Lcrc32c_constants -0: bic LEN, LEN, #15 +0: frame_push 4, 64 + + mov BUF, x0 + mov LEN, x1 + mov CRC, x2 + mov CONST, x3 + + bic LEN, LEN, #15 ld1 {v1.16b-v4.16b}, [BUF], #0x40 movi vzr.16b, #0 fmov dCONSTANT, CRC @@ -132,7 +140,7 @@ ENTRY(crc32c_pmull_le) cmp LEN, #0x40 b.lt less_64 - ldr qCONSTANT, [x3] + ldr qCONSTANT, [CONST] loop_64: /* 64 bytes Full cache line folding */ sub LEN, LEN, #0x40 @@ -162,10 +170,21 @@ loop_64: /* 64 bytes Full cache line folding */ eor v4.16b, v4.16b, v8.16b cmp LEN, #0x40 - b.ge loop_64 + b.lt less_64 + + if_will_cond_yield_neon + stp q1, q2, [sp, #.Lframe_local_offset] + stp q3, q4, [sp, #.Lframe_local_offset + 32] + do_cond_yield_neon + ldp q1, q2, [sp, #.Lframe_local_offset] + ldp q3, q4, [sp, #.Lframe_local_offset + 32] + ldr qCONSTANT, [CONST] + movi vzr.16b, #0 + endif_yield_neon + b loop_64 less_64: /* Folding cache line into 128bit */ - ldr qCONSTANT, [x3, #16] + ldr qCONSTANT, [CONST, #16] pmull2 v5.1q, v1.2d, vCONSTANT.2d pmull v1.1q, v1.1d, vCONSTANT.1d @@ -204,8 +223,8 @@ fold_64: eor v1.16b, v1.16b, v2.16b /* final 32-bit fold */ - ldr dCONSTANT, [x3, #32] - ldr d3, [x3, #40] + ldr dCONSTANT, [CONST, #32] + ldr d3, [CONST, #40] ext v2.16b, v1.16b, vzr.16b, #4 and v1.16b, v1.16b, v3.16b @@ -213,7 +232,7 @@ fold_64: eor v1.16b, v1.16b, v2.16b /* Finish up with the bit-reversed barrett reduction 64 ==> 32 bits */ - ldr qCONSTANT, [x3, #48] + ldr qCONSTANT, [CONST, #48] and v2.16b, v1.16b, v3.16b ext v2.16b, vzr.16b, v2.16b, #8 @@ -223,6 +242,7 @@ fold_64: eor v1.16b, v1.16b, v2.16b mov w0, v1.s[1] + frame_pop ret ENDPROC(crc32_pmull_le) ENDPROC(crc32c_pmull_le)