linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Nathan Huckleberry <nhuck@google.com>
Cc: linux-crypto@vger.kernel.org, linux-fscrypt@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	linux-arm-kernel@lists.infradead.org,
	Paul Crowley <paulcrowley@google.com>,
	Sami Tolvanen <samitolvanen@google.com>,
	Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH v6 7/9] crypto: x86/polyval: Add PCLMULQDQ accelerated implementation of POLYVAL
Date: Wed, 4 May 2022 22:08:37 -0700	[thread overview]
Message-ID: <YnNb1Quo3CAGQmHA@sol.localdomain> (raw)
In-Reply-To: <20220504001823.2483834-8-nhuck@google.com>

On Wed, May 04, 2022 at 12:18:21AM +0000, Nathan Huckleberry wrote:
> +.macro schoolbook1_iteration i xor_sum
> +	movups (16*\i)(MSG), %xmm0
> +	.if (\i == 0 && \xor_sum == 1)
> +		pxor SUM, %xmm0
> +	.endif
> +        vpclmulqdq $0x01, (16*\i)(KEY_POWERS), %xmm0, %xmm2
> +        vpclmulqdq $0x00, (16*\i)(KEY_POWERS), %xmm0, %xmm1
> +        vpclmulqdq $0x10, (16*\i)(KEY_POWERS), %xmm0, %xmm3
> +        vpclmulqdq $0x11, (16*\i)(KEY_POWERS), %xmm0, %xmm4
> +        vpxor %xmm2, MI, MI
> +        vpxor %xmm1, LO, LO
> +        vpxor %xmm4, HI, HI
> +        vpxor %xmm3, MI, MI
> +.endm

The 8 lines above are indented with spaces.  They should use tabs, like
everywhere else.

> + * So our final computation is: T = T_1 : T_0 = g*(x) * P_0 V = V_1 : V_0 =
> + * g*(x) * (P_1 + T_0) p(x) / x^{128} mod g(x) = P_3 + P_1 + T_0 + V_1 : P_2 +
> + * P_0 + T_1 + V_0

This part is unreadable now -- it looks like you formatted it as regular text?
The three equations should be on their own lines, like how it was before.

> +__maybe_unused static const struct x86_cpu_id pcmul_cpu_id[] = {
> +	X86_MATCH_FEATURE(X86_FEATURE_PCLMULQDQ, NULL),
> +	X86_MATCH_FEATURE(X86_FEATURE_AVX, NULL),
> +	{}
> +};
> +MODULE_DEVICE_TABLE(x86cpu, pcmul_cpu_id);
> +
> +static int __init polyval_clmulni_mod_init(void)
> +{
> +	if (!x86_match_cpu(pcmul_cpu_id))
> +		return -ENODEV;
> +
> +	return crypto_register_shash(&polyval_alg);
> +}
> +
> +static void __exit polyval_clmulni_mod_exit(void)
> +{
> +	crypto_unregister_shash(&polyval_alg);
> +}

This won't work as intended; it's registering the algorithm (and autoloading the
module) if PCLMUL *or* AVX is available, rather than PCLMUL *and* AVX.

I think the way to go is to just have X86_FEATURE_PCLMULQDQ in the table, like
before, and add a check for boot_cpu_has(X86_FEATURE_AVX) in the init function.

- Eric

  reply	other threads:[~2022-05-05  5:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  0:18 [PATCH v6 0/9] crypto: HCTR2 support Nathan Huckleberry
2022-05-04  0:18 ` [PATCH v6 1/9] crypto: xctr - Add XCTR support Nathan Huckleberry
2022-05-04  0:18 ` [PATCH v6 2/9] crypto: polyval - Add POLYVAL support Nathan Huckleberry
2022-05-04  0:18 ` [PATCH v6 3/9] crypto: hctr2 - Add HCTR2 support Nathan Huckleberry
2022-05-04  0:18 ` [PATCH v6 4/9] crypto: x86/aesni-xctr: Add accelerated implementation of XCTR Nathan Huckleberry
2022-05-05  4:45   ` Eric Biggers
2022-05-04  0:18 ` [PATCH v6 5/9] crypto: arm64/aes-xctr: " Nathan Huckleberry
2022-05-06  5:49   ` Eric Biggers
2022-05-04  0:18 ` [PATCH v6 6/9] crypto: arm64/aes-xctr: Improve readability of XCTR and CTR modes Nathan Huckleberry
2022-05-05  6:49   ` Ard Biesheuvel
2022-05-06  5:41   ` Eric Biggers
2022-05-06 21:22     ` Nathan Huckleberry
2022-05-04  0:18 ` [PATCH v6 7/9] crypto: x86/polyval: Add PCLMULQDQ accelerated implementation of POLYVAL Nathan Huckleberry
2022-05-05  5:08   ` Eric Biggers [this message]
2022-05-04  0:18 ` [PATCH v6 8/9] crypto: arm64/polyval: Add PMULL " Nathan Huckleberry
2022-05-05  5:56   ` Eric Biggers
2022-05-04  0:18 ` [PATCH v6 9/9] fscrypt: Add HCTR2 support for filename encryption Nathan Huckleberry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YnNb1Quo3CAGQmHA@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=nhuck@google.com \
    --cc=paulcrowley@google.com \
    --cc=samitolvanen@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).