public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Dave Jones <davej@redhat.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: userspace mptable parsing broken in 2.6
Date: Thu, 12 Feb 2004 20:28:04 +0100	[thread overview]
Message-ID: <402BD3C4.1010905@colorfullife.com> (raw)
In-Reply-To: <20040211121350.GK12634@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Dave Jones wrote:

>Reading from some parts of /dev/mem is still broken in 2.6.3rc2,
>which breaks at least x86info.
>
>Manfred, in the end of the last thread on this at..
>http://www.ussg.iu.edu/hypermail/linux/kernel/0311.1/0373.html
>you mentioned you were going to add some code to /dev/mem for the
>DEBUG_PAGEALLOC case. Did you get anywhere with that?
>  
>
Sorry, I forgot about the issue.

What about the attached patch?

--
    Manfred

[-- Attachment #2: patch-debugpagealloc-mem --]
[-- Type: text/plain, Size: 1011 bytes --]

--- 2.6/drivers/char/mem.c	2004-02-08 13:08:30.000000000 +0100
+++ build-2.6/drivers/char/mem.c	2004-02-12 20:10:56.000000000 +0100
@@ -25,6 +25,7 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/ptrace.h>
 #include <linux/device.h>
+#include <linux/pagemap.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -151,10 +152,41 @@
 		}
 	}
 #endif
+#if CONFIG_DEBUG_PAGEALLOC
+	while (count) {
+		size_t i;
+		struct page *page;
+
+		i = PAGE_SIZE - (p%PAGE_SIZE);
+		if (i > count)
+			i = count;
+		if (virt_addr_valid(__va(p))) {
+			page = virt_to_page(__va(p));
+			get_page(page);
+			kernel_map_pages(page, 1, 1);
+		} else {
+			page = NULL;
+		}
+		if (copy_to_user(buf, __va(p), i)) {
+			if (page)
+				put_page(page);
+			return -EFAULT;
+		}
+		if (page)
+			put_page(page);
+		buf += i;
+		p += i;
+		count -= i;
+		read += i;
+	}
+#else
 	if (copy_to_user(buf, __va(p), count))
 		return -EFAULT;
+
+	p += count;
 	read += count;
-	*ppos += read;
+#endif
+	*ppos = p;
 	return read;
 }
 

  reply	other threads:[~2004-02-12 19:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-11 12:13 userspace mptable parsing broken in 2.6 Dave Jones
2004-02-12 19:28 ` Manfred Spraul [this message]
2004-02-19  3:54   ` Dave Jones

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=402BD3C4.1010905@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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