android_kernel_motorola_sm6225/arch/x86/kernel/cpu
Mikael Pettersson 12c247a671 x86: fix boot failure on 486 due to TSC breakage
> Diffing dmesg between git7 and git8 doesn't sched any light since
 > git8 also removed the printouts of the x86 caps as they were being
 > initialised and updated. I'm currently adding those printouts back
 > in the hope of seeing where and when the caps get broken.

That turned out to be very illuminating:

 --- dmesg-2.6.24-git7	2008-02-24 18:01:25.295851000 +0100
 +++ dmesg-2.6.24-git8	2008-02-24 18:01:25.530358000 +0100
 ...
 CPU: After generic identify, caps: 00000003 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 CPU: After all inits, caps: 00000003 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+CPU: After applying cleared_cpu_caps, caps: 00000013 00000000 00000000 00000000 00000000 00000000 00000000 00000000

Notice how the TSC cap bit goes from Off to On.

(The first two lines are printout loops from -git7 forward-ported
to -git8, the third line is the same printout loop added just after
the xor-with-cleared_cpu_caps[] loop.)

Here's how the breakage occurs:
1. arch/x86/kernel/tsc_32.c:tsc_init() sees !cpu_has_tsc,
   so bails and calls setup_clear_cpu_cap(X86_FEATURE_TSC).
2. include/asm-x86/cpufeature.h:setup_clear_cpu_cap(bit) clears
   the bit in boot_cpu_data and sets it in cleared_cpu_caps
3. arch/x86/kernel/cpu/common.c:identify_cpu() XORs all caps
   in with cleared_cpu_caps
   HOWEVER, at this point c->x86_capability correctly has TSC
   Off, cleared_cpu_caps has TSC On, so the XOR incorrectly
   sets TSC to On in c->x86_capability, with disastrous results.

The real bug is that clearing bits with XOR only works if the
bits are known to be 1 prior to the XOR, and that's not true here.

A simple fix is to convert the XOR to AND-NOT instead. The following
patch does that, and allows my 486 to boot 2.6.25-rc kernels again.

[ mingo@elte.hu: fixed a similar bug in setup_64.c as well. ]

The breakage was introduced via commit 7d851c8d3d.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-02-26 12:56:04 +01:00
..
cpufreq Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2008-02-07 09:45:58 -08:00
mcheck x86: sparse warning in therm_throt.c 2008-02-09 23:24:08 +01:00
mtrr x86: don't print a warning when MTRR are blank and running in KVM 2008-02-26 12:55:57 +01:00
addon_cpuid_features.c x86: add set/clear_cpu_cap operations 2008-01-30 13:30:55 +01:00
amd.c x86: fix bootup crash in native_read_tsc() 2008-02-02 10:00:26 +11:00
bugs.c remove mca-pentium 2008-02-19 16:18:28 +01:00
centaur.c spelling fixes: arch/i386/ 2007-10-20 01:13:56 +02:00
common.c x86: fix boot failure on 486 due to TSC breakage 2008-02-26 12:56:04 +01:00
cpu.h x86: add cpu init function defintions to cpu.h 2008-02-04 16:48:04 +01:00
cyrix.c calibrate_delay() must be __cpuinit 2008-02-06 10:41:08 -08:00
feature_names.c x86: unify CPU feature string names 2008-02-04 16:48:00 +01:00
intel.c x86: add include to cpu/intel.c 2008-02-04 16:48:04 +01:00
intel_cacheinfo.c x86: fix sparse warnings in intel_cacheinfo.c 2008-01-31 22:05:43 +01:00
Makefile x86: unify CPU feature string names 2008-02-04 16:48:00 +01:00
nexgen.c
perfctr-watchdog.c x86: nuke a ton of unused exports 2008-01-30 13:30:28 +01:00
proc.c x86: unify CPU feature string names 2008-02-04 16:48:00 +01:00
transmeta.c x86: do not promote TM3x00/TM5x00 to i686-class 2008-02-26 12:55:50 +01:00
umc.c