lkml.org 
[lkml]   [2008]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] x86: Fix /dev/mem mmap breakage when PAT is disabled

* Ravikiran G Thirumalai <kiran@scalex86.org> wrote:

> 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 mmap to regular kernel memory
> succeeds if CONFIG_STRICT_DEVMEM=n and
> PAT is disabled. 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>
>
> Index: git.tip/arch/x86/mm/pat.c
> ===================================================================
> --- git.tip.orig/arch/x86/mm/pat.c 2008-10-21 14:02:57.000000000 -0700
> +++ git.tip/arch/x86/mm/pat.c 2008-10-29 13:19:47.000000000 -0800
> @@ -481,6 +481,7 @@
> 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;
> @@ -508,7 +509,8 @@
> unsigned long flags = -1;
> int retval;
>
> - if (!range_is_allowed(pfn, size))
> + /* Ensure cache aliasing does not occur if and only if PAT is on */
> + if (pat_enabled && !range_is_allowed(pfn, size))
> return 0;

I guess it might be cleaner to push this check into the
range_is_allowed() function?

Ingo


\
 
 \ /
  Last update: 2008-10-30 19:31    [W:0.129 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site