Re: [PATCH 07/19] x86: unify power/cpu_(32|64).c

From: Pavel Machek
Date: Fri Jun 12 2009 - 06:51:15 EST


On Thu 2009-06-11 22:35:11, Rafael J. Wysocki wrote:
> From: Sergio Luis <sergio@xxxxxxxxxxxxxx>
>
> This is the last unification step. Here we do remove one of the files
> and rename the left one as cpu.c, as both are now the same.
> Also update power/Makefile, telling it to build cpu.o, instead of
> cpu_(32|64).o
>
> Signed-off-by: Sergio Luis <sergio@xxxxxxxxxxxxxx>
> Signed-off-by: Lauro Salmito <laurosalmito@xxxxxxxxx>
> Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>


> +#ifdef CONFIG_X86_32
> + store_gdt(&ctxt->gdt);
> + store_idt(&ctxt->idt);
> +#else
> +/* CONFIG_X86_64 */
> + store_gdt((struct desc_ptr *)&ctxt->gdt_limit);
> + store_idt((struct desc_ptr *)&ctxt->idt_limit);
> +#endif

I'd slightly prefer /* CONFIG_X86_64 */ to be moved to line above, or
dropped at all. it seems unneccessarily verbose.


> + store_tr(ctxt->tr);
> +
> + /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */
> + /*
> + * segment registers
> + */
> +#ifdef CONFIG_X86_32
> + savesegment(es, ctxt->es);
> + savesegment(fs, ctxt->fs);
> + savesegment(gs, ctxt->gs);
> + savesegment(ss, ctxt->ss);
> +#else
> +/* CONFIG_X86_64 */
> + asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds));
> + asm volatile ("movw %%es, %0" : "=m" (ctxt->es));
> + asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs));
> + asm volatile ("movw %%gs, %0" : "=m" (ctxt->gs));
> + asm volatile ("movw %%ss, %0" : "=m" (ctxt->ss));
> +
> + rdmsrl(MSR_FS_BASE, ctxt->fs_base);
> + rdmsrl(MSR_GS_BASE, ctxt->gs_base);
> + rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base);
> + mtrr_save_fixed_ranges(NULL);
> +
> + rdmsrl(MSR_EFER, ctxt->efer);
> +#endif

Can i386's mtrr_save_fixed_ranges() be moved to similar place?

> + /*
> + * control registers
> + */
> + ctxt->cr0 = read_cr0();
> + ctxt->cr2 = read_cr2();
> + ctxt->cr3 = read_cr3();
> +#ifdef CONFIG_X86_32
> + ctxt->cr4 = read_cr4_safe();
> +#else
> +/* CONFIG_X86_64 */
> + ctxt->cr4 = read_cr4();
> + ctxt->cr8 = read_cr8();
> +#endif

Could we use read_cr4_safe on x86-64, too? Why the difference?

Should we be saving cr8 on 32-bit machines that have it? (That was
interrupt priority, IIRC?)

> + /* cr4 was introduced in the Pentium CPU */
> +#ifdef CONFIG_X86_32
> + if (ctxt->cr4)
> + write_cr4(ctxt->cr4);
> +#else

Aha, is read_cr4_safe() needed because i486 does not have cr4?

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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/