]> git.hungrycats.org Git - linux/commitdiff
[PATCH] x86-64: fix /dev/mem caching behaviour
authorAndi Kleen <ak@muc.de>
Sat, 15 May 2004 03:41:03 +0000 (20:41 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 15 May 2004 03:41:03 +0000 (20:41 -0700)
This changes the /dev/mem caching behaviour on x86-64 to be compatible
with i386.

By default everything is set cached.

This actually makes WC MTRRs on AMD systems work, which would get
overriden by the UC PAT bits that were set earlier.  This can make DVD
decoding with hardware support a lot faster.

It also supports O_SYNC now, like i386, although that is not really
safe, because it allows the user to create undefined cache attribute
conflicts that can corrupt caches in some circumstances.  I kept it for
now.  Better would to disallow it, until Terrence Ripperda's PAT
framework is getting merged, that can avoid these problems.

Actually it would be probably a good idea to add a printk here to catch
broken programs for i386 and x86-64, but that is for another patch.

drivers/char/mem.c

index 477c63d6b0f3b8e98ca112f7d26be585c3ee4390..619e16d357cb07f114cf4d9c9be18df5bf8ad19c 100644 (file)
@@ -62,6 +62,19 @@ static inline int uncached_access(struct file *file, unsigned long addr)
                  test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) ||
                  test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) )
          && addr >= __pa(high_memory);
+#elif defined(__x86_64__)
+       /* 
+        * This is broken because it can generate memory type aliases,
+        * which can cause cache corruptions
+        * But it is only available for root and we have to be bug-to-bug
+        * compatible with i386.
+        */
+       if (file->f_flags & O_SYNC)
+               return 1;
+       /* same behaviour as i386. PAT always set to cached and MTRRs control the
+          caching behaviour. 
+          Hopefully a full PAT implementation will fix that soon. */      
+       return 0;
 #elif defined(CONFIG_IA64)
        /*
         * On ia64, we ignore O_SYNC because we cannot tolerate memory attribute aliases.