Skip to content

Commit fadb6f5

Browse files
sohilmehIngo Molnar
authored andcommitted
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. Signed-off-by: Sohil Mehta <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 05d234d commit fadb6f5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/x86/kernel/cpu/intel.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
201201
{
202202
u64 misc_enable;
203203

204-
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
205-
(c->x86 == 0x6 && c->x86_model >= 0x0e))
206-
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
207-
208204
if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
209205
c->microcode = intel_get_microcode_revision();
210206

@@ -257,10 +253,16 @@ static void early_init_intel(struct cpuinfo_x86 *c)
257253
*
258254
* It is also reliable across cores and sockets. (but not across
259255
* cabinets - we turn it off in that case explicitly.)
256+
*
257+
* Use a model-specific check for some older CPUs that have invariant
258+
* TSC but may not report it architecturally via 8000_0007.
260259
*/
261260
if (c->x86_power & (1 << 8)) {
262261
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
263262
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
263+
} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
264+
(c->x86_vfm >= INTEL_CORE_YONAH && c->x86_vfm <= INTEL_IVYBRIDGE)) {
265+
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
264266
}
265267

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

0 commit comments

Comments
 (0)