Skip to contentSkip to conversation

Prepare for new Intel Family numbers

PATCH Applied Sohil Mehta 8 participants 60 messages Feb 19, 2025 – Aug 24, 2025

Subsystems (8)
x86 KVM ACPI perf events +4 more subsystems

v3 of 4 Applied Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Prepare for new Intel Family numbers

---Summary---
Mainstream Intel processors have been using Family 6 for a couple of decades. This series is an audit of all the arch/x86 Intel Family-model checks to get ready for the upcoming Family 18 and 19 models. It also converts the last reamaining Intel x86_model checks to VFM ones.

Patch 1-8 : Include Dave Hansen's Acked-by.
Patch 9-15: Almost ready to merge but don't have review tags yet.

---v3 changes---
* Reordered the patches and moved the Acked ones to the front since they are likely to get applied sooner.
* Patches 11 and 14 have a slightly different approach now.
* Improved commit messages overall.
* Dropped the drivers/ fixes. Will post them separately.

---Previous versions---
Refer the v2 cover letter for more background.

v2: https://lore.kernel.org/lkml/[email protected]/
RFC-v1: https://lore.kernel.org/lkml/[email protected]/

Sohil Mehta (15):
x86/apic: Fix 32-bit APIC initialization for extended Intel Families x86/cpu/intel: Fix the movsl alignment preference for extended
Families
x86/microcode: Update the Intel processor flag scan check x86/mtrr: Modify a x86_model check to an Intel VFM check x86/cpu/intel: Replace early Family 6 checks with VFM ones x86/cpu/intel: Replace Family 15 checks with VFM ones x86/cpu/intel: Replace Family 5 model checks with VFM ones x86/acpi/cstate: Improve Intel Family model checks x86/smpboot: Remove confusing quirk usage in INIT delay x86/smpboot: Fix INIT delay assignment for extended Intel Families x86/cpu/intel: Fix fast string initialization for extended Families x86/pat: Replace Intel x86_model checks with VFM ones x86/cpu/intel: Bound the non-architectural constant_tsc model checks perf/x86: Simplify Intel PMU initialization
perf/x86/p4: Replace Pentium 4 model checks with VFM ones

 arch/x86/events/intel/core.c          | 16 ++++--
 arch/x86/events/intel/p4.c            |  7 +--
 arch/x86/events/intel/p6.c            | 26 ++--------
 arch/x86/include/asm/intel-family.h   | 21 +++++++-
 arch/x86/kernel/acpi/cstate.c         |  8 +--
 arch/x86/kernel/apic/apic.c           |  4 +-
 arch/x86/kernel/cpu/intel.c           | 74 +++++++++++++--------------
 arch/x86/kernel/cpu/microcode/intel.c |  2 +-
 arch/x86/kernel/cpu/mtrr/generic.c    |  4 +-
 arch/x86/kernel/smpboot.c             | 17 +++---
 arch/x86/mm/pat/memtype.c             |  6 +--
 11 files changed, 93 insertions(+), 92 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/15 x86/apic: Fix 32-bit APIC initialization for extended Intel Families

APIC detection is currently limited to a few specific Families and will not match the upcoming Families >=18.

Extend the check to include all Families 6 or greater. Also convert it to a VFM check to make it simpler.

---
v3: No change
v2: Update commit message to make it more precise

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/apic.c +2 -2
index e893dc6f11c1..4d99bd65faf5 100644
@@ -2014,8 +2014,8 @@ static bool __init detect_init_APIC(void)
 	case X86_VENDOR_HYGON:
 		break;
 	case X86_VENDOR_INTEL:
-		if (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15 ||
-		    (boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)))
+		if ((boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)) ||
+		    boot_cpu_data.x86_vfm >= INTEL_PENTIUM_PRO)
 			break;
 		goto no_apic;
 	default:
Signature · 1 line
2.43.0
merge bot Applied
#2 lore raw

[tip: x86/cpu] x86/apic: Fix 32-bit APIC initialization for extended Intel Families

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     3447a2e710494fea44ba76a949b3d3afe17a7a23
Gitweb:        https://git.kernel.org/tip/3447a2e710494fea44ba76a949b3d3afe17a7a23
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:19 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:44 +01:00

x86/apic: Fix 32-bit APIC initialization for extended Intel Families

APIC detection is currently limited to a few specific Families and will not match the upcoming Families >=18.

Extend the check to include all Families 6 or greater. Also convert it to a VFM check to make it simpler.

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/apic.c +2 -2
index ddca8da..62584a3 100644
@@ -2011,8 +2011,8 @@ static bool __init detect_init_APIC(void)
 	case X86_VENDOR_HYGON:
 		break;
 	case X86_VENDOR_INTEL:
-		if (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15 ||
-		    (boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)))
+		if ((boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)) ||
+		    boot_cpu_data.x86_vfm >= INTEL_PENTIUM_PRO)
 			break;
 		goto no_apic;
 	default:
merge bot Applied
#3 lore raw

[tip: x86/core] x86/apic: Fix 32-bit APIC initialization for extended Intel Families

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     680d9b2a56681bc63eb7d2109700536d494b6c8c
Gitweb:        https://git.kernel.org/tip/680d9b2a56681bc63eb7d2109700536d494b6c8c
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:19 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:29 +01:00

x86/apic: Fix 32-bit APIC initialization for extended Intel Families

APIC detection is currently limited to a few specific Families and will not match the upcoming Families >=18.

Extend the check to include all Families 6 or greater. Also convert it to a VFM check to make it simpler.

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/apic.c +2 -2
index ddca8da..62584a3 100644
@@ -2011,8 +2011,8 @@ static bool __init detect_init_APIC(void)
 	case X86_VENDOR_HYGON:
 		break;
 	case X86_VENDOR_INTEL:
-		if (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15 ||
-		    (boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)))
+		if ((boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)) ||
+		    boot_cpu_data.x86_vfm >= INTEL_PENTIUM_PRO)
 			break;
 		goto no_apic;
 	default:
#4 lore raw

PATCH v3 2/15 x86/cpu/intel: Fix the movsl alignment preference for extended Families

In reply to Sohil Mehta

The alignment preference for 32-bit movsl based bulk memory move has been 8-byte for a long time. However this preference is only set for Family 6 and 15 processors.

Use the same preference for upcoming Family numbers 18 and 19. Also, use a simpler VFM based check instead of switching based on Family numbers. Refresh the comment to reflect the new check.

---
v3: Picked up Dave's Ack. Improve commit message.
v2: Split the patch into two parts. Update commit message.

---
 arch/x86/kernel/cpu/intel.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/intel.c +6 -13
index 3dce22f00dc3..e5f34a90963e 100644
@@ -449,23 +449,16 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	    (c->x86_stepping < 0x6 || c->x86_stepping == 0xb))
 		set_cpu_bug(c, X86_BUG_11AP);
 
-
 #ifdef CONFIG_X86_INTEL_USERCOPY
 	/*
-	 * Set up the preferred alignment for movsl bulk memory moves
+	 * movsl bulk memory moves can be slow when source and dest are not
+	 * both 8-byte aligned. PII/PIII only like movsl with 8-byte alignment.
+	 *
+	 * Set the preferred alignment for Pentium Pro and newer processors, as
+	 * it has only been tested on these.
 	 */
-	switch (c->x86) {
-	case 4:		/* 486: untested */
-		break;
-	case 5:		/* Old Pentia: untested */
-		break;
-	case 6:		/* PII/PIII only like movsl with 8-byte alignment */
+	if (c->x86_vfm >= INTEL_PENTIUM_PRO)
 		movsl_mask.mask = 7;
-		break;
-	case 15:	/* P4 is OK down to 8-byte alignment */
-		movsl_mask.mask = 7;
-		break;
-	}
 #endif
 
 	intel_smp_check(c);
Signature · 1 line
2.43.0
merge bot Applied
#5 lore raw

[tip: x86/cpu] x86/cpu/intel: Fix the MOVSL alignment preference for extended Families

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     d3c20b8ceadbe561033f51cb220859e3f1bcb44f
Gitweb:        https://git.kernel.org/tip/d3c20b8ceadbe561033f51cb220859e3f1bcb44f
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:20 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:44 +01:00

x86/cpu/intel: Fix the MOVSL alignment preference for extended Families

The alignment preference for 32-bit MOVSL based bulk memory move has been 8-byte for a long time. However this preference is only set for Family 6 and 15 processors.

Use the same preference for upcoming Family numbers 18 and 19. Also, use a simpler VFM based check instead of switching based on Family numbers. Refresh the comment to reflect the new check.

---
 arch/x86/kernel/cpu/intel.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/intel.c +6 -13
index 291c828..99b4c40 100644
@@ -440,23 +440,16 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	    (c->x86_stepping < 0x6 || c->x86_stepping == 0xb))
 		set_cpu_bug(c, X86_BUG_11AP);
 
-
 #ifdef CONFIG_X86_INTEL_USERCOPY
 	/*
-	 * Set up the preferred alignment for movsl bulk memory moves
+	 * MOVSL bulk memory moves can be slow when source and dest are not
+	 * both 8-byte aligned. PII/PIII only like MOVSL with 8-byte alignment.
+	 *
+	 * Set the preferred alignment for Pentium Pro and newer processors, as
+	 * it has only been tested on these.
 	 */
-	switch (c->x86) {
-	case 4:		/* 486: untested */
-		break;
-	case 5:		/* Old Pentia: untested */
-		break;
-	case 6:		/* PII/PIII only like movsl with 8-byte alignment */
+	if (c->x86_vfm >= INTEL_PENTIUM_PRO)
 		movsl_mask.mask = 7;
-		break;
-	case 15:	/* P4 is OK down to 8-byte alignment */
-		movsl_mask.mask = 7;
-		break;
-	}
 #endif
 
 	intel_smp_check(c);
merge bot Applied
#6 lore raw

[tip: x86/core] x86/cpu/intel: Fix the MOVSL alignment preference for extended Families

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     7e67f3617228318da655dc87bc705f9c5f7bb101
Gitweb:        https://git.kernel.org/tip/7e67f3617228318da655dc87bc705f9c5f7bb101
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:20 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:31 +01:00

x86/cpu/intel: Fix the MOVSL alignment preference for extended Families

The alignment preference for 32-bit MOVSL based bulk memory move has been 8-byte for a long time. However this preference is only set for Family 6 and 15 processors.

Use the same preference for upcoming Family numbers 18 and 19. Also, use a simpler VFM based check instead of switching based on Family numbers. Refresh the comment to reflect the new check.

---
 arch/x86/kernel/cpu/intel.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/intel.c +6 -13
index 291c828..99b4c40 100644
@@ -440,23 +440,16 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	    (c->x86_stepping < 0x6 || c->x86_stepping == 0xb))
 		set_cpu_bug(c, X86_BUG_11AP);
 
-
 #ifdef CONFIG_X86_INTEL_USERCOPY
 	/*
-	 * Set up the preferred alignment for movsl bulk memory moves
+	 * MOVSL bulk memory moves can be slow when source and dest are not
+	 * both 8-byte aligned. PII/PIII only like MOVSL with 8-byte alignment.
+	 *
+	 * Set the preferred alignment for Pentium Pro and newer processors, as
+	 * it has only been tested on these.
 	 */
-	switch (c->x86) {
-	case 4:		/* 486: untested */
-		break;
-	case 5:		/* Old Pentia: untested */
-		break;
-	case 6:		/* PII/PIII only like movsl with 8-byte alignment */
+	if (c->x86_vfm >= INTEL_PENTIUM_PRO)
 		movsl_mask.mask = 7;
-		break;
-	case 15:	/* P4 is OK down to 8-byte alignment */
-		movsl_mask.mask = 7;
-		break;
-	}
 #endif
 
 	intel_smp_check(c);
#7 lore raw

PATCH v3 3/15 x86/microcode: Update the Intel processor flag scan check

In reply to Sohil Mehta

The Family model check to read the processor flag MSR is misleading and potentially incorrect. It doesn't consider Family while comparing the model number. The original check did have a Family number but it got lost/moved during refactoring.

intel_collect_cpu_info() is called through multiple paths such as early initialization, CPU hotplug as well as IFS image load. Some of these flows would be error prone due to the ambiguous check.

Correct the processor flag scan check to use a Family number and update it to a VFM based one to make it more readable.

---
v3: Picked up Dave's Ack.
v2: Use a VFM check instead of hardcoded numbers.

---
 arch/x86/include/asm/intel-family.h   | 1 +
 arch/x86/kernel/cpu/microcode/intel.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/intel-family.h +1 -0
index 6d7b04ffc5fd..cccc932d761e 100644
@@ -46,6 +46,7 @@
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
+#define INTEL_PENTIUM_III_DESCHUTES	IFM(6, 0x05)
 
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
arch/x86/kernel/cpu/microcode/intel.c +1 -1
index f3d534807d91..819199bc0119 100644
@@ -74,7 +74,7 @@ void intel_collect_cpu_info(struct cpu_signature *sig)
 	sig->pf = 0;
 	sig->rev = intel_get_microcode_revision();
 
-	if (x86_model(sig->sig) >= 5 || x86_family(sig->sig) > 6) {
+	if (IFM(x86_family(sig->sig), x86_model(sig->sig)) >= INTEL_PENTIUM_III_DESCHUTES) {
 		unsigned int val[2];
 
 		/* get processor flags from MSR 0x17 */
Signature · 1 line
2.43.0
merge bot Applied
#8 lore raw

[tip: x86/cpu] x86/microcode: Update the Intel processor flag scan check

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     faeaa39c37c9334f0b57f551c106a54be387b524
Gitweb:        https://git.kernel.org/tip/faeaa39c37c9334f0b57f551c106a54be387b524
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:21 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:45 +01:00

x86/microcode: Update the Intel processor flag scan check

The Family model check to read the processor flag MSR is misleading and potentially incorrect. It doesn't consider Family while comparing the model number. The original check did have a Family number but it got lost/moved during refactoring.

intel_collect_cpu_info() is called through multiple paths such as early initialization, CPU hotplug as well as IFS image load. Some of these flows would be error prone due to the ambiguous check.

Correct the processor flag scan check to use a Family number and update it to a VFM based one to make it more readable.

---
 arch/x86/include/asm/intel-family.h   | 1 +
 arch/x86/kernel/cpu/microcode/intel.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/intel-family.h +1 -0
index b657d78..f0e7ed0 100644
@@ -46,6 +46,7 @@
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
+#define INTEL_PENTIUM_III_DESCHUTES	IFM(6, 0x05)
 
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
arch/x86/kernel/cpu/microcode/intel.c +1 -1
index f3d5348..819199b 100644
@@ -74,7 +74,7 @@ void intel_collect_cpu_info(struct cpu_signature *sig)
 	sig->pf = 0;
 	sig->rev = intel_get_microcode_revision();
 
-	if (x86_model(sig->sig) >= 5 || x86_family(sig->sig) > 6) {
+	if (IFM(x86_family(sig->sig), x86_model(sig->sig)) >= INTEL_PENTIUM_III_DESCHUTES) {
 		unsigned int val[2];
 
 		/* get processor flags from MSR 0x17 */
merge bot Applied
#9 lore raw

[tip: x86/core] x86/microcode: Update the Intel processor flag scan check

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     7e6b0a2e4152f4046af95eeb46f8b4f9b2a7398d
Gitweb:        https://git.kernel.org/tip/7e6b0a2e4152f4046af95eeb46f8b4f9b2a7398d
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:21 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:38 +01:00

x86/microcode: Update the Intel processor flag scan check

The Family model check to read the processor flag MSR is misleading and potentially incorrect. It doesn't consider Family while comparing the model number. The original check did have a Family number but it got lost/moved during refactoring.

intel_collect_cpu_info() is called through multiple paths such as early initialization, CPU hotplug as well as IFS image load. Some of these flows would be error prone due to the ambiguous check.

Correct the processor flag scan check to use a Family number and update it to a VFM based one to make it more readable.

---
 arch/x86/include/asm/intel-family.h   | 1 +
 arch/x86/kernel/cpu/microcode/intel.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/intel-family.h +1 -0
index b657d78..f0e7ed0 100644
@@ -46,6 +46,7 @@
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
+#define INTEL_PENTIUM_III_DESCHUTES	IFM(6, 0x05)
 
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
arch/x86/kernel/cpu/microcode/intel.c +1 -1
index f3d5348..819199b 100644
@@ -74,7 +74,7 @@ void intel_collect_cpu_info(struct cpu_signature *sig)
 	sig->pf = 0;
 	sig->rev = intel_get_microcode_revision();
 
-	if (x86_model(sig->sig) >= 5 || x86_family(sig->sig) > 6) {
+	if (IFM(x86_family(sig->sig), x86_model(sig->sig)) >= INTEL_PENTIUM_III_DESCHUTES) {
 		unsigned int val[2];
 
 		/* get processor flags from MSR 0x17 */
#10 lore raw

PATCH v3 4/15 x86/mtrr: Modify a x86_model check to an Intel VFM check

In reply to Sohil Mehta

Simplify one of the last few Intel x86_model checks in arch/x86 by substituting it with a VFM one.

---
v3: Picked up Dave's Ack.
v2: No change.

---
 arch/x86/kernel/cpu/mtrr/generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mtrr/generic.c +2 -2
index 2fdfda2b60e4..826b8cff33cf 100644
@@ -12,6 +12,7 @@
 #include <asm/processor-flags.h>
 #include <asm/cacheinfo.h>
 #include <asm/cpufeature.h>
+#include <asm/cpu_device_id.h>
 #include <asm/hypervisor.h>
 #include <asm/mshyperv.h>
 #include <asm/tlbflush.h>
@@ -1025,8 +1026,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size,
 	 * For Intel PPro stepping <= 7
 	 * must be 4 MiB aligned and not touch 0x70000000 -> 0x7003FFFF
 	 */
-	if (mtrr_if == &generic_mtrr_ops && boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
+	if (mtrr_if == &generic_mtrr_ops && boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO &&
 	    boot_cpu_data.x86_stepping <= 7) {
 		if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) {
 			pr_warn("mtrr: base(0x%lx000) is not 4 MiB aligned\n", base);
Signature · 1 line
2.43.0
merge bot Applied
#11 lore raw

[tip: x86/cpu] x86/mtrr: Modify a x86_model check to an Intel VFM check

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     23c905f7ec9d8dc3016fa4e3a9f321a920583b60
Gitweb:        https://git.kernel.org/tip/23c905f7ec9d8dc3016fa4e3a9f321a920583b60
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:22 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:45 +01:00

x86/mtrr: Modify a x86_model check to an Intel VFM check

Simplify one of the last few Intel x86_model checks in arch/x86 by substituting it with a VFM one.

---
 arch/x86/kernel/cpu/mtrr/generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mtrr/generic.c +2 -2
index 6be3cad..e2c6b47 100644
@@ -13,6 +13,7 @@
 #include <asm/processor-flags.h>
 #include <asm/cacheinfo.h>
 #include <asm/cpufeature.h>
+#include <asm/cpu_device_id.h>
 #include <asm/hypervisor.h>
 #include <asm/mshyperv.h>
 #include <asm/tlbflush.h>
@@ -1026,8 +1027,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size,
 	 * For Intel PPro stepping <= 7
 	 * must be 4 MiB aligned and not touch 0x70000000 -> 0x7003FFFF
 	 */
-	if (mtrr_if == &generic_mtrr_ops && boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
+	if (mtrr_if == &generic_mtrr_ops && boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO &&
 	    boot_cpu_data.x86_stepping <= 7) {
 		if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) {
 			pr_warn("mtrr: base(0x%lx000) is not 4 MiB aligned\n", base);
merge bot Applied
#12 lore raw

[tip: x86/core] x86/mtrr: Modify a x86_model check to an Intel VFM check

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     a8cb451458057295fa251152a0297ece5519850f
Gitweb:        https://git.kernel.org/tip/a8cb451458057295fa251152a0297ece5519850f
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:22 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:40 +01:00

x86/mtrr: Modify a x86_model check to an Intel VFM check

Simplify one of the last few Intel x86_model checks in arch/x86 by substituting it with a VFM one.

---
 arch/x86/kernel/cpu/mtrr/generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mtrr/generic.c +2 -2
index 6be3cad..e2c6b47 100644
@@ -13,6 +13,7 @@
 #include <asm/processor-flags.h>
 #include <asm/cacheinfo.h>
 #include <asm/cpufeature.h>
+#include <asm/cpu_device_id.h>
 #include <asm/hypervisor.h>
 #include <asm/mshyperv.h>
 #include <asm/tlbflush.h>
@@ -1026,8 +1027,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size,
 	 * For Intel PPro stepping <= 7
 	 * must be 4 MiB aligned and not touch 0x70000000 -> 0x7003FFFF
 	 */
-	if (mtrr_if == &generic_mtrr_ops && boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
+	if (mtrr_if == &generic_mtrr_ops && boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO &&
 	    boot_cpu_data.x86_stepping <= 7) {
 		if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) {
 			pr_warn("mtrr: base(0x%lx000) is not 4 MiB aligned\n", base);
#13 lore raw

PATCH v3 5/15 x86/cpu/intel: Replace early Family 6 checks with VFM ones

In reply to Sohil Mehta

Introduce names for some old pentium models and replace the x86_model checks with VFM ones.

---
v3: Picked up Dave's Ack.
v2: No change

---
 arch/x86/include/asm/intel-family.h |  4 ++++
 arch/x86/kernel/cpu/intel.c         | 11 +++++------
 2 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/include/asm/intel-family.h +4 -0
index cccc932d761e..c1a081585fcb 100644
@@ -45,8 +45,12 @@
 /* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
+/* Family 6 */
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
+#define INTEL_PENTIUM_II_KLAMATH	IFM(6, 0x03)
 #define INTEL_PENTIUM_III_DESCHUTES	IFM(6, 0x05)
+#define INTEL_PENTIUM_III_TUALATIN	IFM(6, 0x0B)
+#define INTEL_PENTIUM_M_DOTHAN		IFM(6, 0x0D)
 
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
arch/x86/kernel/cpu/intel.c +5 -6
index e5f34a90963e..8e67d1ef4c73 100644
@@ -195,7 +195,7 @@ void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c)
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return;
 
-	if (c->x86 < 6 || (c->x86 == 6 && c->x86_model < 0xd))
+	if (c->x86_vfm < INTEL_PENTIUM_M_DOTHAN)
 		return;
 
 	/*
@@ -350,9 +350,7 @@ static void bsp_init_intel(struct cpuinfo_x86 *c)
 int ppro_with_ram_bug(void)
 {
 	/* Uses data from early_cpu_detect now */
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-	    boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
+	if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO &&
 	    boot_cpu_data.x86_stepping < 8) {
 		pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n");
 		return 1;
@@ -413,7 +411,8 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until
 	 * model 3 mask 3
 	 */
-	if ((c->x86<<8 | c->x86_model<<4 | c->x86_stepping) < 0x633)
+	if ((c->x86_vfm == INTEL_PENTIUM_II_KLAMATH && c->x86_stepping < 3) ||
+	    c->x86_vfm < INTEL_PENTIUM_II_KLAMATH)
 		clear_cpu_cap(c, X86_FEATURE_SEP);
 
 	/*
@@ -615,7 +614,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 	 * to determine which, so we use a boottime override
 	 * for the 512kb model, and assume 256 otherwise.
 	 */
-	if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0))
+	if (c->x86_vfm == INTEL_PENTIUM_III_TUALATIN && size == 0)
 		size = 256;
 
 	/*
Signature · 1 line
2.43.0
merge bot Applied
#14 lore raw

[tip: x86/cpu] x86/cpu/intel: Replace early Family 6 checks with VFM ones

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     93ba53da7da3e5dd2ed7b78672f1e6c22b24a607
Gitweb:        https://git.kernel.org/tip/93ba53da7da3e5dd2ed7b78672f1e6c22b24a607
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:23 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:45 +01:00

x86/cpu/intel: Replace early Family 6 checks with VFM ones

Introduce names for some old pentium models and replace the x86_model checks with VFM ones.

---
 arch/x86/include/asm/intel-family.h |  4 ++++
 arch/x86/kernel/cpu/intel.c         | 11 +++++------
 2 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/include/asm/intel-family.h +4 -0
index f0e7ed0..58735bc 100644
@@ -45,8 +45,12 @@
 /* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
+/* Family 6 */
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
+#define INTEL_PENTIUM_II_KLAMATH	IFM(6, 0x03)
 #define INTEL_PENTIUM_III_DESCHUTES	IFM(6, 0x05)
+#define INTEL_PENTIUM_III_TUALATIN	IFM(6, 0x0B)
+#define INTEL_PENTIUM_M_DOTHAN		IFM(6, 0x0D)
 
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
arch/x86/kernel/cpu/intel.c +5 -6
index 99b4c40..a49615f 100644
@@ -186,7 +186,7 @@ void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c)
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return;
 
-	if (c->x86 < 6 || (c->x86 == 6 && c->x86_model < 0xd))
+	if (c->x86_vfm < INTEL_PENTIUM_M_DOTHAN)
 		return;
 
 	/*
@@ -341,9 +341,7 @@ static void bsp_init_intel(struct cpuinfo_x86 *c)
 int ppro_with_ram_bug(void)
 {
 	/* Uses data from early_cpu_detect now */
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-	    boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
+	if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO &&
 	    boot_cpu_data.x86_stepping < 8) {
 		pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n");
 		return 1;
@@ -404,7 +402,8 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until
 	 * model 3 mask 3
 	 */
-	if ((c->x86<<8 | c->x86_model<<4 | c->x86_stepping) < 0x633)
+	if ((c->x86_vfm == INTEL_PENTIUM_II_KLAMATH && c->x86_stepping < 3) ||
+	    c->x86_vfm < INTEL_PENTIUM_II_KLAMATH)
 		clear_cpu_cap(c, X86_FEATURE_SEP);
 
 	/*
@@ -606,7 +605,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 	 * to determine which, so we use a boottime override
 	 * for the 512kb model, and assume 256 otherwise.
 	 */
-	if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0))
+	if (c->x86_vfm == INTEL_PENTIUM_III_TUALATIN && size == 0)
 		size = 256;
 
 	/*
merge bot Applied
#15 lore raw

[tip: x86/core] x86/cpu/intel: Replace early Family 6 checks with VFM ones

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     eaa472f76d1cc356c0f9d4406d2358ca924a797e
Gitweb:        https://git.kernel.org/tip/eaa472f76d1cc356c0f9d4406d2358ca924a797e
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:23 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:41 +01:00

x86/cpu/intel: Replace early Family 6 checks with VFM ones

Introduce names for some old pentium models and replace the x86_model checks with VFM ones.

---
 arch/x86/include/asm/intel-family.h |  4 ++++
 arch/x86/kernel/cpu/intel.c         | 11 +++++------
 2 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/include/asm/intel-family.h +4 -0
index f0e7ed0..58735bc 100644
@@ -45,8 +45,12 @@
 /* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
+/* Family 6 */
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
+#define INTEL_PENTIUM_II_KLAMATH	IFM(6, 0x03)
 #define INTEL_PENTIUM_III_DESCHUTES	IFM(6, 0x05)
+#define INTEL_PENTIUM_III_TUALATIN	IFM(6, 0x0B)
+#define INTEL_PENTIUM_M_DOTHAN		IFM(6, 0x0D)
 
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
arch/x86/kernel/cpu/intel.c +5 -6
index 99b4c40..a49615f 100644
@@ -186,7 +186,7 @@ void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c)
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return;
 
-	if (c->x86 < 6 || (c->x86 == 6 && c->x86_model < 0xd))
+	if (c->x86_vfm < INTEL_PENTIUM_M_DOTHAN)
 		return;
 
 	/*
@@ -341,9 +341,7 @@ static void bsp_init_intel(struct cpuinfo_x86 *c)
 int ppro_with_ram_bug(void)
 {
 	/* Uses data from early_cpu_detect now */
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-	    boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
+	if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO &&
 	    boot_cpu_data.x86_stepping < 8) {
 		pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n");
 		return 1;
@@ -404,7 +402,8 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until
 	 * model 3 mask 3
 	 */
-	if ((c->x86<<8 | c->x86_model<<4 | c->x86_stepping) < 0x633)
+	if ((c->x86_vfm == INTEL_PENTIUM_II_KLAMATH && c->x86_stepping < 3) ||
+	    c->x86_vfm < INTEL_PENTIUM_II_KLAMATH)
 		clear_cpu_cap(c, X86_FEATURE_SEP);
 
 	/*
@@ -606,7 +605,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 	 * to determine which, so we use a boottime override
 	 * for the 512kb model, and assume 256 otherwise.
 	 */
-	if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0))
+	if (c->x86_vfm == INTEL_PENTIUM_III_TUALATIN && size == 0)
 		size = 256;
 
 	/*
#16 lore raw

PATCH v3 6/15 x86/cpu/intel: Replace Family 15 checks with VFM ones

In reply to Sohil Mehta

Introduce names for some old pentium 4 models and replace the x86_model checks with VFM ones.

---
v3: Picked up Dave's Ack.
v2: No change.

---
 arch/x86/include/asm/intel-family.h | 4 ++++
 arch/x86/kernel/cpu/intel.c         | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/x86/include/asm/intel-family.h +4 -0
index c1a081585fcb..f509061b8c7e 100644
@@ -184,6 +184,10 @@
 /* Family 5 */
 #define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
 
+/* Family 15 - NetBurst */
+#define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
+#define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+
 /* Family 19 */
 #define INTEL_PANTHERCOVE_X		IFM(19, 0x01) /* Diamond Rapids */
 
arch/x86/kernel/cpu/intel.c +3 -3
index 8e67d1ef4c73..30f3812ba62c 100644
@@ -256,8 +256,8 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 #endif
 
 	/* CPUID workaround for 0F33/0F34 CPU */
-	if (c->x86 == 0xF && c->x86_model == 0x3
-	    && (c->x86_stepping == 0x3 || c->x86_stepping == 0x4))
+	if (c->x86_vfm == INTEL_P4_PRESCOTT &&
+	    (c->x86_stepping == 0x3 || c->x86_stepping == 0x4))
 		c->x86_phys_bits = 36;
 
 	/*
@@ -430,7 +430,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * P4 Xeon erratum 037 workaround.
 	 * Hardware prefetcher may cause stale data to be loaded into the cache.
 	 */
-	if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_stepping == 1)) {
+	if (c->x86_vfm == INTEL_P4_WILLAMETTE && c->x86_stepping == 1) {
 		if (msr_set_bit(MSR_IA32_MISC_ENABLE,
 				MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT) > 0) {
 			pr_info("CPU: C0 stepping P4 Xeon detected.\n");
Signature · 1 line
2.43.0
merge bot Applied
#17 lore raw

[tip: x86/cpu] x86/cpu/intel: Replace Family 15 checks with VFM ones

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     93a1337433ab6ae596d9c8a3e4d6fbcbe128afad
Gitweb:        https://git.kernel.org/tip/93a1337433ab6ae596d9c8a3e4d6fbcbe128afad
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:24 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:45 +01:00

x86/cpu/intel: Replace Family 15 checks with VFM ones

Introduce names for some old pentium 4 models and replace the x86_model checks with VFM ones.

---
 arch/x86/include/asm/intel-family.h | 4 ++++
 arch/x86/kernel/cpu/intel.c         | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/x86/include/asm/intel-family.h +4 -0
index 58735bc..0108695 100644
@@ -184,6 +184,10 @@
 /* Family 5 */
 #define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
 
+/* Family 15 - NetBurst */
+#define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
+#define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+
 /* Family 19 */
 #define INTEL_PANTHERCOVE_X		IFM(19, 0x01) /* Diamond Rapids */
 
arch/x86/kernel/cpu/intel.c +3 -3
index a49615f..42cebca 100644
@@ -247,8 +247,8 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 #endif
 
 	/* CPUID workaround for 0F33/0F34 CPU */
-	if (c->x86 == 0xF && c->x86_model == 0x3
-	    && (c->x86_stepping == 0x3 || c->x86_stepping == 0x4))
+	if (c->x86_vfm == INTEL_P4_PRESCOTT &&
+	    (c->x86_stepping == 0x3 || c->x86_stepping == 0x4))
 		c->x86_phys_bits = 36;
 
 	/*
@@ -421,7 +421,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * P4 Xeon erratum 037 workaround.
 	 * Hardware prefetcher may cause stale data to be loaded into the cache.
 	 */
-	if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_stepping == 1)) {
+	if (c->x86_vfm == INTEL_P4_WILLAMETTE && c->x86_stepping == 1) {
 		if (msr_set_bit(MSR_IA32_MISC_ENABLE,
 				MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT) > 0) {
 			pr_info("CPU: C0 stepping P4 Xeon detected.\n");
merge bot Applied
#18 lore raw

[tip: x86/core] x86/cpu/intel: Replace Family 15 checks with VFM ones

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     fc866f247277894bf887cda01c010e1d98abcb86
Gitweb:        https://git.kernel.org/tip/fc866f247277894bf887cda01c010e1d98abcb86
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:24 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:43 +01:00

x86/cpu/intel: Replace Family 15 checks with VFM ones

Introduce names for some old pentium 4 models and replace the x86_model checks with VFM ones.

---
 arch/x86/include/asm/intel-family.h | 4 ++++
 arch/x86/kernel/cpu/intel.c         | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/x86/include/asm/intel-family.h +4 -0
index 58735bc..0108695 100644
@@ -184,6 +184,10 @@
 /* Family 5 */
 #define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
 
+/* Family 15 - NetBurst */
+#define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
+#define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+
 /* Family 19 */
 #define INTEL_PANTHERCOVE_X		IFM(19, 0x01) /* Diamond Rapids */
 
arch/x86/kernel/cpu/intel.c +3 -3
index a49615f..42cebca 100644
@@ -247,8 +247,8 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 #endif
 
 	/* CPUID workaround for 0F33/0F34 CPU */
-	if (c->x86 == 0xF && c->x86_model == 0x3
-	    && (c->x86_stepping == 0x3 || c->x86_stepping == 0x4))
+	if (c->x86_vfm == INTEL_P4_PRESCOTT &&
+	    (c->x86_stepping == 0x3 || c->x86_stepping == 0x4))
 		c->x86_phys_bits = 36;
 
 	/*
@@ -421,7 +421,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * P4 Xeon erratum 037 workaround.
 	 * Hardware prefetcher may cause stale data to be loaded into the cache.
 	 */
-	if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_stepping == 1)) {
+	if (c->x86_vfm == INTEL_P4_WILLAMETTE && c->x86_stepping == 1) {
 		if (msr_set_bit(MSR_IA32_MISC_ENABLE,
 				MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT) > 0) {
 			pr_info("CPU: C0 stepping P4 Xeon detected.\n");
#19 lore raw

PATCH v3 7/15 x86/cpu/intel: Replace Family 5 model checks with VFM ones

In reply to Sohil Mehta

Introduce names for some Family 5 models and convert some of the checks to be VFM based.

Also, to keep the file sorted by family, move Family 5 to the top of the header file.

---
v3: Picked up Dave's Ack.
v2: Reorder the Family 5 models to be at the top of the file.

---
 arch/x86/include/asm/intel-family.h |  9 ++++++---
 arch/x86/kernel/cpu/intel.c         | 11 +++++------
 2 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/include/asm/intel-family.h +6 -3
index f509061b8c7e..9e6a13f03f0e 100644
@@ -45,6 +45,12 @@
 /* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
+/* Family 5 */
+#define INTEL_FAM5_START		IFM(5, 0x00) /* Notational marker, also P5 A-step */
+#define INTEL_PENTIUM_75		IFM(5, 0x02) /* P54C */
+#define INTEL_PENTIUM_MMX		IFM(5, 0x04) /* P55C */
+#define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
+
 /* Family 6 */
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
 #define INTEL_PENTIUM_II_KLAMATH	IFM(6, 0x03)
@@ -181,9 +187,6 @@
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
-/* Family 5 */
-#define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
-
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
arch/x86/kernel/cpu/intel.c +5 -6
index 30f3812ba62c..48aad9bcf300 100644
@@ -367,9 +367,8 @@ static void intel_smp_check(struct cpuinfo_x86 *c)
 	/*
 	 * Mask B, Pentium, but not Pentium MMX
 	 */
-	if (c->x86 == 5 &&
-	    c->x86_stepping >= 1 && c->x86_stepping <= 4 &&
-	    c->x86_model <= 3) {
+	if (c->x86_vfm >= INTEL_FAM5_START && c->x86_vfm < INTEL_PENTIUM_MMX &&
+	    c->x86_stepping >= 1 && c->x86_stepping <= 4) {
 		/*
 		 * Remember we have B step Pentia with bugs
 		 */
@@ -396,7 +395,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * The Quark is also family 5, but does not have the same bug.
 	 */
 	clear_cpu_bug(c, X86_BUG_F00F);
-	if (c->x86 == 5 && c->x86_model < 9) {
+	if (c->x86_vfm >= INTEL_FAM5_START && c->x86_vfm < INTEL_QUARK_X1000) {
 		static int f00f_workaround_enabled;
 
 		set_cpu_bug(c, X86_BUG_F00F);
@@ -444,7 +443,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * integrated APIC (see 11AP erratum in "Pentium Processor
 	 * Specification Update").
 	 */
-	if (boot_cpu_has(X86_FEATURE_APIC) && (c->x86<<8 | c->x86_model<<4) == 0x520 &&
+	if (boot_cpu_has(X86_FEATURE_APIC) && c->x86_vfm == INTEL_PENTIUM_75 &&
 	    (c->x86_stepping < 0x6 || c->x86_stepping == 0xb))
 		set_cpu_bug(c, X86_BUG_11AP);
 
@@ -621,7 +620,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 	 * Intel Quark SoC X1000 contains a 4-way set associative
 	 * 16K cache with a 16 byte cache line and 256 lines per tag
 	 */
-	if ((c->x86 == 5) && (c->x86_model == 9))
+	if (c->x86_vfm == INTEL_QUARK_X1000)
 		size = 16;
 	return size;
 }
Signature · 1 line
2.43.0
merge bot Applied
#20 lore raw

[tip: x86/cpu] x86/cpu/intel: Replace Family 5 model checks with VFM ones

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     8aba98edb8701dad1f748205eb7a093d268f0d40
Gitweb:        https://git.kernel.org/tip/8aba98edb8701dad1f748205eb7a093d268f0d40
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:25 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:45 +01:00

x86/cpu/intel: Replace Family 5 model checks with VFM ones

Introduce names for some Family 5 models and convert some of the checks to be VFM based.

Also, to keep the file sorted by family, move Family 5 to the top of the header file.

---
 arch/x86/include/asm/intel-family.h |  9 ++++++---
 arch/x86/kernel/cpu/intel.c         | 11 +++++------
 2 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/include/asm/intel-family.h +6 -3
index 0108695..4296c8e 100644
@@ -45,6 +45,12 @@
 /* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
+/* Family 5 */
+#define INTEL_FAM5_START		IFM(5, 0x00) /* Notational marker, also P5 A-step */
+#define INTEL_PENTIUM_75		IFM(5, 0x02) /* P54C */
+#define INTEL_PENTIUM_MMX		IFM(5, 0x04) /* P55C */
+#define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
+
 /* Family 6 */
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
 #define INTEL_PENTIUM_II_KLAMATH	IFM(6, 0x03)
@@ -181,9 +187,6 @@
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
-/* Family 5 */
-#define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
-
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
arch/x86/kernel/cpu/intel.c +5 -6
index 42cebca..ae20f45 100644
@@ -358,9 +358,8 @@ static void intel_smp_check(struct cpuinfo_x86 *c)
 	/*
 	 * Mask B, Pentium, but not Pentium MMX
 	 */
-	if (c->x86 == 5 &&
-	    c->x86_stepping >= 1 && c->x86_stepping <= 4 &&
-	    c->x86_model <= 3) {
+	if (c->x86_vfm >= INTEL_FAM5_START && c->x86_vfm < INTEL_PENTIUM_MMX &&
+	    c->x86_stepping >= 1 && c->x86_stepping <= 4) {
 		/*
 		 * Remember we have B step Pentia with bugs
 		 */
@@ -387,7 +386,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * The Quark is also family 5, but does not have the same bug.
 	 */
 	clear_cpu_bug(c, X86_BUG_F00F);
-	if (c->x86 == 5 && c->x86_model < 9) {
+	if (c->x86_vfm >= INTEL_FAM5_START && c->x86_vfm < INTEL_QUARK_X1000) {
 		static int f00f_workaround_enabled;
 
 		set_cpu_bug(c, X86_BUG_F00F);
@@ -435,7 +434,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * integrated APIC (see 11AP erratum in "Pentium Processor
 	 * Specification Update").
 	 */
-	if (boot_cpu_has(X86_FEATURE_APIC) && (c->x86<<8 | c->x86_model<<4) == 0x520 &&
+	if (boot_cpu_has(X86_FEATURE_APIC) && c->x86_vfm == INTEL_PENTIUM_75 &&
 	    (c->x86_stepping < 0x6 || c->x86_stepping == 0xb))
 		set_cpu_bug(c, X86_BUG_11AP);
 
@@ -612,7 +611,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 	 * Intel Quark SoC X1000 contains a 4-way set associative
 	 * 16K cache with a 16 byte cache line and 256 lines per tag
 	 */
-	if ((c->x86 == 5) && (c->x86_model == 9))
+	if (c->x86_vfm == INTEL_QUARK_X1000)
 		size = 16;
 	return size;
 }
merge bot Applied
#21 lore raw

[tip: x86/core] x86/cpu/intel: Replace Family 5 model checks with VFM ones

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     eb1ac3330573e0d6cb0f8dccde34112929fc1344
Gitweb:        https://git.kernel.org/tip/eb1ac3330573e0d6cb0f8dccde34112929fc1344
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:25 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:44 +01:00

x86/cpu/intel: Replace Family 5 model checks with VFM ones

Introduce names for some Family 5 models and convert some of the checks to be VFM based.

Also, to keep the file sorted by family, move Family 5 to the top of the header file.

---
 arch/x86/include/asm/intel-family.h |  9 ++++++---
 arch/x86/kernel/cpu/intel.c         | 11 +++++------
 2 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/include/asm/intel-family.h +6 -3
index 0108695..4296c8e 100644
@@ -45,6 +45,12 @@
 /* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
+/* Family 5 */
+#define INTEL_FAM5_START		IFM(5, 0x00) /* Notational marker, also P5 A-step */
+#define INTEL_PENTIUM_75		IFM(5, 0x02) /* P54C */
+#define INTEL_PENTIUM_MMX		IFM(5, 0x04) /* P55C */
+#define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
+
 /* Family 6 */
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
 #define INTEL_PENTIUM_II_KLAMATH	IFM(6, 0x03)
@@ -181,9 +187,6 @@
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
-/* Family 5 */
-#define INTEL_QUARK_X1000		IFM(5, 0x09) /* Quark X1000 SoC */
-
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
arch/x86/kernel/cpu/intel.c +5 -6
index 42cebca..ae20f45 100644
@@ -358,9 +358,8 @@ static void intel_smp_check(struct cpuinfo_x86 *c)
 	/*
 	 * Mask B, Pentium, but not Pentium MMX
 	 */
-	if (c->x86 == 5 &&
-	    c->x86_stepping >= 1 && c->x86_stepping <= 4 &&
-	    c->x86_model <= 3) {
+	if (c->x86_vfm >= INTEL_FAM5_START && c->x86_vfm < INTEL_PENTIUM_MMX &&
+	    c->x86_stepping >= 1 && c->x86_stepping <= 4) {
 		/*
 		 * Remember we have B step Pentia with bugs
 		 */
@@ -387,7 +386,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * The Quark is also family 5, but does not have the same bug.
 	 */
 	clear_cpu_bug(c, X86_BUG_F00F);
-	if (c->x86 == 5 && c->x86_model < 9) {
+	if (c->x86_vfm >= INTEL_FAM5_START && c->x86_vfm < INTEL_QUARK_X1000) {
 		static int f00f_workaround_enabled;
 
 		set_cpu_bug(c, X86_BUG_F00F);
@@ -435,7 +434,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 	 * integrated APIC (see 11AP erratum in "Pentium Processor
 	 * Specification Update").
 	 */
-	if (boot_cpu_has(X86_FEATURE_APIC) && (c->x86<<8 | c->x86_model<<4) == 0x520 &&
+	if (boot_cpu_has(X86_FEATURE_APIC) && c->x86_vfm == INTEL_PENTIUM_75 &&
 	    (c->x86_stepping < 0x6 || c->x86_stepping == 0xb))
 		set_cpu_bug(c, X86_BUG_11AP);
 
@@ -612,7 +611,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 	 * Intel Quark SoC X1000 contains a 4-way set associative
 	 * 16K cache with a 16 byte cache line and 256 lines per tag
 	 */
-	if ((c->x86 == 5) && (c->x86_model == 9))
+	if (c->x86_vfm == INTEL_QUARK_X1000)
 		size = 16;
 	return size;
 }
#22 lore raw

PATCH v3 8/15 x86/acpi/cstate: Improve Intel Family model checks

In reply to Sohil Mehta

Update the Intel Family checks to consistently use Family 15 instead of Family 0xF. Also, get rid of one of last usages of x86_model by using the new VFM checks.

Update the incorrect comment since the check has changed[1][2] since the initial commit ee1ca48fae7e ("ACPI: Disable ARB_DISABLE on platforms where it is not needed").

[1]: commit 3e2ada5867b7 ("ACPI: fix Compaq Evo N800c (Pentium 4m) boot hang regression") removed the P4 - Family 15.

[2]: commit 03a05ed11529 ("ACPI: Use the ARB_DISABLE for the CPU which model id is less than 0x0f.") got rid of CORE_YONAH - Family 6, model E.

---
v3: Pick up Dave's Ack.
v2: Improve commit message.

---
 arch/x86/include/asm/intel-family.h | 3 +++
 arch/x86/kernel/acpi/cstate.c       | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/include/asm/intel-family.h +3 -0
index 9e6a13f03f0e..deb17c9c21e5 100644
@@ -187,6 +187,9 @@
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
+/* Notational marker denoting the last Family 6 model */
+#define INTEL_FAM6_LAST			IFM(6, 0xFF)
+
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
arch/x86/kernel/acpi/cstate.c +4 -4
index 5854f0b8f0f1..444602a0a3dd 100644
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 
 #include <acpi/processor.h>
+#include <asm/cpu_device_id.h>
 #include <asm/cpuid.h>
 #include <asm/mwait.h>
 #include <asm/special_insns.h>
@@ -47,12 +48,11 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
 	/*
 	 * On all recent Intel platforms, ARB_DISABLE is a nop.
 	 * So, set bm_control to zero to indicate that ARB_DISABLE
-	 * is not required while entering C3 type state on
-	 * P4, Core and beyond CPUs
+	 * is not required while entering C3 type state.
 	 */
 	if (c->x86_vendor == X86_VENDOR_INTEL &&
-	    (c->x86 > 0xf || (c->x86 == 6 && c->x86_model >= 0x0f)))
-			flags->bm_control = 0;
+	    (c->x86 > 15 || (c->x86_vfm >= INTEL_CORE2_MEROM && c->x86_vfm <= INTEL_FAM6_LAST)))
+		flags->bm_control = 0;
 
 	if (c->x86_vendor == X86_VENDOR_CENTAUR) {
 		if (c->x86 > 6 || (c->x86 == 6 && c->x86_model == 0x0f &&
Signature · 1 line
2.43.0
maintainer Acked-by on v3 8/15
#23 lore raw

Re: [PATCH v3 08/15] x86/acpi/cstate: Improve Intel Family model checks

Quoted 9 lines · Sohil Mehta

Update the Intel Family checks to consistently use Family 15 instead of Family 0xF. Also, get rid of one of last usages of x86_model by using the new VFM checks.

Update the incorrect comment since the check has changed[1][2] since the initial commit ee1ca48fae7e ("ACPI: Disable ARB_DISABLE on platforms where it is not needed").

Quoted 8 lines

[1]: commit 3e2ada5867b7 ("ACPI: fix Compaq Evo N800c (Pentium 4m) boot hang regression") removed the P4 - Family 15.

[2]: commit 03a05ed11529 ("ACPI: Use the ARB_DISABLE for the CPU which model id is less than 0x0f.") got rid of CORE_YONAH - Family 6, model E.

and I'm assuming that this series will go in via x86.

Thanks!

Quoted 53 lines

---
v3: Pick up Dave's Ack.
v2: Improve commit message.

---
 arch/x86/include/asm/intel-family.h | 3 +++
 arch/x86/kernel/acpi/cstate.c       | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/include/asm/intel-family.h +3 -0
index 9e6a13f03f0e..deb17c9c21e5 100644
@@ -187,6 +187,9 @@
 #define INTEL_XEON_PHI_KNL             IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM             IFM(6, 0x85) /* Knights Mill */
 
+/* Notational marker denoting the last Family 6 model */
+#define INTEL_FAM6_LAST                        IFM(6, 0xFF)
+
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE            IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT              IFM(15, 0x03)
arch/x86/kernel/acpi/cstate.c +4 -5
index 5854f0b8f0f1..444602a0a3dd 100644
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 
 #include <acpi/processor.h>
+#include <asm/cpu_device_id.h>
 #include <asm/cpuid.h>
 #include <asm/mwait.h>
 #include <asm/special_insns.h>
@@ -47,12 +48,11 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
        /*
         * On all recent Intel platforms, ARB_DISABLE is a nop.
         * So, set bm_control to zero to indicate that ARB_DISABLE
-        * is not required while entering C3 type state on
-        * P4, Core and beyond CPUs
+        * is not required while entering C3 type state.
         */
        if (c->x86_vendor == X86_VENDOR_INTEL &&
-           (c->x86 > 0xf || (c->x86 == 6 && c->x86_model >= 0x0f)))
-                       flags->bm_control = 0;
+           (c->x86 > 15 || (c->x86_vfm >= INTEL_CORE2_MEROM && c->x86_vfm <= INTEL_FAM6_LAST)))
+               flags->bm_control = 0;
 
        if (c->x86_vendor == X86_VENDOR_CENTAUR) {
                if (c->x86 > 6 || (c->x86 == 6 && c->x86_model == 0x0f &&
--

2.43.0

merge bot Applied
#24 lore raw

[tip: x86/cpu] x86/acpi/cstate: Improve Intel Family model checks

In reply to Sohil Mehta
The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     38ed76e1aed9116dd549e3c6e3ab9581ff6dbd05
Gitweb:        https://git.kernel.org/tip/38ed76e1aed9116dd549e3c6e3ab9581ff6dbd05
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:26 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:46 +01:00

x86/acpi/cstate: Improve Intel Family model checks

Update the Intel Family checks to consistently use Family 15 instead of Family 0xF. Also, get rid of one of last usages of x86_model by using the new VFM checks.

Update the incorrect comment since the check has changed since the initial commit:

ee1ca48fae7e ("ACPI: Disable ARB_DISABLE on platforms where it is not needed")

The two changes were:

- 3e2ada5867b7 ("ACPI: fix Compaq Evo N800c (Pentium 4m) boot hang regression") removed the P4 - Family 15.

- 03a05ed11529 ("ACPI: Use the ARB_DISABLE for the CPU which model id is less than 0x0f.") got rid of CORE_YONAH - Family 6, model E.

---
 arch/x86/include/asm/intel-family.h | 3 +++
 arch/x86/kernel/acpi/cstate.c       | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/include/asm/intel-family.h +3 -0
index 4296c8e..51ea366 100644
@@ -187,6 +187,9 @@
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
+/* Notational marker denoting the last Family 6 model */
+#define INTEL_FAM6_LAST			IFM(6, 0xFF)
+
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
arch/x86/kernel/acpi/cstate.c +4 -4
index d255842..d5ac341 100644
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 
 #include <acpi/processor.h>
+#include <asm/cpu_device_id.h>
 #include <asm/cpuid.h>
 #include <asm/mwait.h>
 #include <asm/special_insns.h>
@@ -48,12 +49,11 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
 	/*
 	 * On all recent Intel platforms, ARB_DISABLE is a nop.
 	 * So, set bm_control to zero to indicate that ARB_DISABLE
-	 * is not required while entering C3 type state on
-	 * P4, Core and beyond CPUs
+	 * is not required while entering C3 type state.
 	 */
 	if (c->x86_vendor == X86_VENDOR_INTEL &&
-	    (c->x86 > 0xf || (c->x86 == 6 && c->x86_model >= 0x0f)))
-			flags->bm_control = 0;
+	    (c->x86 > 15 || (c->x86_vfm >= INTEL_CORE2_MEROM && c->x86_vfm <= INTEL_FAM6_LAST)))
+		flags->bm_control = 0;
 
 	if (c->x86_vendor == X86_VENDOR_CENTAUR) {
 		if (c->x86 > 6 || (c->x86 == 6 && c->x86_model == 0x0f &&
merge bot Applied
#25 lore raw

[tip: x86/core] x86/acpi/cstate: Improve Intel Family model checks

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     337959860dbb02120a029dcd169a26ae596c92ee
Gitweb:        https://git.kernel.org/tip/337959860dbb02120a029dcd169a26ae596c92ee
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:26 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:46 +01:00

x86/acpi/cstate: Improve Intel Family model checks

Update the Intel Family checks to consistently use Family 15 instead of Family 0xF. Also, get rid of one of last usages of x86_model by using the new VFM checks.

Update the incorrect comment since the check has changed since the initial commit:

ee1ca48fae7e ("ACPI: Disable ARB_DISABLE on platforms where it is not needed")

The two changes were:

- 3e2ada5867b7 ("ACPI: fix Compaq Evo N800c (Pentium 4m) boot hang regression") removed the P4 - Family 15.

- 03a05ed11529 ("ACPI: Use the ARB_DISABLE for the CPU which model id is less than 0x0f.") got rid of CORE_YONAH - Family 6, model E.

---
 arch/x86/include/asm/intel-family.h | 3 +++
 arch/x86/kernel/acpi/cstate.c       | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/include/asm/intel-family.h +3 -0
index 4296c8e..51ea366 100644
@@ -187,6 +187,9 @@
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
+/* Notational marker denoting the last Family 6 model */
+#define INTEL_FAM6_LAST			IFM(6, 0xFF)
+
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
arch/x86/kernel/acpi/cstate.c +4 -4
index d255842..d5ac341 100644
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 
 #include <acpi/processor.h>
+#include <asm/cpu_device_id.h>
 #include <asm/cpuid.h>
 #include <asm/mwait.h>
 #include <asm/special_insns.h>
@@ -48,12 +49,11 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
 	/*
 	 * On all recent Intel platforms, ARB_DISABLE is a nop.
 	 * So, set bm_control to zero to indicate that ARB_DISABLE
-	 * is not required while entering C3 type state on
-	 * P4, Core and beyond CPUs
+	 * is not required while entering C3 type state.
 	 */
 	if (c->x86_vendor == X86_VENDOR_INTEL &&
-	    (c->x86 > 0xf || (c->x86 == 6 && c->x86_model >= 0x0f)))
-			flags->bm_control = 0;
+	    (c->x86 > 15 || (c->x86_vfm >= INTEL_CORE2_MEROM && c->x86_vfm <= INTEL_FAM6_LAST)))
+		flags->bm_control = 0;
 
 	if (c->x86_vendor == X86_VENDOR_CENTAUR) {
 		if (c->x86 > 6 || (c->x86 == 6 && c->x86_model == 0x0f &&
#26 lore raw

PATCH v3 9/15 x86/smpboot: Remove confusing quirk usage in INIT delay

In reply to Sohil Mehta

Very old multiprocessor systems required a 10 msec delay between asserting and de-asserting INIT but modern processors do not require this delay.

Over time the usage of the "quirk" wording while setting the INIT delay has become misleading. The code comments suggest that modern processors need to be quirked, which clears the default init_udelay of 10 msec, while legacy processors don't need the quirk and continue to use the default init_udelay.

With a lot more modern processors, the wording should be inverted if at all needed. Instead, simplify the comments and the code by getting rid of "quirk" usage altogether and clarifying the following:

Old legacy processors -> Set the "legacy" 10 msec delay
Modern processors -> Do not set any delay

No functional change.

---
v3: Improve commit message
v2: New patch

---
 arch/x86/kernel/smpboot.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
arch/x86/kernel/smpboot.c +5 -6
index c10850ae6f09..eb91ed0f2a06 100644
@@ -654,10 +654,9 @@ static void impress_friends(void)
  * But that slows boot and resume on modern processors, which include
  * many cores and don't require that delay.
  *
- * Cmdline "init_cpu_udelay=" is available to over-ride this delay.
- * Modern processor families are quirked to remove the delay entirely.
+ * Cmdline "cpu_init_udelay=" is available to override this delay.
  */
-#define UDELAY_10MS_DEFAULT 10000
+#define UDELAY_10MS_LEGACY 10000
 
 static unsigned int init_udelay = UINT_MAX;
 
@@ -669,7 +668,7 @@ static int __init cpu_init_udelay(char *str)
 }
 early_param("cpu_init_udelay", cpu_init_udelay);
 
-static void __init smp_quirk_init_udelay(void)
+static void __init smp_set_init_udelay(void)
 {
 	/* if cmdline changed it from default, leave it alone */
 	if (init_udelay != UINT_MAX)
@@ -683,7 +682,7 @@ static void __init smp_quirk_init_udelay(void)
 		return;
 	}
 	/* else, use legacy delay */
-	init_udelay = UDELAY_10MS_DEFAULT;
+	init_udelay = UDELAY_10MS_LEGACY;
 }
 
 /*
@@ -1094,7 +1093,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 
 	uv_system_init();
 
-	smp_quirk_init_udelay();
+	smp_set_init_udelay();
 
 	speculative_store_bypass_ht_init();
 
Signature · 1 line
2.43.0
merge bot Applied
#27 lore raw

[tip: x86/cpu] x86/smpboot: Remove confusing quirk usage in INIT delay

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     4f15efe5cecd8b2dc566f1c0c13e3551b72a34e5
Gitweb:        https://git.kernel.org/tip/4f15efe5cecd8b2dc566f1c0c13e3551b72a34e5
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:27 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:46 +01:00

x86/smpboot: Remove confusing quirk usage in INIT delay

Very old multiprocessor systems required a 10 msec delay between asserting and de-asserting INIT but modern processors do not require this delay.

Over time the usage of the "quirk" wording while setting the INIT delay has become misleading. The code comments suggest that modern processors need to be quirked, which clears the default init_udelay of 10 msec, while legacy processors don't need the quirk and continue to use the default init_udelay.

With a lot more modern processors, the wording should be inverted if at all needed. Instead, simplify the comments and the code by getting rid of "quirk" usage altogether and clarifying the following:

- Old legacy processors -> Set the "legacy" 10 msec delay
- Modern processors -> Do not set any delay

No functional change.

---
 arch/x86/kernel/smpboot.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
arch/x86/kernel/smpboot.c +5 -6
index 8ecf1bf..7dccc44 100644
@@ -634,10 +634,9 @@ static void impress_friends(void)
  * But that slows boot and resume on modern processors, which include
  * many cores and don't require that delay.
  *
- * Cmdline "init_cpu_udelay=" is available to over-ride this delay.
- * Modern processor families are quirked to remove the delay entirely.
+ * Cmdline "cpu_init_udelay=" is available to override this delay.
  */
-#define UDELAY_10MS_DEFAULT 10000
+#define UDELAY_10MS_LEGACY 10000
 
 static unsigned int init_udelay = UINT_MAX;
 
@@ -649,7 +648,7 @@ static int __init cpu_init_udelay(char *str)
 }
 early_param("cpu_init_udelay", cpu_init_udelay);
 
-static void __init smp_quirk_init_udelay(void)
+static void __init smp_set_init_udelay(void)
 {
 	/* if cmdline changed it from default, leave it alone */
 	if (init_udelay != UINT_MAX)
@@ -663,7 +662,7 @@ static void __init smp_quirk_init_udelay(void)
 		return;
 	}
 	/* else, use legacy delay */
-	init_udelay = UDELAY_10MS_DEFAULT;
+	init_udelay = UDELAY_10MS_LEGACY;
 }
 
 /*
@@ -1074,7 +1073,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 
 	uv_system_init();
 
-	smp_quirk_init_udelay();
+	smp_set_init_udelay();
 
 	speculative_store_bypass_ht_init();
 
merge bot Applied
#28 lore raw

[tip: x86/core] x86/smpboot: Remove confusing quirk usage in INIT delay

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     58d1c1fd0319d00e83f58f2a195847e189e447ce
Gitweb:        https://git.kernel.org/tip/58d1c1fd0319d00e83f58f2a195847e189e447ce
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:27 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:48 +01:00

x86/smpboot: Remove confusing quirk usage in INIT delay

Very old multiprocessor systems required a 10 msec delay between asserting and de-asserting INIT but modern processors do not require this delay.

Over time the usage of the "quirk" wording while setting the INIT delay has become misleading. The code comments suggest that modern processors need to be quirked, which clears the default init_udelay of 10 msec, while legacy processors don't need the quirk and continue to use the default init_udelay.

With a lot more modern processors, the wording should be inverted if at all needed. Instead, simplify the comments and the code by getting rid of "quirk" usage altogether and clarifying the following:

- Old legacy processors -> Set the "legacy" 10 msec delay
- Modern processors -> Do not set any delay

No functional change.

---
 arch/x86/kernel/smpboot.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
arch/x86/kernel/smpboot.c +5 -6
index 42ca131..5e586f5 100644
@@ -635,10 +635,9 @@ static void impress_friends(void)
  * But that slows boot and resume on modern processors, which include
  * many cores and don't require that delay.
  *
- * Cmdline "init_cpu_udelay=" is available to over-ride this delay.
- * Modern processor families are quirked to remove the delay entirely.
+ * Cmdline "cpu_init_udelay=" is available to override this delay.
  */
-#define UDELAY_10MS_DEFAULT 10000
+#define UDELAY_10MS_LEGACY 10000
 
 static unsigned int init_udelay = UINT_MAX;
 
@@ -650,7 +649,7 @@ static int __init cpu_init_udelay(char *str)
 }
 early_param("cpu_init_udelay", cpu_init_udelay);
 
-static void __init smp_quirk_init_udelay(void)
+static void __init smp_set_init_udelay(void)
 {
 	/* if cmdline changed it from default, leave it alone */
 	if (init_udelay != UINT_MAX)
@@ -664,7 +663,7 @@ static void __init smp_quirk_init_udelay(void)
 		return;
 	}
 	/* else, use legacy delay */
-	init_udelay = UDELAY_10MS_DEFAULT;
+	init_udelay = UDELAY_10MS_LEGACY;
 }
 
 /*
@@ -1075,7 +1074,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 
 	uv_system_init();
 
-	smp_quirk_init_udelay();
+	smp_set_init_udelay();
 
 	speculative_store_bypass_ht_init();
 
#29 lore raw

PATCH v3 10/15 x86/smpboot: Fix INIT delay assignment for extended Intel Families

In reply to Sohil Mehta

Some old crusty CPUs need an extra delay that slows down booting. See the comment above 'init_udelay' for details. Newer CPUs don't need the delay.

Right now, for Intel, Family 6 and only Family 6 skips the delay. That leaves out both the Family 15 (Pentium 4s) and brand new Family 18/19 models.

The omission of Family 15 (Pentium 4s) seems like an oversight and 18/19 do not need the delay.

Skip the delay on all Intel processors Family 6 and beyond.

---
v3: Improve commit message
v2: Make the changelog more precise

---
 arch/x86/kernel/smpboot.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/smpboot.c +3 -3
index eb91ed0f2a06..57e7b6441384 100644
@@ -675,9 +675,9 @@ static void __init smp_set_init_udelay(void)
 		return;
 
 	/* if modern processor, use no delay */
-	if (((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 == 6)) ||
-	    ((boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) && (boot_cpu_data.x86 >= 0x18)) ||
-	    ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF))) {
+	if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && boot_cpu_data.x86_vfm >= INTEL_PENTIUM_PRO) ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON && boot_cpu_data.x86 >= 0x18) ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_AMD   && boot_cpu_data.x86 >= 0xF)) {
 		init_udelay = 0;
 		return;
 	}
Signature · 1 line
2.43.0
merge bot Applied
#30 lore raw

[tip: x86/cpu] x86/smpboot: Fix INIT delay assignment for extended Intel Families

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     17b1dd60e367795b0b4f44c9a477185f8444e8b9
Gitweb:        https://git.kernel.org/tip/17b1dd60e367795b0b4f44c9a477185f8444e8b9
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:28 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:46 +01:00

x86/smpboot: Fix INIT delay assignment for extended Intel Families

Some old crusty CPUs need an extra delay that slows down booting. See the comment above 'init_udelay' for details. Newer CPUs don't need the delay.

Right now, for Intel, Family 6 and only Family 6 skips the delay. That leaves out both the Family 15 (Pentium 4s) and brand new Family 18/19 models.

The omission of Family 15 (Pentium 4s) seems like an oversight and 18/19 do not need the delay.

Skip the delay on all Intel processors Family 6 and beyond.

---
 arch/x86/kernel/smpboot.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/smpboot.c +3 -3
index 7dccc44..b68216f 100644
@@ -655,9 +655,9 @@ static void __init smp_set_init_udelay(void)
 		return;
 
 	/* if modern processor, use no delay */
-	if (((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 == 6)) ||
-	    ((boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) && (boot_cpu_data.x86 >= 0x18)) ||
-	    ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF))) {
+	if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && boot_cpu_data.x86_vfm >= INTEL_PENTIUM_PRO) ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON && boot_cpu_data.x86 >= 0x18) ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_AMD   && boot_cpu_data.x86 >= 0xF)) {
 		init_udelay = 0;
 		return;
 	}
merge bot Applied
#31 lore raw

[tip: x86/core] x86/smpboot: Fix INIT delay assignment for extended Intel Families

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     7a2ad752746bfb13e89a83984ecc52a48bae4969
Gitweb:        https://git.kernel.org/tip/7a2ad752746bfb13e89a83984ecc52a48bae4969
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:28 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:50 +01:00

x86/smpboot: Fix INIT delay assignment for extended Intel Families

Some old crusty CPUs need an extra delay that slows down booting. See the comment above 'init_udelay' for details. Newer CPUs don't need the delay.

Right now, for Intel, Family 6 and only Family 6 skips the delay. That leaves out both the Family 15 (Pentium 4s) and brand new Family 18/19 models.

The omission of Family 15 (Pentium 4s) seems like an oversight and 18/19 do not need the delay.

Skip the delay on all Intel processors Family 6 and beyond.

---
 arch/x86/kernel/smpboot.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/smpboot.c +3 -3
index 5e586f5..d6cf1e2 100644
@@ -656,9 +656,9 @@ static void __init smp_set_init_udelay(void)
 		return;
 
 	/* if modern processor, use no delay */
-	if (((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 == 6)) ||
-	    ((boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) && (boot_cpu_data.x86 >= 0x18)) ||
-	    ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF))) {
+	if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && boot_cpu_data.x86_vfm >= INTEL_PENTIUM_PRO) ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON && boot_cpu_data.x86 >= 0x18) ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_AMD   && boot_cpu_data.x86 >= 0xF)) {
 		init_udelay = 0;
 		return;
 	}
#32 lore raw

PATCH v3 11/15 x86/cpu/intel: Fix fast string initialization for extended Families

In reply to Sohil Mehta

X86_FEATURE_REP_GOOD is a linux defined feature flag to track whether fast string operations should be used for copy_page(). It is also used as a second alternative for clear_page() if enhanced fast string operations (ERMS) are not available.

X86_FEATURE_ERMS is an Intel-specific hardware-defined feature flag that tracks hardware support for Enhanced Fast strings. It is used to track whether Fast strings should be used for similar memory copy and memory clearing operations.

On top of these, there is a FAST_STRING enable bit in the IA32_MISC_ENABLE MSR. It is typically controlled by the BIOS to provide a hint to the hardware and the OS on whether fast string operations are preferred.

commit 161ec53c702c ("x86, mem, intel: Initialize Enhanced REP MOVSB/STOSB") introduced a mechanism to honor the BIOS preference for fast string operations and clear the above feature flags if needed. Unfortunately, the current initialization code for Intel to set and clear these bits is confusing at best and likely incorrect.

X86_FEATURE_REP_GOOD is cleared in early_init_intel() if MISC_ENABLE.FAST_STRING is 0. But it gets set later on unconditionally for all Family 6 processors in init_intel(). This not only overrides the BIOS preference but also contradicts the earlier check.

Fix this by combining the related checks and always relying on the BIOS provided preference for fast string operations. This simplification makes sure the upcoming Intel Family 18 and 19 models are covered as well.

---
v3: Combine the REP_GOOD checks to one place.
Improve code comments.

v2: Separate out the REP_GOOD (copy page) specific change into a
separate commit.

---
 arch/x86/kernel/cpu/intel.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/intel.c +11 -6
index 48aad9bcf300..fc68561d9f92 100644
@@ -298,12 +298,19 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 		clear_cpu_cap(c, X86_FEATURE_PAT);
 
 	/*
-	 * If fast string is not enabled in IA32_MISC_ENABLE for any reason,
-	 * clear the fast string and enhanced fast string CPU capabilities.
+	 * Modern CPUs are generally expected to have a sane fast string
+	 * implementation. However, BIOSes typically have a knob to tweak
+	 * the architectural MISC_ENABLE.FAST_STRING enable bit.
+	 *
+	 * Adhere to the preference and program the linux-defined fast
+	 * string flag and enhanced fast string capabilities accordingly.
 	 */
-	if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
+	if (c->x86_vfm >= INTEL_PENTIUM_M_DOTHAN) {
 		rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-		if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
+		if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING) {
+			/* X86_FEATURE_ERMS is set based on CPUID */
+			set_cpu_cap(c, X86_FEATURE_REP_GOOD);
+		} else {
 			pr_info("Disabled fast string operations\n");
 			setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
 			setup_clear_cpu_cap(X86_FEATURE_ERMS);
@@ -554,8 +561,6 @@ static void init_intel(struct cpuinfo_x86 *c)
 #ifdef CONFIG_X86_64
 	if (c->x86 == 15)
 		c->x86_cache_alignment = c->x86_clflush_size * 2;
-	if (c->x86 == 6)
-		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 #else
 	/*
 	 * Names for the Pentium II/Celeron processors
Signature · 1 line
2.43.0
merge bot Applied
#33 lore raw

[tip: x86/cpu] x86/cpu/intel: Fix fast string initialization for extended Families

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     8a1259836966af36c5d3fe68cf33ad9416e5e70a
Gitweb:        https://git.kernel.org/tip/8a1259836966af36c5d3fe68cf33ad9416e5e70a
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:29 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:46 +01:00

x86/cpu/intel: Fix fast string initialization for extended Families

X86_FEATURE_REP_GOOD is a linux defined feature flag to track whether fast string operations should be used for copy_page(). It is also used as a second alternative for clear_page() if enhanced fast string operations (ERMS) are not available.

X86_FEATURE_ERMS is an Intel-specific hardware-defined feature flag that tracks hardware support for Enhanced Fast strings. It is used to track whether Fast strings should be used for similar memory copy and memory clearing operations.

On top of these, there is a FAST_STRING enable bit in the IA32_MISC_ENABLE MSR. It is typically controlled by the BIOS to provide a hint to the hardware and the OS on whether fast string operations are preferred.

Commit:

161ec53c702c ("x86, mem, intel: Initialize Enhanced REP MOVSB/STOSB")

introduced a mechanism to honor the BIOS preference for fast string operations and clear the above feature flags if needed.

Unfortunately, the current initialization code for Intel to set and clear these bits is confusing at best and likely incorrect.

X86_FEATURE_REP_GOOD is cleared in early_init_intel() if MISC_ENABLE.FAST_STRING is 0. But it gets set later on unconditionally for all Family 6 processors in init_intel(). This not only overrides the BIOS preference but also contradicts the earlier check.

Fix this by combining the related checks and always relying on the BIOS provided preference for fast string operations. This simplification makes sure the upcoming Intel Family 18 and 19 models are covered as well.

---
 arch/x86/kernel/cpu/intel.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/intel.c +11 -6
index ae20f45..2181304 100644
@@ -289,12 +289,19 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 		clear_cpu_cap(c, X86_FEATURE_PAT);
 
 	/*
-	 * If fast string is not enabled in IA32_MISC_ENABLE for any reason,
-	 * clear the fast string and enhanced fast string CPU capabilities.
+	 * Modern CPUs are generally expected to have a sane fast string
+	 * implementation. However, BIOSes typically have a knob to tweak
+	 * the architectural MISC_ENABLE.FAST_STRING enable bit.
+	 *
+	 * Adhere to the preference and program the Linux-defined fast
+	 * string flag and enhanced fast string capabilities accordingly.
 	 */
-	if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
+	if (c->x86_vfm >= INTEL_PENTIUM_M_DOTHAN) {
 		rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-		if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
+		if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING) {
+			/* X86_FEATURE_ERMS is set based on CPUID */
+			set_cpu_cap(c, X86_FEATURE_REP_GOOD);
+		} else {
 			pr_info("Disabled fast string operations\n");
 			setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
 			setup_clear_cpu_cap(X86_FEATURE_ERMS);
@@ -545,8 +552,6 @@ static void init_intel(struct cpuinfo_x86 *c)
 #ifdef CONFIG_X86_64
 	if (c->x86 == 15)
 		c->x86_cache_alignment = c->x86_clflush_size * 2;
-	if (c->x86 == 6)
-		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 #else
 	/*
 	 * Names for the Pentium II/Celeron processors
merge bot Applied
#34 lore raw

[tip: x86/core] x86/cpu/intel: Fix fast string initialization for extended Families

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     15b7ddcf66fb7ac371279be23b3b6008dad3e36c
Gitweb:        https://git.kernel.org/tip/15b7ddcf66fb7ac371279be23b3b6008dad3e36c
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:29 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:51 +01:00

x86/cpu/intel: Fix fast string initialization for extended Families

X86_FEATURE_REP_GOOD is a linux defined feature flag to track whether fast string operations should be used for copy_page(). It is also used as a second alternative for clear_page() if enhanced fast string operations (ERMS) are not available.

X86_FEATURE_ERMS is an Intel-specific hardware-defined feature flag that tracks hardware support for Enhanced Fast strings. It is used to track whether Fast strings should be used for similar memory copy and memory clearing operations.

On top of these, there is a FAST_STRING enable bit in the IA32_MISC_ENABLE MSR. It is typically controlled by the BIOS to provide a hint to the hardware and the OS on whether fast string operations are preferred.

Commit:

161ec53c702c ("x86, mem, intel: Initialize Enhanced REP MOVSB/STOSB")

introduced a mechanism to honor the BIOS preference for fast string operations and clear the above feature flags if needed.

Unfortunately, the current initialization code for Intel to set and clear these bits is confusing at best and likely incorrect.

X86_FEATURE_REP_GOOD is cleared in early_init_intel() if MISC_ENABLE.FAST_STRING is 0. But it gets set later on unconditionally for all Family 6 processors in init_intel(). This not only overrides the BIOS preference but also contradicts the earlier check.

Fix this by combining the related checks and always relying on the BIOS provided preference for fast string operations. This simplification makes sure the upcoming Intel Family 18 and 19 models are covered as well.

---
 arch/x86/kernel/cpu/intel.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/intel.c +11 -6
index ae20f45..2181304 100644
@@ -289,12 +289,19 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 		clear_cpu_cap(c, X86_FEATURE_PAT);
 
 	/*
-	 * If fast string is not enabled in IA32_MISC_ENABLE for any reason,
-	 * clear the fast string and enhanced fast string CPU capabilities.
+	 * Modern CPUs are generally expected to have a sane fast string
+	 * implementation. However, BIOSes typically have a knob to tweak
+	 * the architectural MISC_ENABLE.FAST_STRING enable bit.
+	 *
+	 * Adhere to the preference and program the Linux-defined fast
+	 * string flag and enhanced fast string capabilities accordingly.
 	 */
-	if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
+	if (c->x86_vfm >= INTEL_PENTIUM_M_DOTHAN) {
 		rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-		if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
+		if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING) {
+			/* X86_FEATURE_ERMS is set based on CPUID */
+			set_cpu_cap(c, X86_FEATURE_REP_GOOD);
+		} else {
 			pr_info("Disabled fast string operations\n");
 			setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
 			setup_clear_cpu_cap(X86_FEATURE_ERMS);
@@ -545,8 +552,6 @@ static void init_intel(struct cpuinfo_x86 *c)
 #ifdef CONFIG_X86_64
 	if (c->x86 == 15)
 		c->x86_cache_alignment = c->x86_clflush_size * 2;
-	if (c->x86 == 6)
-		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 #else
 	/*
 	 * Names for the Pentium II/Celeron processors
#35 lore raw

PATCH v3 12/15 x86/pat: Replace Intel x86_model checks with VFM ones

In reply to Sohil Mehta

Introduce markers and names for some Family 6 and Family 15 models and replace x86_model checks with VFM ones.

Since the VFM checks are closed ended and only applicable to Intel, get rid of the explicit Intel vendor check as well.

---
v3: Get rid of the Intel vendor check.
v2: Get rid of the INTEL_FAM15_START IFM(15, 0x00) define.

---
 arch/x86/include/asm/intel-family.h | 1 +
 arch/x86/mm/pat/memtype.c           | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/include/asm/intel-family.h +1 -0
index deb17c9c21e5..6621d796bb3d 100644
@@ -193,6 +193,7 @@
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+#define INTEL_P4_CEDARMILL		IFM(15, 0x06) /* Also Xeon Dempsey */
 
 /* Family 19 */
 #define INTEL_PANTHERCOVE_X		IFM(19, 0x01) /* Diamond Rapids */
arch/x86/mm/pat/memtype.c +3 -3
index feb8cc6a12bf..e40861c9cb90 100644
@@ -43,6 +43,7 @@
 #include <linux/fs.h>
 #include <linux/rbtree.h>
 
+#include <asm/cpu_device_id.h>
 #include <asm/cacheflush.h>
 #include <asm/cacheinfo.h>
 #include <asm/processor.h>
@@ -290,9 +291,8 @@ void __init pat_bp_init(void)
 		return;
 	}
 
-	if ((c->x86_vendor == X86_VENDOR_INTEL) &&
-	    (((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
-	     ((c->x86 == 0xf) && (c->x86_model <= 0x6)))) {
+	if ((c->x86_vfm >= INTEL_PENTIUM_PRO   && c->x86_vfm <= INTEL_PENTIUM_M_DOTHAN) ||
+	    (c->x86_vfm >= INTEL_P4_WILLAMETTE && c->x86_vfm <= INTEL_P4_CEDARMILL)) {
 		/*
 		 * PAT support with the lower four entries. Intel Pentium 2,
 		 * 3, M, and 4 are affected by PAT errata, which makes the
Signature · 1 line
2.43.0
merge bot Applied
#36 lore raw

[tip: x86/cpu] x86/mm/pat: Replace Intel x86_model checks with VFM ones

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     aa3e8239d8a2aa4dce2750968964afb5cdd424f8
Gitweb:        https://git.kernel.org/tip/aa3e8239d8a2aa4dce2750968964afb5cdd424f8
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:30 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:47 +01:00

x86/mm/pat: Replace Intel x86_model checks with VFM ones

Introduce markers and names for some Family 6 and Family 15 models and replace x86_model checks with VFM ones.

Since the VFM checks are closed ended and only applicable to Intel, get rid of the explicit Intel vendor check as well.

---
 arch/x86/include/asm/intel-family.h | 1 +
 arch/x86/mm/pat/memtype.c           | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/include/asm/intel-family.h +1 -0
index 51ea366..6cd08da 100644
@@ -193,6 +193,7 @@
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+#define INTEL_P4_CEDARMILL		IFM(15, 0x06) /* Also Xeon Dempsey */
 
 /* Family 19 */
 #define INTEL_PANTHERCOVE_X		IFM(19, 0x01) /* Diamond Rapids */
arch/x86/mm/pat/memtype.c +3 -3
index 3a9e6dd..fff9617 100644
@@ -43,6 +43,7 @@
 #include <linux/fs.h>
 #include <linux/rbtree.h>
 
+#include <asm/cpu_device_id.h>
 #include <asm/cacheflush.h>
 #include <asm/cacheinfo.h>
 #include <asm/processor.h>
@@ -290,9 +291,8 @@ void __init pat_bp_init(void)
 		return;
 	}
 
-	if ((c->x86_vendor == X86_VENDOR_INTEL) &&
-	    (((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
-	     ((c->x86 == 0xf) && (c->x86_model <= 0x6)))) {
+	if ((c->x86_vfm >= INTEL_PENTIUM_PRO   && c->x86_vfm <= INTEL_PENTIUM_M_DOTHAN) ||
+	    (c->x86_vfm >= INTEL_P4_WILLAMETTE && c->x86_vfm <= INTEL_P4_CEDARMILL)) {
 		/*
 		 * PAT support with the lower four entries. Intel Pentium 2,
 		 * 3, M, and 4 are affected by PAT errata, which makes the
merge bot Applied
#37 lore raw

[tip: x86/core] x86/mm/pat: Replace Intel x86_model checks with VFM ones

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     05d234d3c79e16ee5329dbbc611d1dde6c8c5ab3
Gitweb:        https://git.kernel.org/tip/05d234d3c79e16ee5329dbbc611d1dde6c8c5ab3
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:30 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:53 +01:00

x86/mm/pat: Replace Intel x86_model checks with VFM ones

Introduce markers and names for some Family 6 and Family 15 models and replace x86_model checks with VFM ones.

Since the VFM checks are closed ended and only applicable to Intel, get rid of the explicit Intel vendor check as well.

---
 arch/x86/include/asm/intel-family.h | 1 +
 arch/x86/mm/pat/memtype.c           | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/include/asm/intel-family.h +1 -0
index 51ea366..6cd08da 100644
@@ -193,6 +193,7 @@
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+#define INTEL_P4_CEDARMILL		IFM(15, 0x06) /* Also Xeon Dempsey */
 
 /* Family 19 */
 #define INTEL_PANTHERCOVE_X		IFM(19, 0x01) /* Diamond Rapids */
arch/x86/mm/pat/memtype.c +3 -3
index feb8cc6..e40861c 100644
@@ -43,6 +43,7 @@
 #include <linux/fs.h>
 #include <linux/rbtree.h>
 
+#include <asm/cpu_device_id.h>
 #include <asm/cacheflush.h>
 #include <asm/cacheinfo.h>
 #include <asm/processor.h>
@@ -290,9 +291,8 @@ void __init pat_bp_init(void)
 		return;
 	}
 
-	if ((c->x86_vendor == X86_VENDOR_INTEL) &&
-	    (((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
-	     ((c->x86 == 0xf) && (c->x86_model <= 0x6)))) {
+	if ((c->x86_vfm >= INTEL_PENTIUM_PRO   && c->x86_vfm <= INTEL_PENTIUM_M_DOTHAN) ||
+	    (c->x86_vfm >= INTEL_P4_WILLAMETTE && c->x86_vfm <= INTEL_P4_CEDARMILL)) {
 		/*
 		 * PAT support with the lower four entries. Intel Pentium 2,
 		 * 3, M, and 4 are affected by PAT errata, which makes the
#38 lore raw

PATCH v3 13/15 x86/cpu/intel: Bound the non-architectural constant_tsc model checks

In reply to Sohil Mehta

X86_FEATURE_CONSTANT_TSC is a Linux-defined, synthesized feature flag. It is used across several vendors. Intel CPUs will set the feature when the architectural CPUID.80000007.EDX[1] bit is set. There are also some Intel CPUs that have the X86_FEATURE_CONSTANT_TSC behavior but don't enumerate it with the architectural bit. Those currently have a model range check.

Today, virtually all of the CPUs that have the CPUID bit *also* match the "model >= 0x0e" check. This is confusing. Instead of an open-ended check, pick some models (INTEL_IVYBRIDGE and P4_WILLAMETTE) as the end of goofy CPUs that should enumerate the bit but don't. These models are relatively arbitrary but conservative pick for this.

This makes it obvious that later CPUs (like Family 18+) no longer need to synthesize X86_FEATURE_CONSTANT_TSC.

---
v3: Make the non-architectural model checks more explicit.
Improve commit message.

v2: No change.

---
 arch/x86/kernel/cpu/intel.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/intel.c +6 -4
index fc68561d9f92..4fbc5465ca67 100644
@@ -210,10 +210,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 {
 	u64 misc_enable;
 
-	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
-		(c->x86 == 0x6 && c->x86_model >= 0x0e))
-		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-
 	if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
 		c->microcode = intel_get_microcode_revision();
 
@@ -266,10 +262,16 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 	 *
 	 * It is also reliable across cores and sockets. (but not across
 	 * cabinets - we turn it off in that case explicitly.)
+	 *
+	 * Use a model-specific check for some older CPUs that have invariant
+	 * TSC but may not report it architecturally via 8000_0007.
 	 */
 	if (c->x86_power & (1 << 8)) {
 		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+	} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
+		   (c->x86_vfm >= INTEL_CORE_YONAH  && c->x86_vfm <= INTEL_IVYBRIDGE)) {
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 	}
 
 	/* Penwell and Cloverview have the TSC which doesn't sleep on S3 */
Signature · 1 line
2.43.0
merge bot Applied
#39 lore raw

[tip: x86/cpu] x86/cpu/intel: Limit the non-architectural constant_tsc model checks

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     08d9bb5b0d89826fedc5204c8bd2463220465996
Gitweb:        https://git.kernel.org/tip/08d9bb5b0d89826fedc5204c8bd2463220465996
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:31 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 18 Mar 2025 19:33:47 +01:00

x86/cpu/intel: Limit the non-architectural constant_tsc model checks

X86_FEATURE_CONSTANT_TSC is a Linux-defined, synthesized feature flag. It is used across several vendors. Intel CPUs will set the feature when the architectural CPUID.80000007.EDX[1] bit is set. There are also some Intel CPUs that have the X86_FEATURE_CONSTANT_TSC behavior but don't enumerate it with the architectural bit. Those currently have a model range check.

Today, virtually all of the CPUs that have the CPUID bit *also* match the "model >= 0x0e" check. This is confusing. Instead of an open-ended check, pick some models (INTEL_IVYBRIDGE and P4_WILLAMETTE) as the end of goofy CPUs that should enumerate the bit but don't. These models are relatively arbitrary but conservative pick for this.

This makes it obvious that later CPUs (like Family 18+) no longer need to synthesize X86_FEATURE_CONSTANT_TSC.

---
 arch/x86/kernel/cpu/intel.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/intel.c +6 -4
index 2181304..4cbb2e6 100644
@@ -201,10 +201,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 {
 	u64 misc_enable;
 
-	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
-		(c->x86 == 0x6 && c->x86_model >= 0x0e))
-		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-
 	if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
 		c->microcode = intel_get_microcode_revision();
 
@@ -257,10 +253,16 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 	 *
 	 * It is also reliable across cores and sockets. (but not across
 	 * cabinets - we turn it off in that case explicitly.)
+	 *
+	 * Use a model-specific check for some older CPUs that have invariant
+	 * TSC but may not report it architecturally via 8000_0007.
 	 */
 	if (c->x86_power & (1 << 8)) {
 		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+	} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
+		   (c->x86_vfm >= INTEL_CORE_YONAH  && c->x86_vfm <= INTEL_IVYBRIDGE)) {
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 	}
 
 	/* Penwell and Cloverview have the TSC which doesn't sleep on S3 */
merge bot Applied
#40 lore raw

[tip: x86/core] x86/cpu/intel: Limit the non-architectural constant_tsc model checks

In reply to Sohil Mehta
The following commit has been merged into the x86/core branch of tip:

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     fadb6f569b10bf668677add876ed50586931b8f3
Gitweb:        https://git.kernel.org/tip/fadb6f569b10bf668677add876ed50586931b8f3
Author:        Sohil Mehta <[email protected]>
AuthorDate:    Wed, 19 Feb 2025 18:41:31 
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 19 Mar 2025 11:19:56 +01:00

x86/cpu/intel: Limit the non-architectural constant_tsc model checks

X86_FEATURE_CONSTANT_TSC is a Linux-defined, synthesized feature flag. It is used across several vendors. Intel CPUs will set the feature when the architectural CPUID.80000007.EDX[1] bit is set. There are also some Intel CPUs that have the X86_FEATURE_CONSTANT_TSC behavior but don't enumerate it with the architectural bit. Those currently have a model range check.

Today, virtually all of the CPUs that have the CPUID bit *also* match the "model >= 0x0e" check. This is confusing. Instead of an open-ended check, pick some models (INTEL_IVYBRIDGE and P4_WILLAMETTE) as the end of goofy CPUs that should enumerate the bit but don't. These models are relatively arbitrary but conservative pick for this.

This makes it obvious that later CPUs (like Family 18+) no longer need to synthesize X86_FEATURE_CONSTANT_TSC.

---
 arch/x86/kernel/cpu/intel.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/intel.c +6 -4
index 2181304..4cbb2e6 100644
@@ -201,10 +201,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 {
 	u64 misc_enable;
 
-	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
-		(c->x86 == 0x6 && c->x86_model >= 0x0e))
-		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-
 	if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
 		c->microcode = intel_get_microcode_revision();
 
@@ -257,10 +253,16 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 	 *
 	 * It is also reliable across cores and sockets. (but not across
 	 * cabinets - we turn it off in that case explicitly.)
+	 *
+	 * Use a model-specific check for some older CPUs that have invariant
+	 * TSC but may not report it architecturally via 8000_0007.
 	 */
 	if (c->x86_power & (1 << 8)) {
 		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+	} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
+		   (c->x86_vfm >= INTEL_CORE_YONAH  && c->x86_vfm <= INTEL_IVYBRIDGE)) {
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 	}
 
 	/* Penwell and Cloverview have the TSC which doesn't sleep on S3 */
#41 lore raw

Re: [PATCH v3 13/15] x86/cpu/intel: Bound the non-architectural constant_tsc model checks

In reply to Sohil Mehta
Quoted 56 lines · Sohil Mehta

X86_FEATURE_CONSTANT_TSC is a Linux-defined, synthesized feature flag. It is used across several vendors. Intel CPUs will set the feature when the architectural CPUID.80000007.EDX[1] bit is set. There are also some Intel CPUs that have the X86_FEATURE_CONSTANT_TSC behavior but don't enumerate it with the architectural bit.  Those currently have a model range check.

Today, virtually all of the CPUs that have the CPUID bit *also* match the "model >= 0x0e" check. This is confusing. Instead of an open-ended check, pick some models (INTEL_IVYBRIDGE and P4_WILLAMETTE) as the end of goofy CPUs that should enumerate the bit but don't.  These models are relatively arbitrary but conservative pick for this.

This makes it obvious that later CPUs (like Family 18+) no longer need to synthesize X86_FEATURE_CONSTANT_TSC.

---
v3: Make the non-architectural model checks more explicit. Improve commit message.

v2: No change.
---
 arch/x86/kernel/cpu/intel.c | 10 ++++++----

 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/intel.c +0 -0
index fc68561d9f92..4fbc5465ca67 100644
@@ -210,10 +210,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
  {
  	u64 misc_enable;

arch/x86/kernel/cpu/intel.c +0 -4
-	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
-		(c->x86 == 0x6 && c->x86_model >= 0x0e))
-		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-

  if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) c->microcode = intel_get_microcode_revision();

arch/x86/kernel/cpu/intel.c +6 -0
@@ -266,10 +262,16 @@ static void early_init_intel(struct cpuinfo_x86 *c)
  	 *
  	 * It is also reliable across cores and sockets. (but not across
  	 * cabinets - we turn it off in that case explicitly.)
+	 *
+	 * Use a model-specific check for some older CPUs that have invariant
+	 * TSC but may not report it architecturally via 8000_0007.
  	 */
  	if (c->x86_power & (1 << 8)) {
  		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
  		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+	} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
+		   (c->x86_vfm >= INTEL_CORE_YONAH  && c->x86_vfm <= INTEL_IVYBRIDGE)) {
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
  	}
Quoted 2 lines


  /* Penwell and Cloverview have the TSC which doesn't sleep on S3 */

Hm. My test host is INTEL_HASWELL_X (0x63f). For reasons which are unclear to me, QEMU doesn't set bit 8 of 0x80000007 EDX unless I explicitly append ',+invtsc' to the existing '-cpu host' on its command line. So now my guest doesn't think it has X86_FEATURE_CONSTANT_TSC.

For reasons I also don't understand, for a Xen (in qemu/kvm) guest this results in about a four-second delay when bringing up each vCPU. Timestamps added to QEMU's stdout because the kernel's own timestamps are lying...

1755781767: [    0.489434] smp: Bringing up secondary CPUs ...
1755781767: [    0.489434] installing Xen timer for CPU 1
1755781767: [    0.489434] smpboot: x86: Booting SMP configuration:
1755781767: [    0.489434] .... node  #0, CPUs:          #1
1755781767: [    0.489434] installing Xen timer for CPU 2
1755781767: [    0.489434]    #2
1755781767: [    0.489434] installing Xen timer for CPU 3
1755781767: [    0.489434]    #3
1755781771: [    0.489434] cpu 1 spinlock event irq 45
1755781775: [    0.544262] cpu 2 spinlock event irq 46
1755781779: [    0.604306] cpu 3 spinlock event irq 47
1755781779: [    0.604792] smp: Brought up 1 node, 4 CPUs
1755781779: [    0.604792] smpboot: Total of 4 processors activated (1034118.38 BogoMIPS)
#42 lore raw

Re: [PATCH v3 13/15] x86/cpu/intel: Bound the non-architectural constant_tsc model checks

Quoted 5 lines · David Woodhouse

Hm. My test host is INTEL_HASWELL_X (0x63f). For reasons which are unclear to me, QEMU doesn't set bit 8 of 0x80000007 EDX unless I explicitly append ',+invtsc' to the existing '-cpu host' on its command line. So now my guest doesn't think it has X86_FEATURE_CONSTANT_TSC.

Haswell should have X86_FEATURE_CONSTANT_TSC, so I would have expected the guest bit to be set. Until now, X86_FEATURE_CONSTANT_TSC was set based on the Family-model instead of the CPUID enumeration which may have hid the issue.

From my initial look at the QEMU implementation, this seems intentional.

QEMU considers Invariant TSC as un-migratable which prevents it from being exposed to migratable guests (default). target/i386/cpu.c:
[FEAT_8000_0007_EDX]
.unmigratable_flags = CPUID_APM_INVTSC,

Can you please try '-cpu host,migratable=off'?

#43 lore raw

Re: [PATCH v3 13/15] x86/cpu/intel: Bound the non-architectural constant_tsc model checks

Quoted 8 lines · Sohil Mehta
Quoted 5 lines · David Woodhouse

Hm. My test host is INTEL_HASWELL_X (0x63f). For reasons which are unclear to me, QEMU doesn't set bit 8 of 0x80000007 EDX unless I explicitly append ',+invtsc' to the existing '-cpu host' on its command line. So now my guest doesn't think it has X86_FEATURE_CONSTANT_TSC.

Quoted 5 lines

Haswell should have X86_FEATURE_CONSTANT_TSC, so I would have expected the guest bit to be set. Until now, X86_FEATURE_CONSTANT_TSC was set based on the Family-model instead of the CPUID enumeration which may have hid the issue.

Correction:
s/instead/as well as

Quoted 9 lines

From my initial look at the QEMU implementation, this seems intentional.

QEMU considers Invariant TSC as un-migratable which prevents it from being exposed to migratable guests (default). target/i386/cpu.c:
[FEAT_8000_0007_EDX]
.unmigratable_flags = CPUID_APM_INVTSC,

Can you please try '-cpu host,migratable=off'?

This is mainly to verify. If confirmed, I am not sure what the long term solution should be.

#44 lore raw

Re: [PATCH v3 13/15] x86/cpu/intel: Bound the non-architectural constant_tsc model checks

Quoted 26 lines · Sohil Mehta
Quoted 8 lines · Sohil Mehta
Quoted 5 lines · David Woodhouse

Hm. My test host is INTEL_HASWELL_X (0x63f). For reasons which are unclear to me, QEMU doesn't set bit 8 of 0x80000007 EDX unless I explicitly append ',+invtsc' to the existing '-cpu host' on its command line. So now my guest doesn't think it has X86_FEATURE_CONSTANT_TSC.

Quoted 5 lines

Haswell should have X86_FEATURE_CONSTANT_TSC, so I would have expected the guest bit to be set. Until now, X86_FEATURE_CONSTANT_TSC was set based on the Family-model instead of the CPUID enumeration which may have hid the issue.

Correction:
s/instead/as well as

Quoted 8 lines

From my initial look at the QEMU implementation, this seems intentional.

QEMU considers Invariant TSC as un-migratable which prevents it from being exposed to migratable guests (default). target/i386/cpu.c:
[FEAT_8000_0007_EDX]
         .unmigratable_flags = CPUID_APM_INVTSC,

Quoted 4 lines
Quoted 1 line

Can you please try '-cpu host,migratable=off'?

This is mainly to verify. If confirmed, I am not sure what the long term solution should be.

Yes, explicitly turning it on with -cpu host,+invtsc does work.

I've been looking into why it takes a Xen guest four seconds per vCPU in this case, but not a KVM guest.

When running as a KVM guest, Linux will infer the TSC frequency from the KVM clock — or better still, from CPUID; see
https://lore.kernel.org/all/[email protected]
and/or
https://lore.kernel.org/all/[email protected]

As a Xen guest though, Linux doesn't do that. This patch in the guest should make it work without recalibrating the TSC for each vCPU...

arch/x86/xen/time.c +9 -4
@@ -489,7 +489,15 @@ static void xen_setup_vsyscall_time_info(void)
  */
 static int __init xen_tsc_safe_clocksource(void)
 {
-       u32 eax, ebx, ecx, edx;
+       u32 eax, ebx, ecx, edx;
+       u64 lpj;
+
+       /* Leaf 4, sub-leaf 0 (0x40000x03) */
+       cpuid_count(xen_cpuid_base() + 3, 0, &eax, &ebx, &ecx, &edx);
+
+       lpj = ((u64)ecx * 1000);
+       do_div(lpj, HZ);
+       preset_lpj = lpj;
 
        if (!(boot_cpu_has(X86_FEATURE_CONSTANT_TSC)))
                return 0;
@@ -500,9 +508,6 @@ static int __init xen_tsc_safe_clocksource(void)
        if (check_tsc_unstable())
                return 0;
 
-       /* Leaf 4, sub-leaf 0 (0x40000x03) */
-       cpuid_count(xen_cpuid_base() + 3, 0, &eax, &ebx, &ecx, &edx);
-
        return ebx == XEN_CPUID_TSC_MODE_NEVER_EMULATE;
 }
 

... but then I got slightly distracted by the question of why I was getting *nonsense* in those values, and why KVM is 'correcting' EAX in subleaf 2 which is supposed to be the *host* TSC, not ECX in subleaf zero...

Under the Fedora 6.13.8-200 kernel I'm fairly sure the guest was seeing values in subleaf 0 ECX/EDX that *should* have been in subleaf 1 ECX/EDX, and that problem went away when I rebooted the host into a mainline kernel. Will have to go back and retest that part...

#45 lore raw

Re: [PATCH v3 13/15] x86/cpu/intel: Bound the non-architectural constant_tsc model checks

In reply to Sohil Mehta
Quoted 26 lines · Sohil Mehta
Quoted 8 lines · Sohil Mehta
Quoted 5 lines · David Woodhouse

Hm. My test host is INTEL_HASWELL_X (0x63f). For reasons which are unclear to me, QEMU doesn't set bit 8 of 0x80000007 EDX unless I explicitly append ',+invtsc' to the existing '-cpu host' on its command line. So now my guest doesn't think it has X86_FEATURE_CONSTANT_TSC.

Quoted 5 lines

Haswell should have X86_FEATURE_CONSTANT_TSC, so I would have expected the guest bit to be set. Until now, X86_FEATURE_CONSTANT_TSC was set based on the Family-model instead of the CPUID enumeration which may have hid the issue.

Correction:
s/instead/as well as

Quoted 8 lines

From my initial look at the QEMU implementation, this seems intentional.

QEMU considers Invariant TSC as un-migratable which prevents it from being exposed to migratable guests (default). target/i386/cpu.c:
[FEAT_8000_0007_EDX]
.unmigratable_flags = CPUID_APM_INVTSC,

Quoted 4 lines
Quoted 1 line

Can you please try '-cpu host,migratable=off'?

This is mainly to verify. If confirmed, I am not sure what the long term solution should be.

yeah. It's the intentional behavior of QEMU.

Invariant TSC is ummigratable unless users explicitly configures the TSC frequency, e.g., "-cpu host,tsc-frequency=xxx". Because the TSC frequency is by default the host's frequency if no "tsc-frequency" specified, and it will change when the VM is migrated to a host with a different TSC frequency.

It's the specific behavior/rule of QEMU. We just need to keep it in mind. If we want to expose invariant TSC to the guest with QEMU's "-cpu host", we can either:
1) explicitly configure the "tsc-frequency", or
2) explicitly turn off "migratable"

#46 lore raw

Re: [PATCH v3 13/15] x86/cpu/intel: Bound the non-architectural constant_tsc model checks

Quoted 40 lines · Xiaoyao Li
Quoted 26 lines · Sohil Mehta
Quoted 8 lines · Sohil Mehta
Quoted 5 lines · David Woodhouse

Hm. My test host is INTEL_HASWELL_X (0x63f). For reasons which are unclear to me, QEMU doesn't set bit 8 of 0x80000007 EDX unless I explicitly append ',+invtsc' to the existing '-cpu host' on its command line. So now my guest doesn't think it has X86_FEATURE_CONSTANT_TSC.

Quoted 5 lines

Haswell should have X86_FEATURE_CONSTANT_TSC, so I would have expected the guest bit to be set. Until now, X86_FEATURE_CONSTANT_TSC was set based on the Family-model instead of the CPUID enumeration which may have hid the issue.

Correction:
s/instead/as well as

Quoted 8 lines

From my initial look at the QEMU implementation, this seems intentional.

QEMU considers Invariant TSC as un-migratable which prevents it from being exposed to migratable guests (default). target/i386/cpu.c:
[FEAT_8000_0007_EDX]
.unmigratable_flags = CPUID_APM_INVTSC,

Quoted 4 lines
Quoted 1 line

Can you please try '-cpu host,migratable=off'?

This is mainly to verify. If confirmed, I am not sure what the long term solution should be.

yeah. It's the intentional behavior of QEMU.

Invariant TSC is ummigratable unless users explicitly configures the TSC frequency, e.g., "-cpu host,tsc-frequency=xxx". Because the TSC frequency is by default the host's frequency if no "tsc-frequency" specified, and it will change when the VM is migrated to a host with a different TSC frequency.

Quoted 5 lines

It's the specific behavior/rule of QEMU. We just need to keep it in mind. If we want to expose invariant TSC to the guest with QEMU's "-cpu host", we can either:
1) explicitly configure the "tsc-frequency", or
2) explicitly turn off "migratable"

Could the TSC frequency be included in the migration stream?

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
#47 lore raw

PATCH v3 14/15 perf/x86: Simplify Intel PMU initialization

In reply to Sohil Mehta

Architectural Perfmon was introduced on the Family 6 "Core" processors starting with Yonah. Processors before Yonah need their own customized PMU initialization.

p6_pmu_init() is expected to provide that initialization for early Family 6 processors. But, due to the unrestricted call to p6_pmu_init(), it could get called for any Family 6 processor if the architectural perfmon feature is disabled on that processor.

To simplify, restrict the call to p6_pmu_init() to early Family 6 processors that do not have architectural perfmon support. As a result, the "unsupported" console print becomes practically unreachable because all the released P6 processors are covered by the switch cases.

Move the console print to a common location where it can cover all modern processors that do not have architectural perfmon support.

Also, use this opportunity to get rid of the unnecessary switch cases in p6_pmu_init(). Only the Pentium Pro processor needs a quirk, and the rest of the processors do not need any special handling. The gaps in the case numbers are only due to no processor with those model numbers being released.

Converting to a VFM based check gets rid of one last few Intel x86_model comparisons.

---
v3: Restrict calling p6_pmu_init() to only when needed.
Move the console print to a common location.

v2: No change.

---
 arch/x86/events/intel/core.c | 16 +++++++++++-----
 arch/x86/events/intel/p6.c   | 26 +++-----------------------
 2 files changed, 14 insertions(+), 28 deletions(-)
arch/x86/events/intel/core.c +11 -5
index 7601196d1d18..c645d8c8ab87 100644
@@ -6466,16 +6466,22 @@ __init int intel_pmu_init(void)
 	char *name;
 	struct x86_hybrid_pmu *pmu;
 
+	/* Architectural Perfmon was introduced starting with INTEL_CORE_YONAH */
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
 		switch (boot_cpu_data.x86) {
-		case 0x6:
-			return p6_pmu_init();
-		case 0xb:
+		case 6:
+			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
+				return p6_pmu_init();
+			break;
+		case 11:
 			return knc_pmu_init();
-		case 0xf:
+		case 15:
 			return p4_pmu_init();
+		default:
+			pr_cont("unsupported CPU family %d model %d ",
+				boot_cpu_data.x86, boot_cpu_data.x86_model);
+			return -ENODEV;
 		}
-		return -ENODEV;
 	}
 
 	/*
arch/x86/events/intel/p6.c +3 -23
index a6cffb4f4ef5..65b45e9d7016 100644
@@ -2,6 +2,8 @@
 #include <linux/perf_event.h>
 #include <linux/types.h>
 
+#include <asm/cpu_device_id.h>
+
 #include "../perf_event.h"
 
 /*
@@ -248,30 +250,8 @@ __init int p6_pmu_init(void)
 {
 	x86_pmu = p6_pmu;
 
-	switch (boot_cpu_data.x86_model) {
-	case  1: /* Pentium Pro */
+	if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO)
 		x86_add_quirk(p6_pmu_rdpmc_quirk);
-		break;
-
-	case  3: /* Pentium II - Klamath */
-	case  5: /* Pentium II - Deschutes */
-	case  6: /* Pentium II - Mendocino */
-		break;
-
-	case  7: /* Pentium III - Katmai */
-	case  8: /* Pentium III - Coppermine */
-	case 10: /* Pentium III Xeon */
-	case 11: /* Pentium III - Tualatin */
-		break;
-
-	case  9: /* Pentium M - Banias */
-	case 13: /* Pentium M - Dothan */
-		break;
-
-	default:
-		pr_cont("unsupported p6 CPU model %d ", boot_cpu_data.x86_model);
-		return -ENODEV;
-	}
 
 	memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
 		sizeof(hw_cache_event_ids));
Signature · 1 line
2.43.0
#48 lore raw

Re: [PATCH v3 14/15] perf/x86: Simplify Intel PMU initialization

Quoted 45 lines · Sohil Mehta

Architectural Perfmon was introduced on the Family 6 "Core" processors starting with Yonah. Processors before Yonah need their own customized PMU initialization.

p6_pmu_init() is expected to provide that initialization for early Family 6 processors. But, due to the unrestricted call to p6_pmu_init(), it could get called for any Family 6 processor if the architectural perfmon feature is disabled on that processor.

To simplify, restrict the call to p6_pmu_init() to early Family 6 processors that do not have architectural perfmon support. As a result, the "unsupported" console print becomes practically unreachable because all the released P6 processors are covered by the switch cases.

Move the console print to a common location where it can cover all modern processors that do not have architectural perfmon support.

Also, use this opportunity to get rid of the unnecessary switch cases in p6_pmu_init(). Only the Pentium Pro processor needs a quirk, and the rest of the processors do not need any special handling. The gaps in the case numbers are only due to no processor with those model numbers being released.

Converting to a VFM based check gets rid of one last few Intel x86_model comparisons.

---
v3: Restrict calling p6_pmu_init() to only when needed.
Move the console print to a common location.

v2: No change.

---
 arch/x86/events/intel/core.c | 16 +++++++++++-----
 arch/x86/events/intel/p6.c   | 26 +++-----------------------
 2 files changed, 14 insertions(+), 28 deletions(-)
arch/x86/events/intel/core.c +0 -0
index 7601196d1d18..c645d8c8ab87 100644
@@ -6466,16 +6466,22 @@ __init int intel_pmu_init(void)
 	char *name;
 	struct x86_hybrid_pmu *pmu;
 

arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 6475

Quoted 10 lines
arch/x86/events/intel/core.c +5 -3
+	/* Architectural Perfmon was introduced starting with INTEL_CORE_YONAH */
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
 		switch (boot_cpu_data.x86) {
-		case 0x6:
-			return p6_pmu_init();
-		case 0xb:
+		case 6:
+			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
+				return p6_pmu_init();
+			break;

We may need a return -ENODEV here.

I think it's possible that some weird hypervisor doesn't enumerate the ARCH_PERFMON for a modern CPU. Perf should not touch the leaf 10 if the ARCH_PERFMON is not supported.

Thanks,
Kan

Quoted 59 lines
arch/x86/events/intel/core.c +6 -2
+		case 11:
 			return knc_pmu_init();
-		case 0xf:
+		case 15:
 			return p4_pmu_init();
+		default:
+			pr_cont("unsupported CPU family %d model %d ",
+				boot_cpu_data.x86, boot_cpu_data.x86_model);
+			return -ENODEV;
 		}
-		return -ENODEV;
 	}
 
 	/*
arch/x86/events/intel/p6.c +3 -23
index a6cffb4f4ef5..65b45e9d7016 100644
@@ -2,6 +2,8 @@
 #include <linux/perf_event.h>
 #include <linux/types.h>
 
+#include <asm/cpu_device_id.h>
+
 #include "../perf_event.h"
 
 /*
@@ -248,30 +250,8 @@ __init int p6_pmu_init(void)
 {
 	x86_pmu = p6_pmu;
 
-	switch (boot_cpu_data.x86_model) {
-	case  1: /* Pentium Pro */
+	if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO)
 		x86_add_quirk(p6_pmu_rdpmc_quirk);
-		break;
-
-	case  3: /* Pentium II - Klamath */
-	case  5: /* Pentium II - Deschutes */
-	case  6: /* Pentium II - Mendocino */
-		break;
-
-	case  7: /* Pentium III - Katmai */
-	case  8: /* Pentium III - Coppermine */
-	case 10: /* Pentium III Xeon */
-	case 11: /* Pentium III - Tualatin */
-		break;
-
-	case  9: /* Pentium M - Banias */
-	case 13: /* Pentium M - Dothan */
-		break;
-
-	default:
-		pr_cont("unsupported p6 CPU model %d ", boot_cpu_data.x86_model);
-		return -ENODEV;
-	}
 
 	memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
 		sizeof(hw_cache_event_ids));
#49 lore raw

Re: [PATCH v3 14/15] perf/x86: Simplify Intel PMU initialization

Quoted 48 lines · Kan
Quoted 45 lines · Sohil Mehta

Architectural Perfmon was introduced on the Family 6 "Core" processors starting with Yonah. Processors before Yonah need their own customized PMU initialization.

p6_pmu_init() is expected to provide that initialization for early Family 6 processors. But, due to the unrestricted call to p6_pmu_init(), it could get called for any Family 6 processor if the architectural perfmon feature is disabled on that processor.

To simplify, restrict the call to p6_pmu_init() to early Family 6 processors that do not have architectural perfmon support. As a result, the "unsupported" console print becomes practically unreachable because all the released P6 processors are covered by the switch cases.

Move the console print to a common location where it can cover all modern processors that do not have architectural perfmon support.

Also, use this opportunity to get rid of the unnecessary switch cases in p6_pmu_init(). Only the Pentium Pro processor needs a quirk, and the rest of the processors do not need any special handling. The gaps in the case numbers are only due to no processor with those model numbers being released.

Converting to a VFM based check gets rid of one last few Intel x86_model comparisons.

---
v3: Restrict calling p6_pmu_init() to only when needed.
Move the console print to a common location.

v2: No change.

---
 arch/x86/events/intel/core.c | 16 +++++++++++-----
 arch/x86/events/intel/p6.c   | 26 +++-----------------------
 2 files changed, 14 insertions(+), 28 deletions(-)
arch/x86/events/intel/core.c +0 -0
index 7601196d1d18..c645d8c8ab87 100644
@@ -6466,16 +6466,22 @@ __init int intel_pmu_init(void)
 	char *name;
 	struct x86_hybrid_pmu *pmu;
 
Quoted 13 lines

arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 6475

Quoted 10 lines
arch/x86/events/intel/core.c +5 -3
+	/* Architectural Perfmon was introduced starting with INTEL_CORE_YONAH */
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
 		switch (boot_cpu_data.x86) {
-		case 0x6:
-			return p6_pmu_init();
-		case 0xb:
+		case 6:
+			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
+				return p6_pmu_init();
+			break;

We may need a return -ENODEV here.

That makes sense. See below.

Quoted 7 lines

I think it's possible that some weird hypervisor doesn't enumerate the ARCH_PERFMON for a modern CPU. Perf should not touch the leaf 10 if the ARCH_PERFMON is not supported.

Thanks,
Kan

Quoted 13 lines

arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 6486

Quoted 13 lines
arch/x86/events/intel/core.c +6 -2
+		case 11:
 			return knc_pmu_init();
-		case 0xf:
+		case 15:
 			return p4_pmu_init();
+		default:
+			pr_cont("unsupported CPU family %d model %d ",
+				boot_cpu_data.x86, boot_cpu_data.x86_model);
+			return -ENODEV;
 		}
-		return -ENODEV;
 	}
 

How about moving the default case out of the switch statement as shown? That would make sure that the unsupported print would also get included with the -ENODEV.

	/* Architectural Perfmon was introduced starting with INTEL_CORE_YONAH */
	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
		switch (boot_cpu_data.x86) {
		case 6:
			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
				return p6_pmu_init();
			break;
		case 11:
			return knc_pmu_init();
		case 15:
			return p4_pmu_init();
		}

		pr_cont("unsupported CPU family %d model %d ",
			boot_cpu_data.x86, boot_cpu_data.x86_model);
		return -ENODEV;
	}
Reviewed-by
#50 lore raw

Re: [PATCH v3 14/15] perf/x86: Simplify Intel PMU initialization

Quoted 100 lines · Sohil Mehta
Quoted 48 lines · Kan
Quoted 45 lines · Sohil Mehta

Architectural Perfmon was introduced on the Family 6 "Core" processors starting with Yonah. Processors before Yonah need their own customized PMU initialization.

p6_pmu_init() is expected to provide that initialization for early Family 6 processors. But, due to the unrestricted call to p6_pmu_init(), it could get called for any Family 6 processor if the architectural perfmon feature is disabled on that processor.

To simplify, restrict the call to p6_pmu_init() to early Family 6 processors that do not have architectural perfmon support. As a result, the "unsupported" console print becomes practically unreachable because all the released P6 processors are covered by the switch cases.

Move the console print to a common location where it can cover all modern processors that do not have architectural perfmon support.

Also, use this opportunity to get rid of the unnecessary switch cases in p6_pmu_init(). Only the Pentium Pro processor needs a quirk, and the rest of the processors do not need any special handling. The gaps in the case numbers are only due to no processor with those model numbers being released.

Converting to a VFM based check gets rid of one last few Intel x86_model comparisons.

---
v3: Restrict calling p6_pmu_init() to only when needed.
Move the console print to a common location.

v2: No change.

---
 arch/x86/events/intel/core.c | 16 +++++++++++-----
 arch/x86/events/intel/p6.c   | 26 +++-----------------------
 2 files changed, 14 insertions(+), 28 deletions(-)
arch/x86/events/intel/core.c +0 -0
index 7601196d1d18..c645d8c8ab87 100644
@@ -6466,16 +6466,22 @@ __init int intel_pmu_init(void)
 	char *name;
 	struct x86_hybrid_pmu *pmu;
 
Quoted 13 lines

arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 6475

Quoted 10 lines
arch/x86/events/intel/core.c +5 -3
+	/* Architectural Perfmon was introduced starting with INTEL_CORE_YONAH */
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
 		switch (boot_cpu_data.x86) {
-		case 0x6:
-			return p6_pmu_init();
-		case 0xb:
+		case 6:
+			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
+				return p6_pmu_init();
+			break;

We may need a return -ENODEV here.

That makes sense. See below.

Quoted 7 lines

I think it's possible that some weird hypervisor doesn't enumerate the ARCH_PERFMON for a modern CPU. Perf should not touch the leaf 10 if the ARCH_PERFMON is not supported.

Thanks,
Kan

Quoted 13 lines

arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 6486

Quoted 13 lines
arch/x86/events/intel/core.c +6 -2
+		case 11:
 			return knc_pmu_init();
-		case 0xf:
+		case 15:
 			return p4_pmu_init();
+		default:
+			pr_cont("unsupported CPU family %d model %d ",
+				boot_cpu_data.x86, boot_cpu_data.x86_model);
+			return -ENODEV;
 		}
-		return -ENODEV;
 	}
 

How about moving the default case out of the switch statement as shown? That would make sure that the unsupported print would also get included with the -ENODEV.

	/* Architectural Perfmon was introduced starting with INTEL_CORE_YONAH */
	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
		switch (boot_cpu_data.x86) {
		case 6:
			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
				return p6_pmu_init();
			break;
		case 11:
			return knc_pmu_init();
Quoted 8 lines
		case 15:
			return p4_pmu_init();
		}

		pr_cont("unsupported CPU family %d model %d ",
			boot_cpu_data.x86, boot_cpu_data.x86_model);
		return -ENODEV;
	}

It looks good to me.

With the above change,

Thanks,
Kan

#51 lore raw

PATCH v3 14/15 perf/x86: Simplify Intel PMU initialization

In reply to Sohil Mehta

Architectural Perfmon was introduced on the Family 6 "Core" processors starting with Yonah. Processors before Yonah need their own customized PMU initialization.

p6_pmu_init() is expected to provide that initialization for early Family 6 processors. But, currently, it could get called for any Family 6 processor if the architectural perfmon feature is disabled on that processor. To simplify, restrict the P6 PMU initialization to early Family 6 processors that do not have architectural perfmon support and truly need the special handling.

As a result, the "unsupported" console print becomes practically unreachable because all the released P6 processors are covered by the switch cases. Move the console print to a common location where it can cover all modern processors (including Family >15) that may not have architectural perfmon support enumerated.

Also, use this opportunity to get rid of the unnecessary switch cases in P6 initialization. Only the Pentium Pro processor needs a quirk, and the rest of the processors do not need any special handling. The gaps in the case numbers are only due to no processor with those model numbers being released.

Use decimal numbers for Intel Family numbers. Also, convert one of the last few Intel x86_model comparison to a VFM based one.

---
Sending an updated version for this one since it's the only one with a change. This would make it feasible to pickup the entire patchset in this cycle if desired.

v3.1: Move the default case outside of the switch.
Pickup the Reviewed-by tag from Kan Liang.

v3: Restrict calling p6_pmu_init() to only when needed.
Move the console print to a common location.

v2: No change.

---
 arch/x86/events/intel/core.c | 14 ++++++++++----
 arch/x86/events/intel/p6.c   | 26 +++-----------------------
 2 files changed, 13 insertions(+), 27 deletions(-)
arch/x86/events/intel/core.c +10 -4
index 7601196d1d18..ef59643a9d23 100644
@@ -6466,15 +6466,21 @@ __init int intel_pmu_init(void)
 	char *name;
 	struct x86_hybrid_pmu *pmu;
 
+	/* Architectural Perfmon was introduced starting with Core "Yonah" */
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
 		switch (boot_cpu_data.x86) {
-		case 0x6:
-			return p6_pmu_init();
-		case 0xb:
+		case 6:
+			if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH)
+				return p6_pmu_init();
+			break;
+		case 11:
 			return knc_pmu_init();
-		case 0xf:
+		case 15:
 			return p4_pmu_init();
 		}
+
+		pr_cont("unsupported CPU family %d model %d ",
+			boot_cpu_data.x86, boot_cpu_data.x86_model);
 		return -ENODEV;
 	}
 
arch/x86/events/intel/p6.c +3 -23
index a6cffb4f4ef5..65b45e9d7016 100644
@@ -2,6 +2,8 @@
 #include <linux/perf_event.h>
 #include <linux/types.h>
 
+#include <asm/cpu_device_id.h>
+
 #include "../perf_event.h"
 
 /*
@@ -248,30 +250,8 @@ __init int p6_pmu_init(void)
 {
 	x86_pmu = p6_pmu;
 
-	switch (boot_cpu_data.x86_model) {
-	case  1: /* Pentium Pro */
+	if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO)
 		x86_add_quirk(p6_pmu_rdpmc_quirk);
-		break;
-
-	case  3: /* Pentium II - Klamath */
-	case  5: /* Pentium II - Deschutes */
-	case  6: /* Pentium II - Mendocino */
-		break;
-
-	case  7: /* Pentium III - Katmai */
-	case  8: /* Pentium III - Coppermine */
-	case 10: /* Pentium III Xeon */
-	case 11: /* Pentium III - Tualatin */
-		break;
-
-	case  9: /* Pentium M - Banias */
-	case 13: /* Pentium M - Dothan */
-		break;
-
-	default:
-		pr_cont("unsupported p6 CPU model %d ", boot_cpu_data.x86_model);
-		return -ENODEV;
-	}
 
 	memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
 		sizeof(hw_cache_event_ids));
Signature · 1 line
2.43.0
#52 lore raw

PATCH v3 15/15 perf/x86/p4: Replace Pentium 4 model checks with VFM ones

In reply to Sohil Mehta

Introduce names for some old pentium 4 models and replace x86_model checks with VFM ones.

---
v3: No change.
v2: No change.

---
 arch/x86/events/intel/p4.c          | 7 ++++---
 arch/x86/include/asm/intel-family.h | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/events/intel/p4.c +4 -3
index 844bc4fc4724..fb726c6fc6e7 100644
@@ -10,6 +10,7 @@
 #include <linux/perf_event.h>
 
 #include <asm/perf_event_p4.h>
+#include <asm/cpu_device_id.h>
 #include <asm/hardirq.h>
 #include <asm/apic.h>
 
@@ -732,9 +733,9 @@ static bool p4_event_match_cpu_model(unsigned int event_idx)
 {
 	/* INSTR_COMPLETED event only exist for model 3, 4, 6 (Prescott) */
 	if (event_idx == P4_EVENT_INSTR_COMPLETED) {
-		if (boot_cpu_data.x86_model != 3 &&
-			boot_cpu_data.x86_model != 4 &&
-			boot_cpu_data.x86_model != 6)
+		if (boot_cpu_data.x86_vfm != INTEL_P4_PRESCOTT &&
+		    boot_cpu_data.x86_vfm != INTEL_P4_PRESCOTT_2M &&
+		    boot_cpu_data.x86_vfm != INTEL_P4_CEDARMILL)
 			return false;
 	}
 
arch/x86/include/asm/intel-family.h +1 -0
index 6621d796bb3d..89cb545d521b 100644
@@ -193,6 +193,7 @@
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+#define INTEL_P4_PRESCOTT_2M		IFM(15, 0x04)
 #define INTEL_P4_CEDARMILL		IFM(15, 0x06) /* Also Xeon Dempsey */
 
 /* Family 19 */
Signature · 1 line
2.43.0
Reviewed-by on v3 15/15
#53 lore raw

Re: [PATCH v3 15/15] perf/x86/p4: Replace Pentium 4 model checks with VFM ones

Quoted 4 lines · Sohil Mehta

Introduce names for some old pentium 4 models and replace x86_model checks with VFM ones.

Thanks,
Kan

Quoted 45 lines

---
v3: No change.
v2: No change.

---
 arch/x86/events/intel/p4.c          | 7 ++++---
 arch/x86/include/asm/intel-family.h | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/events/intel/p4.c +4 -3
index 844bc4fc4724..fb726c6fc6e7 100644
@@ -10,6 +10,7 @@
 #include <linux/perf_event.h>
 
 #include <asm/perf_event_p4.h>
+#include <asm/cpu_device_id.h>
 #include <asm/hardirq.h>
 #include <asm/apic.h>
 
@@ -732,9 +733,9 @@ static bool p4_event_match_cpu_model(unsigned int event_idx)
 {
 	/* INSTR_COMPLETED event only exist for model 3, 4, 6 (Prescott) */
 	if (event_idx == P4_EVENT_INSTR_COMPLETED) {
-		if (boot_cpu_data.x86_model != 3 &&
-			boot_cpu_data.x86_model != 4 &&
-			boot_cpu_data.x86_model != 6)
+		if (boot_cpu_data.x86_vfm != INTEL_P4_PRESCOTT &&
+		    boot_cpu_data.x86_vfm != INTEL_P4_PRESCOTT_2M &&
+		    boot_cpu_data.x86_vfm != INTEL_P4_CEDARMILL)
 			return false;
 	}
 
arch/x86/include/asm/intel-family.h +1 -0
index 6621d796bb3d..89cb545d521b 100644
@@ -193,6 +193,7 @@
 /* Family 15 - NetBurst */
 #define INTEL_P4_WILLAMETTE		IFM(15, 0x01) /* Also Xeon Foster */
 #define INTEL_P4_PRESCOTT		IFM(15, 0x03)
+#define INTEL_P4_PRESCOTT_2M		IFM(15, 0x04)
 #define INTEL_P4_CEDARMILL		IFM(15, 0x06) /* Also Xeon Dempsey */
 
 /* Family 19 */
#54 lore raw
In reply to Sohil Mehta
Quoted 9 lines · Sohil Mehta

---Summary---
Mainstream Intel processors have been using Family 6 for a couple of decades. This series is an audit of all the arch/x86 Intel Family-model checks to get ready for the upcoming Family 18 and 19 models. It also converts the last reamaining Intel x86_model checks to VFM ones.

Patch 1-8 : Include Dave Hansen's Acked-by.
Patch 9-15: Almost ready to merge but don't have review tags yet.

Is there any additional feedback?

Most patches have review tags now or are simple enough that they might not need one. Patch 11 can probably use another look.

Patch 14 is the only one that has a minor change. Seeking additional input before spinning another revision.

Quoted 31 lines

---v3 changes---
* Reordered the patches and moved the Acked ones to the front since they are likely to get applied sooner.
* Patches 11 and 14 have a slightly different approach now.
* Improved commit messages overall.
* Dropped the drivers/ fixes. Will post them separately.

---Previous versions---
Refer the v2 cover letter for more background.

v2: https://lore.kernel.org/lkml/[email protected]/
RFC-v1: https://lore.kernel.org/lkml/[email protected]/

Sohil Mehta (15):
x86/apic: Fix 32-bit APIC initialization for extended Intel Families x86/cpu/intel: Fix the movsl alignment preference for extended
Families
x86/microcode: Update the Intel processor flag scan check x86/mtrr: Modify a x86_model check to an Intel VFM check x86/cpu/intel: Replace early Family 6 checks with VFM ones x86/cpu/intel: Replace Family 15 checks with VFM ones x86/cpu/intel: Replace Family 5 model checks with VFM ones x86/acpi/cstate: Improve Intel Family model checks x86/smpboot: Remove confusing quirk usage in INIT delay x86/smpboot: Fix INIT delay assignment for extended Intel Families x86/cpu/intel: Fix fast string initialization for extended Families x86/pat: Replace Intel x86_model checks with VFM ones x86/cpu/intel: Bound the non-architectural constant_tsc model checks perf/x86: Simplify Intel PMU initialization
perf/x86/p4: Replace Pentium 4 model checks with VFM ones

#55 lore raw
Quoted 7 lines · Sohil Mehta
Quoted 6 lines · Sohil Mehta

---Summary---
Mainstream Intel processors have been using Family 6 for a couple of decades. This series is an audit of all the arch/x86 Intel Family-model checks to get ready for the upcoming Family 18 and 19 models. It also converts the last reamaining Intel x86_model checks to VFM ones.

Quoted 5 lines
Quoted 3 lines

Patch 1-8 : Include Dave Hansen's Acked-by.
Patch 9-15: Almost ready to merge but don't have review tags yet.

Is there any additional feedback?

Looks mostly good to me.

Quoted 2 lines

Most patches have review tags now or are simple enough that they might not need one. Patch 11 can probably use another look.

LGTM, but I've extended the Cc: list to make more people aware.

(I did the same for some of the other patches that could use extra eyes.)

Quoted 2 lines

Patch 14 is the only one that has a minor change. Seeking additional input before spinning another revision.

I've applied the first 13 patches to tip:x86/cpu to help move this along. I fixed a handful of typos, but haven't noticed any functional problems so far, so unless there's problems in -next this might be OK for the merge window. (Famous last words.)

Thanks,

Ingo

#56 lore raw
Quoted 7 lines · Ingo Molnar
Quoted 2 lines

Most patches have review tags now or are simple enough that they might not need one. Patch 11 can probably use another look.

LGTM, but I've extended the Cc: list to make more people aware.

(I did the same for some of the other patches that could use extra eyes.)

Appreciate it.

Quoted 8 lines
Quoted 2 lines

Patch 14 is the only one that has a minor change. Seeking additional input before spinning another revision.

I've applied the first 13 patches to tip:x86/cpu to help move this along. I fixed a handful of typos, but haven't noticed any functional problems so far, so unless there's problems in -next this might be OK for the merge window. (Famous last words.)

Many thanks.. Fingers crossed!

-Sohil

#57 lore raw
Quoted 7 lines · Sohil Mehta
Quoted 5 lines

I've applied the first 13 patches to tip:x86/cpu to help move this along. I fixed a handful of typos, but haven't noticed any functional problems so far, so unless there's problems in -next this might be OK for the merge window. (Famous last words.)

Many thanks.. Fingers crossed!

You are welcome, and please send the remaining patches in a day or so, on top of tip:x86/cpu.

Thanks,

Ingo

#58 lore raw
Quoted 9 lines · Ingo Molnar
Quoted 6 lines · Sohil Mehta
Quoted 5 lines

I've applied the first 13 patches to tip:x86/cpu to help move this along. I fixed a handful of typos, but haven't noticed any functional problems so far, so unless there's problems in -next this might be OK for the merge window. (Famous last words.)

Quoted 5 lines
Quoted 1 line

Many thanks.. Fingers crossed!

You are welcome, and please send the remaining patches in a day or so, on top of tip:x86/cpu.

Sent the v4 series with the couple of leftover patches. When sent, the patches were based on tip:x86/cpu, but that seems to have been merged into x86/core. I have verified that patches apply cleanly on updated tip:x86/core as well.

Sohil

#59 lore raw
Quoted 12 lines · Sohil Mehta
Quoted 11 lines · Ingo Molnar
Quoted 7 lines · Sohil Mehta
Quoted 5 lines

I've applied the first 13 patches to tip:x86/cpu to help move this along. I fixed a handful of typos, but haven't noticed any functional problems so far, so unless there's problems in -next this might be OK for the merge window. (Famous last words.)

Many thanks.. Fingers crossed!

Quoted 7 lines
Quoted 3 lines

You are welcome, and please send the remaining patches in a day or so, on top of tip:x86/cpu.

Sent the v4 series with the couple of leftover patches. When sent, the patches were based on tip:x86/cpu, but that seems to have been merged into x86/core.

Correct, we had to back out a broken patch, and a rebase of a number of patches, including yours, was the cleanest option. It should be the same tree content-wise.

Quoted 2 lines

I have verified that patches apply cleanly on updated tip:x86/core as well.

Thank you!

Ingo