Following patch reworks car_disable into C. Tested, works here. I compared
[coreboot.git] / src / include / cpu / x86 / cache.h
index f3ac2ed11f5da35e24fa5d9de712793937e943b1..14538592e9191eac5fff8a6a0c426fcc205d6263 100644 (file)
 #ifndef CPU_X86_CACHE
 #define CPU_X86_CACHE
 
+/* the memory clobber prevents the GCC from reordering the read/write order
+   of CR0 */
+
 static inline unsigned long read_cr0(void)
 {
        unsigned long cr0;
-       asm volatile ("movl %%cr0, %0" : "=r" (cr0));
+       asm volatile ("movl %%cr0, %0" : "=r" (cr0) :: "memory");
        return cr0;
 }
 
 static inline void write_cr0(unsigned long cr0)
 {
-       asm volatile ("movl %0, %%cr0" : : "r" (cr0));
+       asm volatile ("movl %0, %%cr0" : : "r" (cr0) : "memory");
 }
 
 static inline void invd(void)
@@ -39,7 +42,7 @@ static inline void invd(void)
 
 static inline void wbinvd(void)
 {
-       asm volatile ("wbinvd");
+       asm volatile ("wbinvd" ::: "memory");
 }
 
 static inline void enable_cache(void)