Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer updates from Thomas Gleixner:
"This is the last functional update from the tip tree for 4.10. It got
delayed due to a newly reported and anlyzed variant of BIOS bug and
the resulting wreckage:

- Seperation of TSC being marked realiable and the fact that the
platform provides the TSC frequency via CPUID/MSRs and making use
for it for GOLDMONT.

- TSC adjust MSR validation and sanitizing:

The TSC adjust MSR contains the offset to the hardware counter. The
sum of the adjust MSR and the counter is the TSC value which is
read via RDTSC.

On at least two machines from different vendors the BIOS sets the
TSC adjust MSR to negative values. This happens on cold and warm
boot. While on cold boot the offset is a few milliseconds, on warm
boot it basically compensates the power on time of the system. The
BIOSes are not even using the adjust MSR to set all CPUs in the
package to the same offset. The offsets are different which renders
the TSC unusable,

What's worse is that the TSC deadline timer has a HW feature^Wbug.
It malfunctions when the TSC adjust value is negative or greater
equal 0x80000000 resulting in silent boot failures, hard lockups or
non firing timers. This looks like some hardware internal 32/64bit
issue with a sign extension problem. Intel has been silent so far
on the issue.

The update contains sanity checks and keeps the adjust register
within working limits and in sync on the package.

As it looks like this disease is spreading via BIOS crapware, we
need to address this urgently as the boot failures are hard to
debug for users"

* 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/tsc: Limit the adjust value further
x86/tsc: Annotate printouts as firmware bug
x86/tsc: Force TSC_ADJUST register to value >= zero
x86/tsc: Validate TSC_ADJUST after resume
x86/tsc: Validate cpumask pointer before accessing it
x86/tsc: Fix broken CONFIG_X86_TSC=n build
x86/tsc: Try to adjust TSC if sync test fails
x86/tsc: Prepare warp test for TSC adjustment
x86/tsc: Move sync cleanup to a safe place
x86/tsc: Sync test only for the first cpu in a package
x86/tsc: Verify TSC_ADJUST from idle
x86/tsc: Store and check TSC ADJUST MSR
x86/tsc: Detect random warps
x86/tsc: Use X86_FEATURE_TSC_ADJUST in detect_art()
x86/tsc: Finalize the split of the TSC_RELIABLE flag
x86/tsc: Set TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Atom SoCs
x86/tsc: Mark Intel ATOM_GOLDMONT TSC reliable
x86/tsc: Mark TSC frequency determined by CPUID as known
x86/tsc: Add X86_FEATURE_TSC_KNOWN_FREQ flag

+355 -27
+1
arch/x86/include/asm/cpufeatures.h
··· 105 105 #define X86_FEATURE_AMD_DCM ( 3*32+27) /* multi-node processor */ 106 106 #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */ 107 107 #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */ 108 + #define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */ 108 109 109 110 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ 110 111 #define X86_FEATURE_XMM3 ( 4*32+ 0) /* "pni" SSE-3 */
+9
arch/x86/include/asm/tsc.h
··· 45 45 * Boot-time check whether the TSCs are synchronized across 46 46 * all CPUs/cores: 47 47 */ 48 + #ifdef CONFIG_X86_TSC 49 + extern bool tsc_store_and_check_tsc_adjust(bool bootcpu); 50 + extern void tsc_verify_tsc_adjust(bool resume); 48 51 extern void check_tsc_sync_source(int cpu); 49 52 extern void check_tsc_sync_target(void); 53 + #else 54 + static inline bool tsc_store_and_check_tsc_adjust(bool bootcpu) { return false; } 55 + static inline void tsc_verify_tsc_adjust(bool resume) { } 56 + static inline void check_tsc_sync_source(int cpu) { } 57 + static inline void check_tsc_sync_target(void) { } 58 + #endif 50 59 51 60 extern int notsc_setup(char *); 52 61 extern void tsc_save_sched_clock_state(void);
+1 -1
arch/x86/kernel/Makefile
··· 75 75 obj-$(CONFIG_APM) += apm.o 76 76 obj-$(CONFIG_SMP) += smp.o 77 77 obj-$(CONFIG_SMP) += smpboot.o 78 - obj-$(CONFIG_SMP) += tsc_sync.o 78 + obj-$(CONFIG_X86_TSC) += tsc_sync.o 79 79 obj-$(CONFIG_SMP) += setup_percpu.o 80 80 obj-$(CONFIG_X86_MPPARSE) += mpparse.o 81 81 obj-y += apic/
+1
arch/x86/kernel/process.c
··· 235 235 236 236 void arch_cpu_idle_enter(void) 237 237 { 238 + tsc_verify_tsc_adjust(false); 238 239 local_touch_nmi(); 239 240 } 240 241
+33 -9
arch/x86/kernel/tsc.c
··· 702 702 } 703 703 } 704 704 705 + /* 706 + * TSC frequency determined by CPUID is a "hardware reported" 707 + * frequency and is the most accurate one so far we have. This 708 + * is considered a known frequency. 709 + */ 710 + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); 711 + 712 + /* 713 + * For Atom SoCs TSC is the only reliable clocksource. 714 + * Mark TSC reliable so no watchdog on it. 715 + */ 716 + if (boot_cpu_data.x86_model == INTEL_FAM6_ATOM_GOLDMONT) 717 + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); 718 + 705 719 return crystal_khz * ebx_numerator / eax_denominator; 706 720 } 707 721 ··· 1057 1043 if (boot_cpu_data.cpuid_level < ART_CPUID_LEAF) 1058 1044 return; 1059 1045 1046 + /* Don't enable ART in a VM, non-stop TSC and TSC_ADJUST required */ 1047 + if (boot_cpu_has(X86_FEATURE_HYPERVISOR) || 1048 + !boot_cpu_has(X86_FEATURE_NONSTOP_TSC) || 1049 + !boot_cpu_has(X86_FEATURE_TSC_ADJUST)) 1050 + return; 1051 + 1060 1052 cpuid(ART_CPUID_LEAF, &art_to_tsc_denominator, 1061 1053 &art_to_tsc_numerator, unused, unused+1); 1062 1054 1063 - /* Don't enable ART in a VM, non-stop TSC required */ 1064 - if (boot_cpu_has(X86_FEATURE_HYPERVISOR) || 1065 - !boot_cpu_has(X86_FEATURE_NONSTOP_TSC) || 1066 - art_to_tsc_denominator < ART_MIN_DENOMINATOR) 1055 + if (art_to_tsc_denominator < ART_MIN_DENOMINATOR) 1067 1056 return; 1068 1057 1069 - if (rdmsrl_safe(MSR_IA32_TSC_ADJUST, &art_to_tsc_offset)) 1070 - return; 1058 + rdmsrl(MSR_IA32_TSC_ADJUST, art_to_tsc_offset); 1071 1059 1072 1060 /* Make this sticky over multiple CPU init calls */ 1073 1061 setup_force_cpu_cap(X86_FEATURE_ART); ··· 1079 1063 /* clocksource code */ 1080 1064 1081 1065 static struct clocksource clocksource_tsc; 1066 + 1067 + static void tsc_resume(struct clocksource *cs) 1068 + { 1069 + tsc_verify_tsc_adjust(true); 1070 + } 1082 1071 1083 1072 /* 1084 1073 * We used to compare the TSC to the cycle_last value in the clocksource ··· 1117 1096 .flags = CLOCK_SOURCE_IS_CONTINUOUS | 1118 1097 CLOCK_SOURCE_MUST_VERIFY, 1119 1098 .archdata = { .vclock_mode = VCLOCK_TSC }, 1099 + .resume = tsc_resume, 1120 1100 }; 1121 1101 1122 1102 void mark_tsc_unstable(char *reason) ··· 1305 1283 clocksource_tsc.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP; 1306 1284 1307 1285 /* 1308 - * Trust the results of the earlier calibration on systems 1309 - * exporting a reliable TSC. 1286 + * When TSC frequency is known (retrieved via MSR or CPUID), we skip 1287 + * the refined calibration and directly register it as a clocksource. 1310 1288 */ 1311 - if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) { 1289 + if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) { 1312 1290 clocksource_register_khz(&clocksource_tsc, tsc_khz); 1313 1291 return 0; 1314 1292 } ··· 1385 1363 1386 1364 if (unsynchronized_tsc()) 1387 1365 mark_tsc_unstable("TSCs unsynchronized"); 1366 + else 1367 + tsc_store_and_check_tsc_adjust(true); 1388 1368 1389 1369 check_system_tsc_reliable(); 1390 1370
+19
arch/x86/kernel/tsc_msr.c
··· 100 100 #ifdef CONFIG_X86_LOCAL_APIC 101 101 lapic_timer_frequency = (freq * 1000) / HZ; 102 102 #endif 103 + 104 + /* 105 + * TSC frequency determined by MSR is always considered "known" 106 + * because it is reported by HW. 107 + * Another fact is that on MSR capable platforms, PIT/HPET is 108 + * generally not available so calibration won't work at all. 109 + */ 110 + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); 111 + 112 + /* 113 + * Unfortunately there is no way for hardware to tell whether the 114 + * TSC is reliable. We were told by silicon design team that TSC 115 + * on Atom SoCs are always "reliable". TSC is also the only 116 + * reliable clocksource on these SoCs (HPET is either not present 117 + * or not functional) so mark TSC reliable which removes the 118 + * requirement for a watchdog clocksource. 119 + */ 120 + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); 121 + 103 122 return res; 104 123 }
+277 -13
arch/x86/kernel/tsc_sync.c
··· 14 14 * ( The serial nature of the boot logic and the CPU hotplug lock 15 15 * protects against more than 2 CPUs entering this code. ) 16 16 */ 17 + #include <linux/topology.h> 17 18 #include <linux/spinlock.h> 18 19 #include <linux/kernel.h> 19 20 #include <linux/smp.h> 20 21 #include <linux/nmi.h> 21 22 #include <asm/tsc.h> 23 + 24 + struct tsc_adjust { 25 + s64 bootval; 26 + s64 adjusted; 27 + unsigned long nextcheck; 28 + bool warned; 29 + }; 30 + 31 + static DEFINE_PER_CPU(struct tsc_adjust, tsc_adjust); 32 + 33 + void tsc_verify_tsc_adjust(bool resume) 34 + { 35 + struct tsc_adjust *adj = this_cpu_ptr(&tsc_adjust); 36 + s64 curval; 37 + 38 + if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST)) 39 + return; 40 + 41 + /* Rate limit the MSR check */ 42 + if (!resume && time_before(jiffies, adj->nextcheck)) 43 + return; 44 + 45 + adj->nextcheck = jiffies + HZ; 46 + 47 + rdmsrl(MSR_IA32_TSC_ADJUST, curval); 48 + if (adj->adjusted == curval) 49 + return; 50 + 51 + /* Restore the original value */ 52 + wrmsrl(MSR_IA32_TSC_ADJUST, adj->adjusted); 53 + 54 + if (!adj->warned || resume) { 55 + pr_warn(FW_BUG "TSC ADJUST differs: CPU%u %lld --> %lld. Restoring\n", 56 + smp_processor_id(), adj->adjusted, curval); 57 + adj->warned = true; 58 + } 59 + } 60 + 61 + static void tsc_sanitize_first_cpu(struct tsc_adjust *cur, s64 bootval, 62 + unsigned int cpu, bool bootcpu) 63 + { 64 + /* 65 + * First online CPU in a package stores the boot value in the 66 + * adjustment value. This value might change later via the sync 67 + * mechanism. If that fails we still can yell about boot values not 68 + * being consistent. 69 + * 70 + * On the boot cpu we just force set the ADJUST value to 0 if it's 71 + * non zero. We don't do that on non boot cpus because physical 72 + * hotplug should have set the ADJUST register to a value > 0 so 73 + * the TSC is in sync with the already running cpus. 74 + * 75 + * But we always force positive ADJUST values. Otherwise the TSC 76 + * deadline timer creates an interrupt storm. We also have to 77 + * prevent values > 0x7FFFFFFF as those wreckage the timer as well. 78 + */ 79 + if ((bootcpu && bootval != 0) || (!bootcpu && bootval < 0) || 80 + (bootval > 0x7FFFFFFF)) { 81 + pr_warn(FW_BUG "TSC ADJUST: CPU%u: %lld force to 0\n", cpu, 82 + bootval); 83 + wrmsrl(MSR_IA32_TSC_ADJUST, 0); 84 + bootval = 0; 85 + } 86 + cur->adjusted = bootval; 87 + } 88 + 89 + #ifndef CONFIG_SMP 90 + bool __init tsc_store_and_check_tsc_adjust(bool bootcpu) 91 + { 92 + struct tsc_adjust *cur = this_cpu_ptr(&tsc_adjust); 93 + s64 bootval; 94 + 95 + if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST)) 96 + return false; 97 + 98 + rdmsrl(MSR_IA32_TSC_ADJUST, bootval); 99 + cur->bootval = bootval; 100 + cur->nextcheck = jiffies + HZ; 101 + tsc_sanitize_first_cpu(cur, bootval, smp_processor_id(), bootcpu); 102 + return false; 103 + } 104 + 105 + #else /* !CONFIG_SMP */ 106 + 107 + /* 108 + * Store and check the TSC ADJUST MSR if available 109 + */ 110 + bool tsc_store_and_check_tsc_adjust(bool bootcpu) 111 + { 112 + struct tsc_adjust *ref, *cur = this_cpu_ptr(&tsc_adjust); 113 + unsigned int refcpu, cpu = smp_processor_id(); 114 + struct cpumask *mask; 115 + s64 bootval; 116 + 117 + if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST)) 118 + return false; 119 + 120 + rdmsrl(MSR_IA32_TSC_ADJUST, bootval); 121 + cur->bootval = bootval; 122 + cur->nextcheck = jiffies + HZ; 123 + cur->warned = false; 124 + 125 + /* 126 + * Check whether this CPU is the first in a package to come up. In 127 + * this case do not check the boot value against another package 128 + * because the new package might have been physically hotplugged, 129 + * where TSC_ADJUST is expected to be different. When called on the 130 + * boot CPU topology_core_cpumask() might not be available yet. 131 + */ 132 + mask = topology_core_cpumask(cpu); 133 + refcpu = mask ? cpumask_any_but(mask, cpu) : nr_cpu_ids; 134 + 135 + if (refcpu >= nr_cpu_ids) { 136 + tsc_sanitize_first_cpu(cur, bootval, smp_processor_id(), 137 + bootcpu); 138 + return false; 139 + } 140 + 141 + ref = per_cpu_ptr(&tsc_adjust, refcpu); 142 + /* 143 + * Compare the boot value and complain if it differs in the 144 + * package. 145 + */ 146 + if (bootval != ref->bootval) { 147 + pr_warn(FW_BUG "TSC ADJUST differs: Reference CPU%u: %lld CPU%u: %lld\n", 148 + refcpu, ref->bootval, cpu, bootval); 149 + } 150 + /* 151 + * The TSC_ADJUST values in a package must be the same. If the boot 152 + * value on this newly upcoming CPU differs from the adjustment 153 + * value of the already online CPU in this package, set it to that 154 + * adjusted value. 155 + */ 156 + if (bootval != ref->adjusted) { 157 + pr_warn("TSC ADJUST synchronize: Reference CPU%u: %lld CPU%u: %lld\n", 158 + refcpu, ref->adjusted, cpu, bootval); 159 + cur->adjusted = ref->adjusted; 160 + wrmsrl(MSR_IA32_TSC_ADJUST, ref->adjusted); 161 + } 162 + /* 163 + * We have the TSCs forced to be in sync on this package. Skip sync 164 + * test: 165 + */ 166 + return true; 167 + } 22 168 23 169 /* 24 170 * Entry/exit counters that make sure that both CPUs ··· 172 26 */ 173 27 static atomic_t start_count; 174 28 static atomic_t stop_count; 29 + static atomic_t skip_test; 30 + static atomic_t test_runs; 175 31 176 32 /* 177 33 * We use a raw spinlock in this exceptional case, because ··· 185 37 static cycles_t last_tsc; 186 38 static cycles_t max_warp; 187 39 static int nr_warps; 40 + static int random_warps; 188 41 189 42 /* 190 43 * TSC-warp measurement loop running on both CPUs. This is not called 191 44 * if there is no TSC. 192 45 */ 193 - static void check_tsc_warp(unsigned int timeout) 46 + static cycles_t check_tsc_warp(unsigned int timeout) 194 47 { 195 - cycles_t start, now, prev, end; 196 - int i; 48 + cycles_t start, now, prev, end, cur_max_warp = 0; 49 + int i, cur_warps = 0; 197 50 198 51 start = rdtsc_ordered(); 199 52 /* ··· 234 85 if (unlikely(prev > now)) { 235 86 arch_spin_lock(&sync_lock); 236 87 max_warp = max(max_warp, prev - now); 88 + cur_max_warp = max_warp; 89 + /* 90 + * Check whether this bounces back and forth. Only 91 + * one CPU should observe time going backwards. 92 + */ 93 + if (cur_warps != nr_warps) 94 + random_warps++; 237 95 nr_warps++; 96 + cur_warps = nr_warps; 238 97 arch_spin_unlock(&sync_lock); 239 98 } 240 99 } 241 100 WARN(!(now-start), 242 101 "Warning: zero tsc calibration delta: %Ld [max: %Ld]\n", 243 102 now-start, end-start); 103 + return cur_max_warp; 244 104 } 245 105 246 106 /* ··· 294 136 } 295 137 296 138 /* 297 - * Reset it - in case this is a second bootup: 139 + * Set the maximum number of test runs to 140 + * 1 if the CPU does not provide the TSC_ADJUST MSR 141 + * 3 if the MSR is available, so the target can try to adjust 298 142 */ 299 - atomic_set(&stop_count, 0); 300 - 143 + if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST)) 144 + atomic_set(&test_runs, 1); 145 + else 146 + atomic_set(&test_runs, 3); 147 + retry: 301 148 /* 302 - * Wait for the target to arrive: 149 + * Wait for the target to start or to skip the test: 303 150 */ 304 - while (atomic_read(&start_count) != cpus-1) 151 + while (atomic_read(&start_count) != cpus - 1) { 152 + if (atomic_read(&skip_test) > 0) { 153 + atomic_set(&skip_test, 0); 154 + return; 155 + } 305 156 cpu_relax(); 157 + } 158 + 306 159 /* 307 160 * Trigger the target to continue into the measurement too: 308 161 */ ··· 324 155 while (atomic_read(&stop_count) != cpus-1) 325 156 cpu_relax(); 326 157 327 - if (nr_warps) { 158 + /* 159 + * If the test was successful set the number of runs to zero and 160 + * stop. If not, decrement the number of runs an check if we can 161 + * retry. In case of random warps no retry is attempted. 162 + */ 163 + if (!nr_warps) { 164 + atomic_set(&test_runs, 0); 165 + 166 + pr_debug("TSC synchronization [CPU#%d -> CPU#%d]: passed\n", 167 + smp_processor_id(), cpu); 168 + 169 + } else if (atomic_dec_and_test(&test_runs) || random_warps) { 170 + /* Force it to 0 if random warps brought us here */ 171 + atomic_set(&test_runs, 0); 172 + 328 173 pr_warning("TSC synchronization [CPU#%d -> CPU#%d]:\n", 329 174 smp_processor_id(), cpu); 330 175 pr_warning("Measured %Ld cycles TSC warp between CPUs, " 331 176 "turning off TSC clock.\n", max_warp); 177 + if (random_warps) 178 + pr_warning("TSC warped randomly between CPUs\n"); 332 179 mark_tsc_unstable("check_tsc_sync_source failed"); 333 - } else { 334 - pr_debug("TSC synchronization [CPU#%d -> CPU#%d]: passed\n", 335 - smp_processor_id(), cpu); 336 180 } 337 181 338 182 /* 339 183 * Reset it - just in case we boot another CPU later: 340 184 */ 341 185 atomic_set(&start_count, 0); 186 + random_warps = 0; 342 187 nr_warps = 0; 343 188 max_warp = 0; 344 189 last_tsc = 0; ··· 361 178 * Let the target continue with the bootup: 362 179 */ 363 180 atomic_inc(&stop_count); 181 + 182 + /* 183 + * Retry, if there is a chance to do so. 184 + */ 185 + if (atomic_read(&test_runs) > 0) 186 + goto retry; 364 187 } 365 188 366 189 /* ··· 374 185 */ 375 186 void check_tsc_sync_target(void) 376 187 { 188 + struct tsc_adjust *cur = this_cpu_ptr(&tsc_adjust); 189 + unsigned int cpu = smp_processor_id(); 190 + cycles_t cur_max_warp, gbl_max_warp; 377 191 int cpus = 2; 378 192 379 193 /* Also aborts if there is no TSC. */ 380 194 if (unsynchronized_tsc() || tsc_clocksource_reliable) 381 195 return; 382 196 197 + /* 198 + * Store, verify and sanitize the TSC adjust register. If 199 + * successful skip the test. 200 + */ 201 + if (tsc_store_and_check_tsc_adjust(false)) { 202 + atomic_inc(&skip_test); 203 + return; 204 + } 205 + 206 + retry: 383 207 /* 384 208 * Register this CPU's participation and wait for the 385 209 * source CPU to start the measurement: ··· 401 199 while (atomic_read(&start_count) != cpus) 402 200 cpu_relax(); 403 201 404 - check_tsc_warp(loop_timeout(smp_processor_id())); 202 + cur_max_warp = check_tsc_warp(loop_timeout(cpu)); 203 + 204 + /* 205 + * Store the maximum observed warp value for a potential retry: 206 + */ 207 + gbl_max_warp = max_warp; 405 208 406 209 /* 407 210 * Ok, we are done: ··· 418 211 */ 419 212 while (atomic_read(&stop_count) != cpus) 420 213 cpu_relax(); 214 + 215 + /* 216 + * Reset it for the next sync test: 217 + */ 218 + atomic_set(&stop_count, 0); 219 + 220 + /* 221 + * Check the number of remaining test runs. If not zero, the test 222 + * failed and a retry with adjusted TSC is possible. If zero the 223 + * test was either successful or failed terminally. 224 + */ 225 + if (!atomic_read(&test_runs)) 226 + return; 227 + 228 + /* 229 + * If the warp value of this CPU is 0, then the other CPU 230 + * observed time going backwards so this TSC was ahead and 231 + * needs to move backwards. 232 + */ 233 + if (!cur_max_warp) 234 + cur_max_warp = -gbl_max_warp; 235 + 236 + /* 237 + * Add the result to the previous adjustment value. 238 + * 239 + * The adjustement value is slightly off by the overhead of the 240 + * sync mechanism (observed values are ~200 TSC cycles), but this 241 + * really depends on CPU, node distance and frequency. So 242 + * compensating for this is hard to get right. Experiments show 243 + * that the warp is not longer detectable when the observed warp 244 + * value is used. In the worst case the adjustment needs to go 245 + * through a 3rd run for fine tuning. 246 + */ 247 + cur->adjusted += cur_max_warp; 248 + 249 + /* 250 + * TSC deadline timer stops working or creates an interrupt storm 251 + * with adjust values < 0 and > x07ffffff. 252 + * 253 + * To allow adjust values > 0x7FFFFFFF we need to disable the 254 + * deadline timer and use the local APIC timer, but that requires 255 + * more intrusive changes and we do not have any useful information 256 + * from Intel about the underlying HW wreckage yet. 257 + */ 258 + if (cur->adjusted < 0) 259 + cur->adjusted = 0; 260 + if (cur->adjusted > 0x7FFFFFFF) 261 + cur->adjusted = 0x7FFFFFFF; 262 + 263 + pr_warn("TSC ADJUST compensate: CPU%u observed %lld warp. Adjust: %lld\n", 264 + cpu, cur_max_warp, cur->adjusted); 265 + 266 + wrmsrl(MSR_IA32_TSC_ADJUST, cur->adjusted); 267 + goto retry; 268 + 421 269 } 270 + 271 + #endif /* CONFIG_SMP */
+7 -2
arch/x86/platform/intel-mid/mfld.c
··· 49 49 fast_calibrate = ratio * fsb; 50 50 pr_debug("read penwell tsc %lu khz\n", fast_calibrate); 51 51 lapic_timer_frequency = fsb * 1000 / HZ; 52 - /* mark tsc clocksource as reliable */ 53 - set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE); 52 + 53 + /* 54 + * TSC on Intel Atom SoCs is reliable and of known frequency. 55 + * See tsc_msr.c for details. 56 + */ 57 + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); 58 + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); 54 59 55 60 return fast_calibrate; 56 61 }
+6 -2
arch/x86/platform/intel-mid/mrfld.c
··· 78 78 pr_debug("Setting lapic_timer_frequency = %d\n", 79 79 lapic_timer_frequency); 80 80 81 - /* mark tsc clocksource as reliable */ 82 - set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE); 81 + /* 82 + * TSC on Intel Atom SoCs is reliable and of known frequency. 83 + * See tsc_msr.c for details. 84 + */ 85 + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); 86 + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); 83 87 84 88 return fast_calibrate; 85 89 }
+1
arch/x86/power/cpu.c
··· 252 252 fix_processor_context(); 253 253 254 254 do_fpu_end(); 255 + tsc_verify_tsc_adjust(true); 255 256 x86_platform.restore_sched_clock_state(); 256 257 mtrr_bp_restore(); 257 258 perf_restore_debug_store();