Mikael Pettersson df17b1d990 x86, 32-bit: fix boot failure on TSC-less processors
Booting 2.6.26-rc6 on my 486 DX/4 fails with a "BUG: Int 6"
(invalid opcode) and a kernel halt immediately after the
kernel has been uncompressed. The BUG shows EIP pointing
to an rdtsc instruction in native_read_tsc(), invoked from
native_sched_clock().

(This error occurs so early that not even the serial console
can capture it.)

A bisection showed that this bug first occurs in 2.6.26-rc3-git7,
via commit 9ccc906c97e34fd91dc6aaf5b69b52d824386910:

>x86: distangle user disabled TSC from unstable
>
>tsc_enabled is set to 0 from the command line switch "notsc" and from
>the mark_tsc_unstable code. Seperate those functionalities and replace
>tsc_enable with tsc_disable. This makes also the native_sched_clock()
>decision when to use TSC understandable.
>
>Preparatory patch to solve the sched_clock() issue on 32 bit.
>
>Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

The core reason for this bug is that native_sched_clock() gets
called before tsc_init().

Before the commit above, tsc_32.c used a "tsc_enabled" variable
which defaulted to 0 == disabled, and which only got enabled late
in tsc_init(). Thus early calls to native_sched_clock() would skip
the TSC and use jiffies instead.

After the commit above, tsc_32.c uses a "tsc_disabled" variable
which defaults to 0, meaning that the TSC is Ok to use. Early calls
to native_sched_clock() now erroneously try to use the TSC on
!cpu_has_tsc processors, leading to invalid opcode exceptions.

My proposed fix is to initialise tsc_disabled to a "soft disabled"
state distinct from the hard disabled state set up by the "notsc"
kernel option. This fixes the native_sched_clock() problem. It also
allows tsc_init() to be simplified: instead of setting tsc_disabled = 1
on every error return, we just set tsc_disabled = 0 once when all
checks have succeeded.

I've verified that this lets my 486 boot again. I've also verified
that a Core2 machine still uses the TSC as clocksource after the patch.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-06-19 10:08:47 +02:00
..
2008-06-04 13:11:46 +02:00
2007-10-17 21:19:04 +02:00
2008-04-25 19:54:07 +02:00
2008-04-17 17:41:19 +02:00
2008-04-26 17:35:47 +02:00
2008-04-29 08:06:29 -07:00
2008-04-29 08:06:29 -07:00
2007-10-11 11:17:01 +02:00
2007-10-11 11:17:24 +02:00
2008-04-19 19:10:28 -07:00
2007-10-19 11:53:33 -07:00
2007-10-13 10:01:23 -07:00
2008-01-30 13:31:31 +01:00
2008-04-29 13:45:24 +02:00
2008-02-19 16:18:28 +01:00
2008-04-19 19:19:54 +02:00
2007-10-11 11:17:01 +02:00
2008-01-30 13:31:19 +01:00
2008-04-19 19:19:54 +02:00
2008-04-17 17:41:13 +02:00
2008-04-30 23:15:34 +02:00
2008-04-17 17:41:36 +02:00
2008-04-19 19:19:58 +02:00
2008-04-17 17:40:49 +02:00
2008-06-12 21:26:12 +02:00
2008-04-17 17:41:37 +02:00
2008-04-30 23:15:34 +02:00
2008-04-26 17:35:47 +02:00
2008-04-26 17:35:48 +02:00
2008-03-26 22:23:40 +01:00
2008-01-30 13:33:10 +01:00
2008-04-17 17:40:56 +02:00
2008-04-29 08:06:02 -07:00
2007-10-11 11:17:24 +02:00
2008-04-19 19:19:54 +02:00
2008-04-27 12:00:28 +03:00
2008-05-23 14:08:06 +02:00
2008-05-07 12:42:03 +02:00
2008-06-12 21:25:51 +02:00
2007-10-11 11:17:01 +02:00
2007-10-11 11:17:24 +02:00
2008-05-04 20:04:45 +02:00
2008-04-19 19:10:28 -07:00
2008-06-12 21:26:28 +02:00
2008-01-30 13:33:19 +01:00
2008-04-19 19:19:57 +02:00
2008-04-19 19:19:56 +02:00
2007-10-11 11:17:01 +02:00
2008-06-12 18:05:42 -07:00
2008-04-19 19:19:55 +02:00
2008-04-30 08:29:37 -07:00
2008-04-30 08:29:37 -07:00
2008-05-13 19:36:12 +02:00
2008-04-17 17:40:55 +02:00
2008-04-17 17:40:55 +02:00
2008-04-26 17:35:47 +02:00
2008-04-29 08:06:03 -07:00
2008-02-08 09:22:29 -08:00
2008-04-17 17:40:56 +02:00
2008-01-30 13:31:52 +01:00
2008-04-17 17:41:37 +02:00
2008-05-23 14:08:06 +02:00
2007-10-11 11:17:24 +02:00
2008-04-24 23:57:31 +02:00
2008-04-28 13:49:35 -07:00
2007-10-11 11:17:01 +02:00
2008-04-24 23:15:44 +02:00