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

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] i386: Prevent early access to TSC to avoid crash on TSCless systems

commit f9690982b8c2f9a2c65acdc113e758ec356676a3 removed the check for
cpu_khz from sched_clock(), which prevented early access to the TSC by
non obvious magic.

This is harmless as long as the CPU has a TSC. On TSCless systems this
results in an illegal instruction trap.

Replace tsc_disabled and tsc_unstable by tsc_enabled, which is only set
when the tsc is available and not unstable.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Thomas Gleixner and committed by
Linus Torvalds
d9a5c0a4 8fb303c7

+7 -2
+7 -2
arch/i386/kernel/tsc.c
··· 18 18 19 19 #include "mach_timer.h" 20 20 21 + static int tsc_enabled; 22 + 21 23 /* 22 24 * On some systems the TSC frequency does not 23 25 * change with the cpu frequency. So we need ··· 107 105 /* 108 106 * Fall back to jiffies if there's no TSC available: 109 107 */ 110 - if (tsc_unstable || unlikely(tsc_disable)) 108 + if (unlikely(!tsc_enabled)) 111 109 /* No locking but a rare wrong value is not a big deal: */ 112 110 return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ); 113 111 ··· 285 283 { 286 284 if (!tsc_unstable) { 287 285 tsc_unstable = 1; 286 + tsc_enabled = 0; 288 287 /* Can be called before registration */ 289 288 if (clocksource_tsc.mult) 290 289 clocksource_change_rating(&clocksource_tsc, 0); ··· 386 383 if (check_tsc_unstable()) { 387 384 clocksource_tsc.rating = 0; 388 385 clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS; 389 - } 386 + } else 387 + tsc_enabled = 1; 388 + 390 389 clocksource_register(&clocksource_tsc); 391 390 392 391 return;