Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4594897rwb; Sun, 13 Nov 2022 09:06:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4RfiZ5EIK3RB/eEHvwYrbOJRSUCAUDrIC8GmzIlfKR1OTSDBxdKgJkzWaZs4jvCakPEYQv X-Received: by 2002:a63:515c:0:b0:462:85d6:6276 with SMTP id r28-20020a63515c000000b0046285d66276mr9158324pgl.293.1668359210274; Sun, 13 Nov 2022 09:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668359210; cv=none; d=google.com; s=arc-20160816; b=hekV1tBknblBrSernBKIuBiJT8DrEPy/HDpgREsJsPSzjU531uU9mAv+mmZGCFJ1BK DE7MMV8jo7kgrE8I9+lwoh5pGvnLrAS9NGF/nfHyUI8CsAZ6zFiG0SrxbTvnLKYoLxgj 9oOTU+DHR7GGM28WKWzYr9Yd2lsIx1v7CjRJR6yeP2IlAh5+gzJhShqOW2X/YrkRJfRB DJMMbmr5YHKZRYsEzluMJoscDUis1sgTV4IvZgHI8C0jTt2czZp8F7WKaq8mp4MUPiuK x0bn5WsZSeCAjofO8gjN1FsZtQ6tUMYKa/tB6XrXSjz+jxEdNtsuLHs9ZTyfmjSiWvgp I8SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=XnNKd0lfAw9xQy1orqKXmmUAGUez2iUd5ui9HrKTj+M=; b=GULe3kCQAiViOtyTF/LPnnzXYVD3njKlY4NwuzMcQ+fh1F+i8soG0kOu0Y7r5clUL2 +R2vUALyjeNrfu847BvoTOO/aj93yNsaawKqSYT+tTjCaRe+N3Lf+SnXW2AGvT4f8ATt zF/joWeKX9jWW2c1spzjiR2pNAtSYBRGEEjYEXzrbgahqeFGknTen9tQDJqklefgIRM2 YYJgquhkIfUdaavfA0FX/h2PjWhI+0EPv6CVeCmJ2AHJmmsgdNfx5ef1Plpbk7ZAZrsP t7U5fLehefC160nwKKQ2z3/3Z0UFEm2WuuNDYb/3ZsPHz0vxkngH0Xr+8fyw/hiPgWA2 OJDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NSjMV5E0; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx12-20020a17090b4b0c00b0020ac15764f6si9096683pjb.176.2022.11.13.09.06.27; Sun, 13 Nov 2022 09:06:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=@gmail.com header.s=20210112 header.b=NSjMV5E0; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233792AbiKMQ5E (ORCPT + 99 others); Sun, 13 Nov 2022 11:57:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbiKMQ5D (ORCPT ); Sun, 13 Nov 2022 11:57:03 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8642D11C16 for ; Sun, 13 Nov 2022 08:57:02 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id v3so8352513pgh.4 for ; Sun, 13 Nov 2022 08:57:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=XnNKd0lfAw9xQy1orqKXmmUAGUez2iUd5ui9HrKTj+M=; b=NSjMV5E0VcM8kSRBB0XhwnKrDhlY+nPasdgQkh6AChyYvcz6SP+kom3zRaYk2F6H1q mdJ2QxgQugpPq9uk80yRW6AsUzrH7f8PG+qd7DWQZWMYCABr7UeF6EUvrMuv7kYcxkJN nQUi4rlSXDx6H/Ag0rKhMujtINSoD1vVq4auhf+dAqAguaOw4iYJQznTlOmFvAltX0F7 Pfqh6l7slm58nAPGWFBZEs0O2HRWKflfHPPqidu7lSn07321VicMyVskHDNEhPsXoFxd 5/EEe5LpuiBeXNKVKqsmwMilGBl1EbVl9BkHTtvdPuo6xREvFUmNBq+hZvHT61uFUGL4 Y8cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XnNKd0lfAw9xQy1orqKXmmUAGUez2iUd5ui9HrKTj+M=; b=yGWMGanofeBjAagH6oq9Pki/XAI77+PmRtn9MH8UFpQxdxwCqUjTrjMMCGwaqHFkGL Ow3kaDzETlTX0RIps4kd2yZvbZWJ0JCY/34WlVV++UU1Lp08wqDAAemANiZYRvduYeCm ailoZDytJ8CsxMGEksCwWj/imwng4FzqzzTsUvgfXWEwXsR/MhOrrwAk51CD//NldLX/ IYtjIyW93Kzu8h7GcgvC0WMj+JnMD0puw4hpe695FD1wfEdLLoRRZ6BuIjAQEIvxvLKo A2mwDKRMhUmVxDpXYDsoqDIVPS59PsOXlbkY2uKmUi/X4OJc8eStB+k/48xcAegWJYdb Ii+g== X-Gm-Message-State: ANoB5pnC2vjRt/LY36Q/C811L8azifVofyZtZaRssK88fd0WXETzZzid v1v9Bl25gKlyGXnmh/yjbn2EHLyzK6dt/w== X-Received: by 2002:a62:180f:0:b0:56b:f23a:7854 with SMTP id 15-20020a62180f000000b0056bf23a7854mr10910024pfy.66.1668358621861; Sun, 13 Nov 2022 08:57:01 -0800 (PST) Received: from localhost.localdomain ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id qi18-20020a17090b275200b001f8c532b93dsm4910477pjb.15.2022.11.13.08.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 08:57:01 -0800 (PST) From: Taehee Yoo To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, kirill.shutemov@linux.intel.com, richard@nod.at, viro@zeniv.linux.org.uk, sathyanarayanan.kuppuswamy@linux.intel.com, jpoimboe@kernel.org, elliott@hpe.com, x86@kernel.org, jussi.kivilinna@iki.fi Cc: ap420073@gmail.com Subject: [PATCH v4 1/4] crypto: aria: add keystream array into request ctx Date: Sun, 13 Nov 2022 16:56:42 +0000 Message-Id: <20221113165645.4652-2-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221113165645.4652-1-ap420073@gmail.com> References: <20221113165645.4652-1-ap420073@gmail.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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-crypto@vger.kernel.org avx accelerated aria module used local keystream array. But, keystream array size is too big. So, it puts the keystream array into request ctx. Signed-off-by: Taehee Yoo --- v4: - Add aria_avx_request ctx for keystream array v3: - No changes. v2: - Patch introduced. arch/x86/crypto/aria_aesni_avx_glue.c | 39 ++++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/arch/x86/crypto/aria_aesni_avx_glue.c b/arch/x86/crypto/aria_aesni_avx_glue.c index c561ea4fefa5..5f97e442349f 100644 --- a/arch/x86/crypto/aria_aesni_avx_glue.c +++ b/arch/x86/crypto/aria_aesni_avx_glue.c @@ -33,6 +33,10 @@ asmlinkage void aria_aesni_avx_gfni_ctr_crypt_16way(const void *ctx, u8 *dst, static struct aria_avx_ops aria_ops; +struct aria_avx_request_ctx { + u8 keystream[ARIA_AESNI_PARALLEL_BLOCK_SIZE]; +}; + static int ecb_do_encrypt(struct skcipher_request *req, const u32 *rkey) { ECB_WALK_START(req, ARIA_BLOCK_SIZE, ARIA_AESNI_PARALLEL_BLOCKS); @@ -73,6 +77,7 @@ static int aria_avx_set_key(struct crypto_skcipher *tfm, const u8 *key, static int aria_avx_ctr_encrypt(struct skcipher_request *req) { + struct aria_avx_request_ctx *req_ctx = skcipher_request_ctx(req); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); struct aria_ctx *ctx = crypto_skcipher_ctx(tfm); struct skcipher_walk walk; @@ -86,10 +91,9 @@ static int aria_avx_ctr_encrypt(struct skcipher_request *req) u8 *dst = walk.dst.virt.addr; while (nbytes >= ARIA_AESNI_PARALLEL_BLOCK_SIZE) { - u8 keystream[ARIA_AESNI_PARALLEL_BLOCK_SIZE]; - kernel_fpu_begin(); - aria_ops.aria_ctr_crypt_16way(ctx, dst, src, keystream, + aria_ops.aria_ctr_crypt_16way(ctx, dst, src, + &req_ctx->keystream[0], walk.iv); kernel_fpu_end(); dst += ARIA_AESNI_PARALLEL_BLOCK_SIZE; @@ -98,28 +102,29 @@ static int aria_avx_ctr_encrypt(struct skcipher_request *req) } while (nbytes >= ARIA_BLOCK_SIZE) { - u8 keystream[ARIA_BLOCK_SIZE]; - - memcpy(keystream, walk.iv, ARIA_BLOCK_SIZE); + memcpy(&req_ctx->keystream[0], walk.iv, ARIA_BLOCK_SIZE); crypto_inc(walk.iv, ARIA_BLOCK_SIZE); - aria_encrypt(ctx, keystream, keystream); + aria_encrypt(ctx, &req_ctx->keystream[0], + &req_ctx->keystream[0]); - crypto_xor_cpy(dst, src, keystream, ARIA_BLOCK_SIZE); + crypto_xor_cpy(dst, src, &req_ctx->keystream[0], + ARIA_BLOCK_SIZE); dst += ARIA_BLOCK_SIZE; src += ARIA_BLOCK_SIZE; nbytes -= ARIA_BLOCK_SIZE; } if (walk.nbytes == walk.total && nbytes > 0) { - u8 keystream[ARIA_BLOCK_SIZE]; - - memcpy(keystream, walk.iv, ARIA_BLOCK_SIZE); + memcpy(&req_ctx->keystream[0], walk.iv, + ARIA_BLOCK_SIZE); crypto_inc(walk.iv, ARIA_BLOCK_SIZE); - aria_encrypt(ctx, keystream, keystream); + aria_encrypt(ctx, &req_ctx->keystream[0], + &req_ctx->keystream[0]); - crypto_xor_cpy(dst, src, keystream, nbytes); + crypto_xor_cpy(dst, src, &req_ctx->keystream[0], + nbytes); dst += nbytes; src += nbytes; nbytes = 0; @@ -130,6 +135,13 @@ static int aria_avx_ctr_encrypt(struct skcipher_request *req) return err; } +static int aria_avx_init_tfm(struct crypto_skcipher *tfm) +{ + crypto_skcipher_set_reqsize(tfm, sizeof(struct aria_avx_request_ctx)); + + return 0; +} + static struct skcipher_alg aria_algs[] = { { .base.cra_name = "__ecb(aria)", @@ -160,6 +172,7 @@ static struct skcipher_alg aria_algs[] = { .setkey = aria_avx_set_key, .encrypt = aria_avx_ctr_encrypt, .decrypt = aria_avx_ctr_encrypt, + .init = aria_avx_init_tfm, } }; -- 2.17.1