Commit f1eda416 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86-64: fix /dev/mem caching behaviour

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.
parent fb75a3d4
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment