All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, H Peter Anvin <hpa@zytor.com>,
	Christopherson Sean J <sean.j.christopherson@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Radim Krcmar <rkrcmar@redhat.com>,
	Ravi V Shankar <ravi.v.shankar@intel.com>,
	linux-kernel <linux-kernel@vger.kernel.org>, x86 <x86@kernel.org>
Subject: Re: [PATCH v2 2/2] x86/cpufeatures: Enumerate new AVX512 BFLOAT16 instructions
Date: Thu, 20 Jun 2019 12:37:20 +0200	[thread overview]
Message-ID: <20190620103720.GB28032@zn.tnic> (raw)
In-Reply-To: <20190619213404.GB234387@romley-ivt3.sc.intel.com>

On Wed, Jun 19, 2019 at 02:34:04PM -0700, Fenghua Yu wrote:
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index efb114298cfb..4910cb421b82 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -847,6 +847,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
>  		c->x86_capability[CPUID_7_0_EBX] = ebx;
>  		c->x86_capability[CPUID_7_ECX] = ecx;
>  		c->x86_capability[CPUID_7_EDX] = edx;
> +
> +		cpuid_count(0x00000007, 1, &eax, &ebx, &ecx, &edx);
> +		c->x86_capability[CPUID_7_1_EAX] = eax;
>  	}

You need to test the sub-leaf index validity here before accessing
subleaf 1:

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4910cb421b82..dad20bc891d5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -848,8 +848,11 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
 		c->x86_capability[CPUID_7_ECX] = ecx;
 		c->x86_capability[CPUID_7_EDX] = edx;
 
-		cpuid_count(0x00000007, 1, &eax, &ebx, &ecx, &edx);
-		c->x86_capability[CPUID_7_1_EAX] = eax;
+		/* Check valid sub-leaf index before accessing it */
+		if (eax >= 1) {
+			cpuid_count(0x00000007, 1, &eax, &ebx, &ecx, &edx);
+			c->x86_capability[CPUID_7_1_EAX] = eax;
+		}
 	}
 
 	/* Extended state features: level 0x0000000d */

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  reply	other threads:[~2019-06-20 10:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 18:00 [PATCH v2 0/2] x86/cpufeatures: Re-arrange a few features and enumerate AVX512 BFLOAT16 intructions Fenghua Yu
2019-06-17 18:00 ` [PATCH v2 1/2] x86/cpufeatures: Combine word 11 and 12 into new scattered features word 11 Fenghua Yu
2019-06-19 17:36   ` Borislav Petkov
2019-06-19 21:24     ` Fenghua Yu
2019-06-20 11:37   ` [tip:x86/cpu] x86/cpufeatures: Combine word 11 and 12 into a new scattered features word tip-bot for Fenghua Yu
2019-06-17 18:00 ` [PATCH v2 2/2] x86/cpufeatures: Enumerate new AVX512 BFLOAT16 instructions Fenghua Yu
2019-06-19 17:31   ` Borislav Petkov
2019-06-19 21:34     ` Fenghua Yu
2019-06-20 10:37       ` Borislav Petkov [this message]
2019-06-20 14:06         ` Fenghua Yu
2019-06-20 11:38   ` [tip:x86/cpu] x86/cpufeatures: Enumerate the " tip-bot for Fenghua Yu

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=20190620103720.GB28032@zn.tnic \
    --to=bp@alien8.de \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=rkrcmar@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --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.