All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: David Woodhouse <dwmw2@infradead.org>, x86-ml <x86@kernel.org>,
	linux-tip-commits@vger.kernel.org, hpa@zytor.com,
	gregkh@linuxfoundation.org, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, mingo@kernel.org
Subject: Re: [PATCH] x86/cpufeatures: Cleanup AMD speculation feature bits
Date: Fri, 26 Jan 2018 22:52:09 +0100	[thread overview]
Message-ID: <20180126215209.vqdxh5p672tcdst6@pd.tnic> (raw)
In-Reply-To: <7094ed9b-40f7-ba2b-55a6-cc5ab0b06bb9@amd.com>

On Fri, Jan 26, 2018 at 03:06:20PM -0600, Tom Lendacky wrote:
> So I like the idea of AMD_IBRS/AMD_IBPB/AMD_STIBP and then use the magic
> quotes as appropriate.  We could probably use the magic quotes on
> AMD_STIBP and set X86_FEATURE_STIBP when we see X86_FEATURE_AMD_STIBP.

Like this?

We set the respective Intel features when we detect the AMD ones so that
we get correct /proc/cpuinfo strings. The respective AMD ones are not
shown.

---
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 40f92eff09df..73080d5a5696 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -272,9 +272,9 @@
 #define X86_FEATURE_CLZERO		(13*32+ 0) /* CLZERO instruction */
 #define X86_FEATURE_IRPERF		(13*32+ 1) /* Instructions Retired Count */
 #define X86_FEATURE_XSAVEERPTR		(13*32+ 2) /* Always save/restore FP error pointers */
-#define X86_FEATURE_AMD_PRED_CMD	(13*32+12) /* Prediction Command MSR (AMD) */
-#define X86_FEATURE_AMD_SPEC_CTRL	(13*32+14) /* Speculation Control MSR only (AMD) */
-#define X86_FEATURE_AMD_STIBP		(13*32+15) /* Single Thread Indirect Branch Predictors (AMD) */
+#define X86_FEATURE_AMD_IBPB		(13*32+12) /* "" Indirect Branch Prediction Barrier MSR */
+#define X86_FEATURE_AMD_IBRS		(13*32+14) /* "" Speculation Control MSR only */
+#define X86_FEATURE_AMD_STIBP		(13*32+15) /* "" Single Thread Indirect Branch Predictors */
 
 /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
 #define X86_FEATURE_DTHERM		(14*32+ 0) /* Digital Thermal Sensor */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index ea831c858195..14c8a7869450 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -872,6 +872,12 @@ static void init_amd(struct cpuinfo_x86 *c)
 	/* AMD CPUs don't reset SS attributes on SYSRET, Xen does. */
 	if (!cpu_has(c, X86_FEATURE_XENPV))
 		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
+
+	if (cpu_has(c, X86_FEATURE_AMD_IBRS))
+		set_cpu_cap(c, X86_FEATURE_IBRS);
+
+	if (cpu_has(c, X86_FEATURE_AMD_STIBP))
+		set_cpu_cap(c, X86_FEATURE_STIBP);
 }
 
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index c988a8acb0d5..be068aea6bda 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -266,7 +266,7 @@ static void __init spectre_v2_select_mitigation(void)
 
 	/* Initialize Indirect Branch Prediction Barrier if supported */
 	if (boot_cpu_has(X86_FEATURE_SPEC_CTRL) ||
-	    boot_cpu_has(X86_FEATURE_AMD_PRED_CMD)) {
+	    boot_cpu_has(X86_FEATURE_AMD_IBPB)) {
 		setup_force_cpu_cap(X86_FEATURE_IBPB);
 		pr_info("Enabling Indirect Branch Prediction Barrier\n");
 	}
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 7a3d216875fc..571249b8bc00 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -177,14 +177,14 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 
 	if ((cpu_has(c, X86_FEATURE_SPEC_CTRL) ||
 	     cpu_has(c, X86_FEATURE_STIBP) ||
-	     cpu_has(c, X86_FEATURE_AMD_SPEC_CTRL) ||
-	     cpu_has(c, X86_FEATURE_AMD_PRED_CMD) ||
+	     cpu_has(c, X86_FEATURE_AMD_IBRS) ||
+	     cpu_has(c, X86_FEATURE_AMD_IBPB) ||
 	     cpu_has(c, X86_FEATURE_AMD_STIBP)) && bad_spectre_microcode(c)) {
 		pr_warn("Intel Spectre v2 broken microcode detected; disabling SPEC_CTRL\n");
 		clear_cpu_cap(c, X86_FEATURE_SPEC_CTRL);
 		clear_cpu_cap(c, X86_FEATURE_STIBP);
-		clear_cpu_cap(c, X86_FEATURE_AMD_SPEC_CTRL);
-		clear_cpu_cap(c, X86_FEATURE_AMD_PRED_CMD);
+		clear_cpu_cap(c, X86_FEATURE_AMD_IBRS);
+		clear_cpu_cap(c, X86_FEATURE_AMD_IBPB);
 		clear_cpu_cap(c, X86_FEATURE_AMD_STIBP);
 	}
 

-- 
Regards/Gruss,
    Boris.

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

  reply	other threads:[~2018-01-26 21:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 16:14 [PATCH v5 0/7] Basic Speculation Control feature support David Woodhouse
2018-01-25 16:14 ` [PATCH v5 1/7] x86/cpufeatures: Add CPUID_7_EDX CPUID leaf David Woodhouse
2018-01-26 14:59   ` [tip:x86/pti] " tip-bot for David Woodhouse
2018-01-25 16:14 ` [PATCH v5 2/7] x86/cpufeatures: Add Intel feature bits for Speculation Control David Woodhouse
2018-01-26 15:00   ` [tip:x86/pti] " tip-bot for David Woodhouse
2018-01-25 16:14 ` [PATCH v5 3/7] x86/cpufeatures: Add AMD " David Woodhouse
2018-01-25 21:30   ` Borislav Petkov
2018-01-25 21:37     ` Thomas Gleixner
2018-01-25 21:41     ` Borislav Petkov
2018-01-26 15:00   ` [tip:x86/pti] " tip-bot for David Woodhouse
2018-01-26 18:41     ` [PATCH] x86/cpufeatures: Cleanup AMD speculation feature bits Borislav Petkov
2018-01-26 18:45       ` David Woodhouse
2018-01-26 18:49         ` Borislav Petkov
2018-01-26 21:06           ` Tom Lendacky
2018-01-26 21:52             ` Borislav Petkov [this message]
2018-01-26 21:59               ` David Woodhouse
2018-01-26 22:10                 ` Borislav Petkov
2018-01-26 23:14                   ` Tom Lendacky
2018-01-27  8:49                     ` David Woodhouse
2018-01-27  9:27                     ` David Woodhouse
2018-01-27  9:37                       ` Borislav Petkov
2018-01-27 10:32                         ` David Woodhouse
2018-01-27 13:18                           ` Borislav Petkov
2018-01-25 16:14 ` [PATCH v5 4/7] x86/msr: Add definitions for new speculation control MSRs David Woodhouse
2018-01-26 15:00   ` [tip:x86/pti] " tip-bot for David Woodhouse
2018-01-25 16:14 ` [PATCH v5 5/7] x86/pti: Do not enable PTI on processors which are not vulnerable to Meltdown David Woodhouse
2018-01-25 18:10   ` Dave Hansen
2018-01-25 19:53     ` Dave Hansen
2018-01-25 22:00   ` Borislav Petkov
2018-01-26 15:01   ` [tip:x86/pti] x86/pti: Do not enable PTI on CPUs " tip-bot for David Woodhouse
2018-01-25 16:14 ` [PATCH v5 6/7] x86/cpufeature: Blacklist SPEC_CTRL/PRED_CMD on early Spectre v2 microcodes David Woodhouse
2018-01-26 15:01   ` [tip:x86/pti] " tip-bot for David Woodhouse
2018-01-25 16:14 ` [PATCH v5 7/7] x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support David Woodhouse
2018-01-26 15:02   ` [tip:x86/pti] " tip-bot for David Woodhouse
2018-01-26 16:18     ` David Woodhouse
2018-01-26 21:36   ` [PATCH v5 7/7] " Tim Chen

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=20180126215209.vqdxh5p672tcdst6@pd.tnic \
    --to=bp@alien8.de \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --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.