Skip to contentSkip to conversation

Incorrect #ifdef in arch/x86/mm/pat.c

PATCH Dheeraj Reddy 2 participants 2 messages Feb 20, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello there,
The checks for reading /dev/kmem and /dev/mem in arch/x86/mm/pat.c seems to
be incorrect when CONFIG_STRICT_DEVMEM is set.
Following patch corrects it.
The check should always return 1 when CONFIG_STRICT_DEVMEM is not defined, similar to what is in drivers/char/mem.c

truly
dheeraj

[dreddy-desktop:~/Ksources/git.linux-2.6]$ git diff
arch/x86/mm/pat.c +0 -0
index aebbf67..2aff276 100644
@@ -503,12 +503,6 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned 

l
}

#ifdef CONFIG_STRICT_DEVMEM
-/* This check is done in drivers/char/mem.c in case of STRICT_DEVMEM*/ -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) {
@@ -531,6 +525,12 @@ static inline int range_is_allowed(unsigned long pfn, unsig

        }
        return 1;

}
+#else
+/* This check is done in drivers/char/mem.c in case of STRICT_DEVMEM*/ +static inline int range_is_allowed(unsigned long pfn, unsigned long size) +{
+ return 1;
+}
#endif /* CONFIG_STRICT_DEVMEM */

int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,

#1 lore raw
Quoted 6 lines · Dheeraj Reddy

Hello there,
The checks for reading /dev/kmem and /dev/mem in arch/x86/mm/pat.c seems to
be incorrect when CONFIG_STRICT_DEVMEM is set.
Following patch corrects it.
The check should always return 1 when CONFIG_STRICT_DEVMEM is not defined, similar to what is in drivers/char/mem.c

no - see the comment in pat.c:

/* This check is done in drivers/char/mem.c in case of STRICT_DEVMEM*/

Ingo