All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: linux-crypto@vger.kernel.org,
	"Stéphane Glondu" <glondu@debian.org>,
	stable <stable@vger.kernel.org>,
	x86@kernel.org, "Dave Hansen" <dave@sr71.net>
Subject: Re: [PATCH] crypto x86/camellia_aesni_avx: Fix CPU feature checks
Date: Wed, 7 Oct 2015 09:25:58 +0200	[thread overview]
Message-ID: <20151007072558.GF7837@gmail.com> (raw)
In-Reply-To: <1444131093.2956.122.camel@decadent.org.uk>


* Ben Hutchings <ben@decadent.org.uk> wrote:

> We need to explicitly check the AVX and AES CPU features, as we can't
> infer them from the related XSAVE feature flags.  For example, the
> Core i3 2310M passes the XSAVE feature test but does not implement
> AES-NI.
> 
> Reported-and-tested-by: Stéphane Glondu <glondu@debian.org>
> References: https://bugs.debian.org/800934
> Fixes: ce4f5f9b65ae ("x86/fpu, crypto x86/camellia_aesni_avx: Simplify...")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> Cc: stable <stable@vger.kernel.org> # 4.2
> ---
>  arch/x86/crypto/camellia_aesni_avx_glue.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/crypto/camellia_aesni_avx_glue.c b/arch/x86/crypto/camellia_aesni_avx_glue.c
> index 80a0e43..bacaa13 100644
> --- a/arch/x86/crypto/camellia_aesni_avx_glue.c
> +++ b/arch/x86/crypto/camellia_aesni_avx_glue.c
> @@ -554,6 +554,11 @@ static int __init camellia_aesni_init(void)
>  {
>  	const char *feature_name;
>  
> +	if (!cpu_has_avx || !cpu_has_aes || !cpu_has_osxsave) {
> +		pr_info("AVX or AES-NI instructions are not detected.\n");
> +		return -ENODEV;
> +	}
> +
>  	if (!cpu_has_xfeatures(XSTATE_SSE | XSTATE_YMM, &feature_name)) {
>  		pr_info("CPU feature '%s' is not supported.\n", feature_name);
>  		return -ENODEV;

Good catch!

Do we still need the cpu_has_xfeatures() check after the cpuid based check?

Thanks,

	Ingo

WARNING: multiple messages have this Message-ID (diff)
From: Ingo Molnar <mingo@kernel.org>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: linux-crypto@vger.kernel.org,
	"Stéphane Glondu" <glondu@debian.org>,
	stable <stable@vger.kernel.org>,
	x86@kernel.org, "Dave Hansen" <dave@sr71.net>
Subject: Re: [PATCH] crypto x86/camellia_aesni_avx: Fix CPU feature checks
Date: Wed, 7 Oct 2015 09:25:58 +0200	[thread overview]
Message-ID: <20151007072558.GF7837@gmail.com> (raw)
In-Reply-To: <1444131093.2956.122.camel@decadent.org.uk>


* Ben Hutchings <ben@decadent.org.uk> wrote:

> We need to explicitly check the AVX and AES CPU features, as we can't
> infer them from the related XSAVE feature flags.  For example, the
> Core i3 2310M passes the XSAVE feature test but does not implement
> AES-NI.
> 
> Reported-and-tested-by: St�phane Glondu <glondu@debian.org>
> References: https://bugs.debian.org/800934
> Fixes: ce4f5f9b65ae ("x86/fpu, crypto x86/camellia_aesni_avx: Simplify...")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> Cc: stable <stable@vger.kernel.org> # 4.2
> ---
>  arch/x86/crypto/camellia_aesni_avx_glue.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/crypto/camellia_aesni_avx_glue.c b/arch/x86/crypto/camellia_aesni_avx_glue.c
> index 80a0e43..bacaa13 100644
> --- a/arch/x86/crypto/camellia_aesni_avx_glue.c
> +++ b/arch/x86/crypto/camellia_aesni_avx_glue.c
> @@ -554,6 +554,11 @@ static int __init camellia_aesni_init(void)
>  {
>  	const char *feature_name;
>  
> +	if (!cpu_has_avx || !cpu_has_aes || !cpu_has_osxsave) {
> +		pr_info("AVX or AES-NI instructions are not detected.\n");
> +		return -ENODEV;
> +	}
> +
>  	if (!cpu_has_xfeatures(XSTATE_SSE | XSTATE_YMM, &feature_name)) {
>  		pr_info("CPU feature '%s' is not supported.\n", feature_name);
>  		return -ENODEV;

Good catch!

Do we still need the cpu_has_xfeatures() check after the cpuid based check?

Thanks,

	Ingo

  reply	other threads:[~2015-10-07  7:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 11:31 [PATCH] crypto x86/camellia_aesni_avx: Fix CPU feature checks Ben Hutchings
2015-10-07  7:25 ` Ingo Molnar [this message]
2015-10-07  7:25   ` Ingo Molnar
2015-10-07 14:02   ` Dave Hansen

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=20151007072558.GF7837@gmail.com \
    --to=mingo@kernel.org \
    --cc=ben@decadent.org.uk \
    --cc=dave@sr71.net \
    --cc=glondu@debian.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.