All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "Luck\, Tony" <tony.luck@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>, Fenghua Yu <fenghua.yu@intel.com>,
	Borislav Petkov <bp@alien8.de>, H Peter Anvin <hpa@zytor.com>,
	Ashok Raj <ashok.raj@intel.com>,
	Ravi V Shankar <ravi.v.shankar@intel.com>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH 2/3] x86/split_lock: Bits in IA32_CORE_CAPABILITIES are not architectural
Date: Fri, 17 Apr 2020 23:07:37 +0200	[thread overview]
Message-ID: <873691zuqu.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <877dydzvml.fsf@nanos.tec.linutronix.de>

Tony,

Thomas Gleixner <tglx@linutronix.de> writes:
> "Luck, Tony" <tony.luck@intel.com> writes:
>> Swings and roundabouts ... getting rid of the goto makes for
>> deeper indentation. But if you really want to get rid of the
>> goto, then your version is fine with me.
>>
>> Do you want me to spin it into v3?
>
> Nah. I tweak it myself.

as I fear that the infinite wisdom of HW folks will add yet another
variant in the foreseeable future, I used a switch() right away and
tweaked the comments a bit.

Can you have a look, please?

Thanks,

        tglx

8<------------------
From: Tony Luck <tony.luck@intel.com>
Subject: x86/split_lock: Bits in IA32_CORE_CAPABILITIES are not architectural
Date: Thu, 16 Apr 2020 13:57:53 -0700

From: Tony Luck <tony.luck@intel.com>

The Intel Software Developers' Manual erroneously listed bit 5 of the
IA32_CORE_CAPABILITIES register as an architectural feature. It is not.

Features enumerated by IA32_CORE_CAPABILITIES are model specific and
implementation details may vary in different cpu models. Thus it is only
safe to trust features after checking the CPU model.

Icelake client and server models are known to implement the split lock
detect feature even though they don't enumerate IA32_CORE_CAPABILITIES

Fixes: 6650cdd9a8cc ("x86/split_lock: Enable split lock detection by kernel")
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200416205754.21177-3-tony.luck@intel.com

---
 arch/x86/kernel/cpu/intel.c |   45 ++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)

--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -1120,10 +1120,17 @@ void switch_to_sld(unsigned long tifn)
 }
 
 /*
- * The following processors have the split lock detection feature. But
- * since they don't have the IA32_CORE_CAPABILITIES MSR, the feature cannot
- * be enumerated. Enable it by family and model matching on these
- * processors.
+ * Bits in the IA32_CORE_CAPABILITIES are not architectural, so they should
+ * only be trusted if it is confirmed that a CPU model implements a
+ * specific feature at a particular bit position.
+ *
+ * The possible driver data field values:
+ *
+ * - 0: CPU models that are known to have the per-core split-lock detection
+ *	feature even though they do not enumerate IA32_CORE_CAPABILITIES.
+ *
+ * - 1: CPU models which may enumerate IA32_CORE_CAPABILITIES and if so use
+ *      bit 5 to enumerate the per-core split-lock detection feature.
  */
 static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
 	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X,		0),
@@ -1133,19 +1140,29 @@ static const struct x86_cpu_id split_loc
 
 void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c)
 {
-	u64 ia32_core_caps = 0;
+	const struct x86_cpu_id *m;
+	u64 ia32_core_caps;
 
-	if (c->x86_vendor != X86_VENDOR_INTEL)
+	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return;
-	if (cpu_has(c, X86_FEATURE_CORE_CAPABILITIES)) {
-		/* Enumerate features reported in IA32_CORE_CAPABILITIES MSR. */
+
+	m = x86_match_cpu(split_lock_cpu_ids);
+	if (!m)
+		return;
+
+	switch (m->driver_data) {
+	case 0:
+		break;
+	case 1:
+		if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES))
+			return;
 		rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps);
-	} else if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
-		/* Enumerate split lock detection by family and model. */
-		if (x86_match_cpu(split_lock_cpu_ids))
-			ia32_core_caps |= MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT;
+		if (!(ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT))
+			return;
+		break;
+	default:
+		return;
 	}
 
-	if (ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT)
-		split_lock_setup();
+	split_lock_setup();
 }

  reply	other threads:[~2020-04-17 21:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 20:57 [PATCH 0/3] Split lock enumeration cleanup and fixes Tony Luck
2020-04-16 20:57 ` [PATCH 1/3] x86/split_lock: Update to use X86_MATCH_INTEL_FAM6_MODEL() Tony Luck
2020-04-17 10:20   ` [tip: x86/urgent] " tip-bot2 for Tony Luck
2020-04-16 20:57 ` [PATCH 2/3] x86/split_lock: Bits in IA32_CORE_CAPABILITIES are not architectural Tony Luck
2020-04-16 22:06   ` Thomas Gleixner
2020-04-16 22:33     ` Luck, Tony
2020-04-17  9:48       ` Thomas Gleixner
2020-04-17 10:04   ` Thomas Gleixner
2020-04-17 17:06     ` Luck, Tony
2020-04-17 19:29       ` Thomas Gleixner
2020-04-17 19:56         ` Luck, Tony
2020-04-17 20:48           ` Thomas Gleixner
2020-04-17 21:07             ` Thomas Gleixner [this message]
2020-04-17 21:19               ` Luck, Tony
2020-04-17 22:18                 ` Thomas Gleixner
2020-04-18  4:15               ` Xiaoyao Li
2020-04-18  4:35                 ` Sean Christopherson
2020-04-18  9:27                 ` Thomas Gleixner
2020-04-18 10:54   ` [tip: x86/urgent] " tip-bot2 for Tony Luck
2020-04-16 20:57 ` [PATCH 3/3] x86/split_lock: Add Tremont family CPU models Tony Luck
2020-04-18 10:54   ` [tip: x86/urgent] " tip-bot2 for Tony Luck
2020-04-16 21:35 ` [PATCH 0/3] Split lock enumeration cleanup and fixes Thomas Gleixner
2020-04-16 21:39   ` Luck, Tony

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=873691zuqu.fsf@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=ashok.raj@intel.com \
    --cc=bp@alien8.de \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=ravi.v.shankar@intel.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tony.luck@intel.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.