public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH v3] x86/cpu/intel: Fix the constant_tsc model check for Pentium 4s
@ 2025-07-30  4:26 Suchit Karunakaran
  2025-07-30  4:52 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Suchit Karunakaran @ 2025-07-30  4:26 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, hpa, darwi, sohil.mehta, peterz,
	ravi.bangoria
  Cc: skhan, linux-kernel-mentees, linux-kernel, Suchit Karunakaran,
	stable

The logic to synthesize constant_tsc for Pentium 4s (Family 15) is
wrong. Since INTEL_P4_PRESCOTT is numerically greater than
INTEL_P4_WILLAMETTE, the logic always results in false and never sets
X86_FEATURE_CONSTANT_TSC for any Pentium 4 model.
The error was introduced while replacing the x86_model check with a VFM
one. The original check was as follows:
        if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
                (c->x86 == 0x6 && c->x86_model >= 0x0e))
                set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);

Fix the logic to cover all Pentium 4 models from Prescott (model 3) to
Cedarmill (model 6) which is the last model released in Family 15.

Fixes: fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")

Cc: <stable@vger.kernel.org> # v6.15

Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>

---

Changes since v2:
- Improve commit message

Changes since v1:
- Fix incorrect logic

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

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 076eaa41b8c8..6f5bd5dbc249 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -262,7 +262,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 	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) ||
+	} else if ((c->x86_vfm >=  INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_CEDARMILL) ||
 		   (c->x86_vfm >= INTEL_CORE_YONAH  && c->x86_vfm <= INTEL_IVYBRIDGE)) {
 		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 	}
-- 
2.50.1


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

end of thread, other threads:[~2025-07-31 18:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30  4:26 [PATCH v3] x86/cpu/intel: Fix the constant_tsc model check for Pentium 4s Suchit Karunakaran
2025-07-30  4:52 ` Greg KH
2025-07-30  5:35   ` Suchit Karunakaran
2025-07-30  5:55     ` Greg KH
2025-07-30  6:21       ` Suchit Karunakaran
2025-07-30 14:42 ` Sohil Mehta
2025-07-30 14:58   ` Suchit Karunakaran
2025-07-30 15:33     ` Sohil Mehta
2025-07-30 16:27       ` Suchit Karunakaran
2025-07-30 19:29         ` Sohil Mehta
2025-07-31  4:17           ` Suchit Karunakaran
2025-07-31 15:57 ` Dave Hansen
2025-07-31 17:39   ` Suchit Karunakaran
2025-07-31 18:56   ` Sohil Mehta

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