Re: [PATCH] OOPS in identify_cpu() on CPUs without CPUID

From: Ondrej Zary
Date: Sat Aug 08 2009 - 14:19:52 EST


On Saturday 08 August 2009 19:53:44 Ingo Molnar wrote:
> * Ondrej Zary <linux@xxxxxxxxxxxxxxxxxxxx> wrote:
> > Kernel is broken for x86 CPUs without CPUID since 2.6.28. It
> > crashes with NULL pointer dereference in identify_cpu():
> >
> > 766 generic_identify(c);
> > 767
> > 768--> if (this_cpu->c_identify)
> > 769 this_cpu->c_identify(c);
> >
> > this_cpu is NULL. This is because it's only initialized in
> > get_cpu_vendor() function, which is not called if the CPU has no
> > CPUID instruction.
>
> indeed ...
>
> > Signed-off-by: Ondrej Zary <linux@xxxxxxxxxxxxxxxxxxxx>
> >
> > --- linux-2.6.30.4-orig/arch/x86/kernel/cpu/common.c 2009-06-10
> > 05:05:27.000000000 +0200 +++
> > linux-2.6.30.4-router/arch/x86/kernel/cpu/common.c 2009-08-08
> > 18:00:21.000000000 +0200 @@ -699,6 +699,7 @@
> >
> > static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
> > {
> > + this_cpu = &default_cpu;
> > c->extended_cpuid_level = 0;
> >
> > if (!have_cpuid_p())
>
> How about initializing this_cpu instead, via:
>
> static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
>
> ?

That might be even better - looks cleaner. I can't test it right now as I
don't have the hardware here. I'll test it tomorrow (unless someone will be
faster).

--
Ondrej Zary
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/