public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs
@ 2022-07-01 13:19 Fenghua Yu
  2022-07-01 14:20 ` Dave Hansen
  2022-07-05 19:46 ` Dave Hansen
  0 siblings, 2 replies; 4+ messages in thread
From: Fenghua Yu @ 2022-07-01 13:19 UTC (permalink / raw)
  To: Thomas Gleixner, Borislav Petkov, Dave Hansen, Ingo Molnar,
	Tony Luck
  Cc: x86, linux-kernel, Fenghua Yu

These CPU models support the split lock detect feature. Add them to
the x86_cpu_ids match table.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
This patch supersedes the earlier:
https://lore.kernel.org/lkml/20220609193549.2725612-1-fenghua.yu@intel.com/
that just added Raptor Lake P.

 arch/x86/kernel/cpu/intel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index fd5dead8371c..5afb7d3d248d 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -1290,6 +1290,8 @@ static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
 	X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE,		1),
 	X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L,		1),
 	X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE,		1),
+	X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_P,	1),
+	X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_N,		1),
 	{}
 };
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs
  2022-07-01 13:19 [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs Fenghua Yu
@ 2022-07-01 14:20 ` Dave Hansen
  2022-07-02 10:32   ` David Laight
  2022-07-05 19:46 ` Dave Hansen
  1 sibling, 1 reply; 4+ messages in thread
From: Dave Hansen @ 2022-07-01 14:20 UTC (permalink / raw)
  To: Fenghua Yu, Thomas Gleixner, Borislav Petkov, Dave Hansen,
	Ingo Molnar, Tony Luck
  Cc: x86, linux-kernel

On 7/1/22 06:19, Fenghua Yu wrote:
> These CPU models support the split lock detect feature. Add them to
> the x86_cpu_ids match table.

When is there going to be architectural detection for this feature?  Or,
is the plan to just keep adding CPUs to this table as they are available.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs
  2022-07-01 14:20 ` Dave Hansen
@ 2022-07-02 10:32   ` David Laight
  0 siblings, 0 replies; 4+ messages in thread
From: David Laight @ 2022-07-02 10:32 UTC (permalink / raw)
  To: 'Dave Hansen', Fenghua Yu, Thomas Gleixner,
	Borislav Petkov, Dave Hansen, Ingo Molnar, Tony Luck
  Cc: x86, linux-kernel

From: Dave Hansen
> Sent: 01 July 2022 15:20
> 
> On 7/1/22 06:19, Fenghua Yu wrote:
> > These CPU models support the split lock detect feature. Add them to
> > the x86_cpu_ids match table.
> 
> When is there going to be architectural detection for this feature?  Or,
> is the plan to just keep adding CPUs to this table as they are available.

I saw that as well, it really doesn't scale at all.

Isn't it usual for the flag to not be settable on old cpu?

In any case the flag could be set and then a 'split lock'
transfer and see if it faults.

OTOH why bother with the test?
Unless you want to report that the 'split lock' detection
doesn't work?

Or did Intel really screw this up and use a flag that has
some other undesirable effect on (at least some) older cpu.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs
  2022-07-01 13:19 [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs Fenghua Yu
  2022-07-01 14:20 ` Dave Hansen
@ 2022-07-05 19:46 ` Dave Hansen
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2022-07-05 19:46 UTC (permalink / raw)
  To: Fenghua Yu, Thomas Gleixner, Borislav Petkov, Dave Hansen,
	Ingo Molnar, Tony Luck
  Cc: x86, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

I have an alternative patch.

Let's just consider the MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT bit to be
architectural.  Are there *ACTUAL* implementations where this is wrong?
 If not, let's just make it part of the architecture.  Intel can then
keep it true forever.

Some documentation which says:

	All processors that enumerate support for MSR_IA32_CORE_CAPS and
	set MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT support split lock 	
	detection.

would suffice, I think.  Just look at the diffstat.  What's not to love?

[-- Attachment #2: split-lock-arch.patch --]
[-- Type: text/x-patch, Size: 2832 bytes --]



---

 b/arch/x86/kernel/cpu/intel.c |   55 +++++++++++++-----------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)

diff -puN arch/x86/kernel/cpu/intel.c~split-lock-arch arch/x86/kernel/cpu/intel.c
--- a/arch/x86/kernel/cpu/intel.c~split-lock-arch	2022-07-05 12:37:21.294034182 -0700
+++ b/arch/x86/kernel/cpu/intel.c	2022-07-05 12:43:40.483842478 -0700
@@ -1265,31 +1265,14 @@ void handle_bus_lock(struct pt_regs *reg
 }
 
 /*
- * 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.
+ * Not all bits in MSR_IA32_CORE_CAPS are architectural, but
+ * MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT is.  All CPUs that set
+ * it have split lock detection.
  */
 static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
-	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X,		0),
-	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L,		0),
-	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D,		0),
-	X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT,	1),
-	X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D,	1),
-	X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_L,	1),
-	X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L,		1),
-	X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE,		1),
-	X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X,	1),
-	X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE,		1),
-	X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L,		1),
-	X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE,		1),
+	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X,	1),
+	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L,	1),
+	X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D,	1),
 	{}
 };
 
@@ -1301,24 +1284,22 @@ static void __init split_lock_setup(stru
 	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return;
 
+	/* Check for CPUs that have support but do not enumerate it: */
 	m = x86_match_cpu(split_lock_cpu_ids);
-	if (!m)
-		return;
+	if (m)
+		goto supported;
 
-	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);
-		if (!(ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT))
-			return;
-		break;
-	default:
+	if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES))
 		return;
-	}
 
+	rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps);
+	if (ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT)
+		goto supported;
+
+	/* CPU is not in the model list and does not have the MSR bit: */
+	return;
+
+supported:
 	cpu_model_supports_sld = true;
 	__split_lock_setup();
 }
_

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-05 19:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-01 13:19 [PATCH] x86/split_lock: Enable the split lock detect feature on Raptor Lake P and Alder Lake N CPUs Fenghua Yu
2022-07-01 14:20 ` Dave Hansen
2022-07-02 10:32   ` David Laight
2022-07-05 19:46 ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox