From patchwork Thu Nov 3 04:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elliott, Robert (Servers)" X-Patchwork-Id: 14622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp313051wru; Wed, 2 Nov 2022 21:30:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72vhE01ZV2C55mkvu462SOp0alMDLGc01kr50WOn6r5ZFJzRORUGf+T9eh4VMFgdQRjc0R X-Received: by 2002:a17:906:7c52:b0:7ad:c9e5:3ecc with SMTP id g18-20020a1709067c5200b007adc9e53eccmr20713321ejp.73.1667449859354; Wed, 02 Nov 2022 21:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667449859; cv=none; d=google.com; s=arc-20160816; b=gxzANlGiVbp0zIFGwVbjrQXEeKqQLhXt7sC/8EMf/h1kFLRbd31hDPrcndnO38NY2Y El/EInQwI7FsnA1wWv4GKy7uWNy/VcbMhuaZwVm0RO72FoRl4AiHhE8SRh+VmwR21WrH +kAPStq2AX2q14SV3KcRVJNQkISh75mfb7uk2lkPhUEoW/Y5iz2hTrfPDYwa7q6JLTsr zm6CZUGaEJ3AksyapKaLU3XYgOgx/emCs2tWtuzTFuy5vEi4j4ZeUaaItk5tietqlK++ yr+NKCQBF0wYI57EHKxu5/gENPuMvaIxuyMsaRQf++B0WIio5Y/gA3keNWaNR6W5u3Wi TrYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6i7qkLSf27dNfAQK+C6QTFK0YUsn0GSTSCnxogIVu/I=; b=Kkoh1DEgEbl4nc1I9c9n/psv02+/kz07IV+Ht7ZEeb32dQzYxVPGyNFoukfm7VQ7/K hEx2pqACA0UBGjzAaDpoqLtBDMUq/6MwiEcInC04RgJAjVjC7deJhzjHZL374J9mmCtn W5nY4uizOc9yRqiKZw28cyBwveXGwCAurSdJ14nbJQBW4TLbSLrQRgh/qwUpwvlFWPQT wV074HID805ofsxd/zUk5FRAzZ3q9O2ts3BSu9GAl37AoppU1vxKpqRpityuQAM67GlR W/5pVUXhy9YPfGe3ZvsA0dhj/JOVAzwhm5ybXvpMixh7vge7Vx4ByBaRV9eVqDozjDf7 F3Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Cct5XUWd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho18-20020a1709070e9200b00780a240cfd7si21459988ejc.493.2022.11.02.21.30.36; Wed, 02 Nov 2022 21:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Cct5XUWd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbiKCE27 (ORCPT + 99 others); Thu, 3 Nov 2022 00:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiKCE2l (ORCPT ); Thu, 3 Nov 2022 00:28:41 -0400 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D1811A28; Wed, 2 Nov 2022 21:28:26 -0700 (PDT) Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A335icD008499; Thu, 3 Nov 2022 04:28:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=6i7qkLSf27dNfAQK+C6QTFK0YUsn0GSTSCnxogIVu/I=; b=Cct5XUWdHcVswJgk3T6pZfN6VB+icEZRaatpBT8A7lMpJnMA+kSkjHGjsFvfm8/2WPP8 JP1Kq7QvsjeH6BypBiDi5aGWyQe7Ic0m+7ej5yBrt0AMEERsNdsTMROQjkAXOIvUfu2v F3627+MhY/xkMgKuaZ4rCVmu3zn+83712QSEMvMNRPlZzTVR3S0HpXSpenrZC0Hti1q9 WFUJVgXwvLd9TUAeqSXpoMmi0+Uo4O0aK5Wl6HVGE0jXN0RnYfpreJecvmd75MVnrMfk JSmDZX/ocRL9M3Zf2DlNY8No5sUaOvB1lQPW9ubuE1k8yA5vYvSelhM6fLCwceqS0xRV ew== Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3km2pfhdfc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Nov 2022 04:28:15 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id 4A1BA295B3; Thu, 3 Nov 2022 04:28:15 +0000 (UTC) Received: from adevxp033-sys.us.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 99704808EAF; Thu, 3 Nov 2022 04:28:14 +0000 (UTC) From: Robert Elliott To: herbert@gondor.apana.org.au, davem@davemloft.net, tim.c.chen@linux.intel.com, ap420073@gmail.com, ardb@kernel.org, Jason@zx2c4.com, David.Laight@ACULAB.COM, ebiggers@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Robert Elliott Subject: [PATCH v3 08/17] crypto: x86/ghash - restructure FPU context saving Date: Wed, 2 Nov 2022 23:27:31 -0500 Message-Id: <20221103042740.6556-9-elliott@hpe.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221103042740.6556-1-elliott@hpe.com> References: <20221012215931.3896-1-elliott@hpe.com> <20221103042740.6556-1-elliott@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: z73p0svX-2GXugifPhOieRorl8zP_M1f X-Proofpoint-ORIG-GUID: z73p0svX-2GXugifPhOieRorl8zP_M1f X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-02_15,2022-11-02_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211030031 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748447903777106507?= X-GMAIL-MSGID: =?utf-8?q?1748447903777106507?= Wrap each of the calls to clmul_hash_update and clmul_ghash__mul in its own set of kernel_fpu_begin and kernel_fpu_end calls, preparing to limit the amount of data processed by each _update call to avoid RCU stalls. This is more like how polyval-clmulni_glue is structured. Fixes: 0e1227d356e9 ("crypto: ghash - Add PCLMULQDQ accelerated implementation") Suggested-by: Herbert Xu Signed-off-by: Robert Elliott --- arch/x86/crypto/ghash-clmulni-intel_glue.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c index e996627c6583..22367e363d72 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c @@ -80,7 +80,6 @@ static int ghash_update(struct shash_desc *desc, struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); u8 *dst = dctx->buffer; - kernel_fpu_begin(); if (dctx->bytes) { int n = min(srclen, dctx->bytes); u8 *pos = dst + (GHASH_BLOCK_SIZE - dctx->bytes); @@ -91,10 +90,14 @@ static int ghash_update(struct shash_desc *desc, while (n--) *pos++ ^= *src++; - if (!dctx->bytes) + if (!dctx->bytes) { + kernel_fpu_begin(); clmul_ghash_mul(dst, &ctx->shash); + kernel_fpu_end(); + } } + kernel_fpu_begin(); clmul_ghash_update(dst, src, srclen, &ctx->shash); kernel_fpu_end();