]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86: fix /dev/mem mmap breakage when PAT is disabled
authorRavikiran G Thirumalai <kiran@scalex86.org>
Thu, 30 Oct 2008 20:59:21 +0000 (13:59 -0700)
committerIngo Molnar <mingo@elte.hu>
Thu, 30 Oct 2008 22:54:41 +0000 (23:54 +0100)
Impact: allow /dev/mem mmaps on non-PAT CPUs/platforms

Fix mmap to /dev/mem when CONFIG_X86_PAT is off and CONFIG_STRICT_DEVMEM is
off

mmap to /dev/mem on kernel memory has been failing since the
introduction of PAT (CONFIG_STRICT_DEVMEM=n case).   Seems like
the check to avoid cache aliasing with PAT is kicking in even
when PAT is disabled. The bug seems to have crept in 2.6.26.

This patch makes sure that the mmap to regular
kernel memory succeeds if CONFIG_STRICT_DEVMEM=n and
PAT is disabled, and the checks to avoid cache aliasing
still happens if PAT is enabled.

Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Tested-by: Tim Sirianni <tim@scalemp.com>
Cc: <stable@kernel.org>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/mm/pat.c

index 738fd0f2495823189daffbba1e5c836b227e6c25..eb1bf000d12e9b1aa1769284e263d43593095183 100644 (file)
@@ -481,12 +481,16 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
        return 1;
 }
 #else
+/* This check is needed to avoid cache aliasing when PAT is enabled */
 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
 {
        u64 from = ((u64)pfn) << PAGE_SHIFT;
        u64 to = from + size;
        u64 cursor = from;
 
+       if (!pat_enabled)
+               return 1;
+
        while (cursor < to) {
                if (!devmem_is_allowed(pfn)) {
                        printk(KERN_INFO