diff -urN --exclude-from=/home/davej/.exclude linux-ac/arch/i386/kernel/mtrr.c linux-dj/arch/i386/kernel/mtrr.c --- linux-ac/arch/i386/kernel/mtrr.c Thu Aug 23 22:32:10 2001 +++ linux-dj/arch/i386/kernel/mtrr.c Thu Aug 23 22:31:12 2001 @@ -389,21 +389,19 @@ return; /* Save value of CR4 and clear Page Global Enable (bit 7) */ - if ( test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability) ) - asm volatile ("movl %%cr4, %0\n\t" - "movl %0, %1\n\t" - "andb $0x7f, %b1\n\t" - "movl %1, %%cr4\n\t" - : "=r" (ctxt->cr4val), "=q" (tmp) : : "memory"); + if ( test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability) ) { + ctxt->cr4val = read_cr4(); + write_cr4(ctxt->cr4val & (~1<<7)); + } /* Disable and flush caches. Note that wbinvd flushes the TLBs as a side-effect */ - asm volatile ("movl %%cr0, %0\n\t" - "orl $0x40000000, %0\n\t" - "wbinvd\n\t" - "movl %0, %%cr0\n\t" - "wbinvd\n\t" - : "=r" (tmp) : : "memory"); + { + long cr0 = read_cr0() | 0x40000000; + wbinvd(); + write_cr0( cr0 ); + wbinvd(); + } if ( mtrr_if == MTRR_IF_INTEL ) { /* Disable MTRRs, and set the default type to uncached */ @@ -420,15 +418,13 @@ /* Restore the processor after a set_mtrr_prepare */ static void set_mtrr_done (struct set_mtrr_context *ctxt) { - unsigned long tmp; - if ( mtrr_if != MTRR_IF_INTEL && mtrr_if != MTRR_IF_CYRIX_ARR ) { __restore_flags (ctxt->flags); return; } /* Flush caches and TLBs */ - asm volatile ("wbinvd" : : : "memory" ); + wbinvd(); /* Restore MTRRdefType */ if ( mtrr_if == MTRR_IF_INTEL ) { @@ -440,15 +436,11 @@ } /* Enable caches */ - asm volatile ("movl %%cr0, %0\n\t" - "andl $0xbfffffff, %0\n\t" - "movl %0, %%cr0\n\t" - : "=r" (tmp) : : "memory"); + write_cr0( read_cr0() & 0xbfffffff ); /* Restore value of CR4 */ if ( test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability) ) - asm volatile ("movl %0, %%cr4" - : : "r" (ctxt->cr4val) : "memory"); + write_cr4(ctxt->cr4val); /* Re-enable interrupts locally (if enabled previously) */ __restore_flags (ctxt->flags); @@ -792,8 +784,8 @@ * The writeback rule is quite specific. See the manual. Its * disable local interrupts, write back the cache, set the mtrr */ - __asm__ __volatile__ ("wbinvd" : : : "memory"); - wrmsr (MSR_K6_UWCCR, regs[0], regs[1]); + wbinvd(); + wrmsr (MSR_K6_UWCCR, regs[0], regs[1]); if (do_safe) set_mtrr_done (&ctxt); } /* End Function amd_set_mtrr_up */ diff -urN --exclude-from=/home/davej/.exclude linux-ac/include/asm-i386/system.h linux-dj/include/asm-i386/system.h --- linux-ac/include/asm-i386/system.h Thu Aug 23 22:32:22 2001 +++ linux-dj/include/asm-i386/system.h Thu Aug 23 22:30:30 2001 @@ -110,9 +110,22 @@ }) #define write_cr0(x) \ __asm__("movl %0,%%cr0": :"r" (x)); + +#define read_cr4() ({ \ + unsigned long __dummy; \ + __asm__( \ + "movl %%cr4,%0\n\t" \ + :"=r" (__dummy)); \ + __dummy; \ +}) +#define write_cr4(x) \ + __asm__("movl %0,%%cr4": :"r" (x)); #define stts() write_cr0(8 | read_cr0()) #endif /* __KERNEL__ */ + +#define wbinvd() \ + __asm__ __volatile__ ("wbinvd": : :"memory"); static inline unsigned long get_limit(unsigned long segment) {