mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: David Woodhouse <dwmw@amazon.co.uk>
Cc: arjan@linux.intel.com, tglx@linutronix.de, karahmed@amazon.de,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	tim.c.chen@linux.intel.com, peterz@infradead.org,
	pbonzini@redhat.com, ak@linux.intel.com,
	torvalds@linux-foundation.org, gregkh@linux-foundation.org
Subject: Re: [PATCH] x86/cpuid: Fix up "virtual" IBRS/IBPB/STIBP feature bits on Intel
Date: Tue, 30 Jan 2018 11:58:14 +0100	[thread overview]
Message-ID: <20180130105814.m5zd43dyx2o2ius2@pd.tnic> (raw)
In-Reply-To: <1517269773-16750-1-git-send-email-dwmw@amazon.co.uk>

On Mon, Jan 29, 2018 at 11:49:33PM +0000, David Woodhouse wrote:
> Despite the fact that all the other code there seems to be doing it,
> just using set_cpu_cap() in early_intel_init() doesn't actually work.
> 
> When the CPU is queried again in identify_boot_cpu(), it all gets
> overwritten again. Do it in init_scattered_cpuid_features() instead.
> 
> Turning the bits off for bad microcode can use setup_clear_cpu_cap()
> to force them off for all CPUs; I was less keen on forcing the feature
> bits *on* that way.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> Fixes: 2961298e ("x86/cpufeatures: Clean up Spectre v2 related CPUID flags")
> ---
> I feel I must be missing something. Is the rest of early_init_intel() broken too?

Does that help?

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 6936d14d4c77..1dd596d0a6c4 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -182,21 +182,21 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 	 * Intel CPUs, for finer-grained selection of what's available.
 	 */
 	if (cpu_has(c, X86_FEATURE_SPEC_CTRL)) {
-		set_cpu_cap(c, X86_FEATURE_IBRS);
-		set_cpu_cap(c, X86_FEATURE_IBPB);
+		setup_force_cpu_cap(X86_FEATURE_IBRS);
+		setup_force_cpu_cap(X86_FEATURE_IBPB);
 	}
 	if (cpu_has(c, X86_FEATURE_INTEL_STIBP))
-		set_cpu_cap(c, X86_FEATURE_STIBP);
+		setup_force_cpu_cap(X86_FEATURE_STIBP);
 
 	/* Now if any of them are set, check the blacklist and clear the lot */
 	if ((cpu_has(c, X86_FEATURE_IBRS) || cpu_has(c, X86_FEATURE_IBPB) ||
 	     cpu_has(c, X86_FEATURE_STIBP)) && bad_spectre_microcode(c)) {
 		pr_warn("Intel Spectre v2 broken microcode detected; disabling Speculation Control\n");
-		clear_cpu_cap(c, X86_FEATURE_IBRS);
-		clear_cpu_cap(c, X86_FEATURE_IBPB);
-		clear_cpu_cap(c, X86_FEATURE_STIBP);
-		clear_cpu_cap(c, X86_FEATURE_SPEC_CTRL);
-		clear_cpu_cap(c, X86_FEATURE_INTEL_STIBP);
+		setup_clear_cpu_cap(X86_FEATURE_IBRS);
+		setup_clear_cpu_cap(X86_FEATURE_IBPB);
+		setup_clear_cpu_cap(X86_FEATURE_STIBP);
+		setup_clear_cpu_cap(X86_FEATURE_SPEC_CTRL);
+		setup_clear_cpu_cap(X86_FEATURE_INTEL_STIBP);
 	}
 
 	/*

-- 
Regards/Gruss,
    Boris.

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

  parent reply	other threads:[~2018-01-30 10:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 23:49 David Woodhouse
2018-01-30 10:37 ` Thomas Gleixner
2018-01-30 10:58 ` Borislav Petkov [this message]
2018-01-30 11:03   ` David Woodhouse
2018-01-30 11:18     ` Borislav Petkov
2018-01-30 11:28       ` David Woodhouse
2018-01-30 11:37         ` Thomas Gleixner
2018-01-30 12:09           ` David Woodhouse
2018-01-30 12:57             ` Thomas Gleixner
2018-01-30 13:11               ` Borislav Petkov
2018-01-30 14:01                 ` Arjan van de Ven
2018-01-30 14:54                   ` Alan Cox
2018-01-30 14:57                     ` David Woodhouse
2018-01-30 18:19                 ` Henrique de Moraes Holschuh

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=20180130105814.m5zd43dyx2o2ius2@pd.tnic \
    --to=bp@alien8.de \
    --cc=ak@linux.intel.com \
    --cc=arjan@linux.intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=gregkh@linux-foundation.org \
    --cc=karahmed@amazon.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®