[PATCH] 2.3.99-pre1: cr4 fixes

From: Maciej W. Rozycki (macro@ds2.pg.gda.pl)
Date: Fri Mar 17 2000 - 12:36:10 EST


Hi,

 It seems there are some inconsistencies with handling of the cr4 register
when it comes to i486 machines, including but not limited to SMP ones.

 The attached patch fixes the following problems:

- head.S: earlier 486 chips do not have the cr4 register. The code
however accesses it unconditionally for APs which would result in an
invalid opcode fault. Fixing this is essential for 486-based SMP systems.

 The proposed change is the cheapest one and is obvious I believe. I
don't think supporting unequal 486 SMP systems actively in advance is
worth the hassle -- if someone has such a system, CPUs must be on
daughtercards or in sockets for sure, so it should be easy enough to swap
them until the BSP is the CPU that implements the smallest subset of
features of all CPUs used.

 The second hunk removes an unused leftover after the yet more broken
piece of code that was enabling pse unconditionally for APs before 2.3.43.

- setup.c: some SL-enhanced i486s implement vme yet the do not implement
pse. So far, I've seen CPUs of the 042a (i486SX) and 0435 (i486DX2)
signatures featuring vme but no pse. I believe this is also the case for
standard i486DX4s and for i486SX2 although I could only verify it by docs.
Writeback-enhanced i486s do feature both vme and pse. I suppose we should
switch vme and pvi off regardless of the pse feature.

 While fixing the semantics the change does not even enlarge the code --
gcc just sets more bits in the testl opcode it generates for the affected
if statement.

- processor.h: just add new macros suitable for changes made to setup.c.

 Beside being "obviously correct" these fixes were compile-time and
run-time tested on an SMP machine (not a 486, however). I hope these
changes can be incorporated before 2.4.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

diff -u --recursive --new-file linux-2.3.99-pre1.macro/arch/i386/kernel/head.S linux-2.3.99-pre1/arch/i386/kernel/head.S --- linux-2.3.99-pre1.macro/arch/i386/kernel/head.S Fri Mar 17 11:19:40 2000 +++ linux-2.3.99-pre1/arch/i386/kernel/head.S Fri Mar 17 12:29:33 2000 @@ -58,10 +58,19 @@ * New page tables may be in 4Mbyte page mode and may * be using the global pages. * + * NOTE! If we are on a 486 we may have no cr4 at all! + * So we do not try to touch it unless we really have + * some bits in it to set. This won't work if the BSP + * implements cr4 but this AP does not -- very unlikely + * but be warned! The same applies to the pse feature + * if not equally supported. --macro + * * NOTE! We have to correct for the fact that we're * not yet offset PAGE_OFFSET.. */ #define cr4_bits mmu_cr4_features-__PAGE_OFFSET + cmpl $0,cr4_bits + je 1f movl %cr4,%eax # Turn on 4Mb pages orl cr4_bits,%eax movl %eax,%cr4 @@ -219,7 +228,6 @@ orl $2,%eax # set MP 2: movl %eax,%cr0 call check_x87 -4: #ifdef __SMP__ incb ready #endif diff -u --recursive --new-file linux-2.3.99-pre1.macro/arch/i386/kernel/setup.c linux-2.3.99-pre1/arch/i386/kernel/setup.c --- linux-2.3.99-pre1.macro/arch/i386/kernel/setup.c Fri Mar 17 11:19:40 2000 +++ linux-2.3.99-pre1/arch/i386/kernel/setup.c Fri Mar 17 11:36:12 2000 @@ -1546,7 +1546,7 @@ cpus_initialized++; printk("Initializing CPU#%d\n", nr); - if (cpu_has_pse) + if (cpu_has_vme || cpu_has_tsc || cpu_has_de) clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); __asm__ __volatile__("lgdt %0": "=m" (gdt_descr)); diff -u --recursive --new-file linux-2.3.99-pre1.macro/include/asm-i386/processor.h linux-2.3.99-pre1/include/asm-i386/processor.h --- linux-2.3.99-pre1.macro/include/asm-i386/processor.h Tue Feb 22 11:12:38 2000 +++ linux-2.3.99-pre1/include/asm-i386/processor.h Fri Mar 17 11:54:59 2000 @@ -116,6 +116,10 @@ (boot_cpu_data.x86_capability & X86_FEATURE_PAE) #define cpu_has_tsc \ (boot_cpu_data.x86_capability & X86_FEATURE_TSC) +#define cpu_has_de \ + (boot_cpu_data.x86_capability & X86_FEATURE_DE) +#define cpu_has_vme \ + (boot_cpu_data.x86_capability & X86_FEATURE_VME) extern char ignore_irq13;

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



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:22 EST