public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ravikiran G Thirumalai <kiran@scalex86.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: venkatesh.pallipadi@intel.com, linux-kernel@vger.kernel.org,
	tim@scalemp.com, shai@scalex86.org,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	Arjan van de Ven <arjan@infradead.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [patch] x86: Fix /dev/mem mmap breakage when PAT is disabled
Date: Thu, 30 Oct 2008 13:59:21 -0700	[thread overview]
Message-ID: <20081030205921.GA6583@localdomain> (raw)
In-Reply-To: <20081030182902.GF14102@elte.hu>

On Thu, Oct 30, 2008 at 07:29:02PM +0100, Ingo Molnar wrote:
>
>I guess it might be cleaner to push this check into the 
>range_is_allowed() function?
>

OK.  Here it is.


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>

Index: git.tip/arch/x86/mm/pat.c
===================================================================
--- git.tip.orig/arch/x86/mm/pat.c	2008-10-29 13:19:51.000000000 -0800
+++ git.tip/arch/x86/mm/pat.c	2008-10-30 10:44:46.000000000 -0800
@@ -481,12 +481,16 @@
 	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

  reply	other threads:[~2008-10-30 20:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-30  2:02 [patch] x86: Fix /dev/mem mmap breakage when PAT is disabled Ravikiran G Thirumalai
2008-10-30 18:29 ` Ingo Molnar
2008-10-30 20:59   ` Ravikiran G Thirumalai [this message]
2008-10-30 22:55     ` Ingo Molnar
2008-10-30 20:21 ` Arjan van de Ven
2008-10-30 21:21   ` Ravikiran G Thirumalai
2008-10-30 21:29     ` Arjan van de Ven
2008-10-30 21:54       ` Ravikiran G Thirumalai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081030205921.GA6583@localdomain \
    --to=kiran@scalex86.org \
    --cc=arjan@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=shai@scalex86.org \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tim@scalemp.com \
    --cc=venkatesh.pallipadi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox