public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@muc.de>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Linux kernel <linux-kernel@vger.kernel.org>, akpm@osdl.org
Subject: Re: [BUG?] x86_64 : Can not read /dev/kmem ?
Date: 22 Mar 2005 16:24:42 +0100
Date: Tue, 22 Mar 2005 16:24:42 +0100	[thread overview]
Message-ID: <20050322152442.GA73893@muc.de> (raw)
In-Reply-To: <4235695F.5070203@cosmosbay.com>

On Mon, Mar 14, 2005 at 11:37:19AM +0100, Eric Dumazet wrote:
> 
> Hi Andi
> 
> I tried to mmap /dev/kmem on x86_64 (linux-2.6.11) and got no success.
> 

Here's a patch that fixes the problem to me.


Fix mmap of /dev/kmem. It cannot ever have worked before.

vmalloc is still not supported because that would be more
complicated.

Signed-off-by: Andi Kleen <ak@suse.de>


diff -u linux-2.6.11/drivers/char/mem.c-o linux-2.6.11/drivers/char/mem.c
--- linux-2.6.11/drivers/char/mem.c-o	2004-12-24 22:34:47.000000000 +0100
+++ linux-2.6.11/drivers/char/mem.c	2005-03-22 12:36:33.852319000 +0100
@@ -211,6 +211,23 @@
 	return 0;
 }
 
+static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
+{
+        unsigned long long val;
+	/* 
+	 * RED-PEN: on some architectures there is more mapped memory
+	 * than available in mem_map which pfn_valid checks
+	 * for. Perhaps should add a new macro here.
+	 * 
+	 * RED-PEN: vmalloc is not supported right now. 
+	 */
+	if (!pfn_valid(vma->vm_pgoff))
+		return -EIO;
+	val = (u64)vma->vm_pgoff << PAGE_SHIFT;
+	vma->vm_pgoff = __pa(val) >> PAGE_SHIFT; 
+	return mmap_mem(file, vma);
+}
+
 extern long vread(char *buf, char *addr, unsigned long count);
 extern long vwrite(char *buf, char *addr, unsigned long count);
 
@@ -567,7 +584,6 @@
 	return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
 }
 
-#define mmap_kmem	mmap_mem
 #define zero_lseek	null_lseek
 #define full_lseek      null_lseek
 #define write_zero	write_null

  parent reply	other threads:[~2005-03-22 15:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-13 18:20 [patch] x86: fix ESP corruption CPU bug Stas Sergeev
2005-03-13 18:52 ` Grzegorz Kulewski
2005-03-13 19:11   ` Stas Sergeev
2005-03-13 19:37     ` Ondrej Zary
2005-03-13 19:46       ` Stas Sergeev
2005-03-13 20:02   ` Pavel Machek
2005-03-13 20:10 ` Pavel Machek
2005-03-13 20:55   ` Stas Sergeev
2005-03-13 21:13     ` Linus Torvalds
2005-03-13 22:06       ` [patch] x86: fix ESP corruption CPU bug (take 2) Stas Sergeev
2005-03-14 19:29         ` Alan Cox
2005-03-14 19:59           ` Stas Sergeev
2005-03-15  3:34             ` Andrew Morton
2005-03-15 10:48               ` x86: spin_unlock(), spin_unlock_irq() & others are out of line ? Eric Dumazet
2005-03-15 19:44                 ` Lee Revell
2005-03-15 19:48               ` [patch] x86: fix ESP corruption CPU bug (take 2) Stas Sergeev
2005-03-13 23:17       ` [patch] x86: fix ESP corruption CPU bug Pavel Machek
2005-03-13 23:54         ` Linus Torvalds
2005-03-14  0:16       ` Linus Torvalds
2005-03-14  4:52         ` Stas Sergeev
2005-03-14  9:34           ` Andi Kleen
2005-03-14 10:37             ` [BUG?] x86_64 : Can not read /dev/kmem ? Eric Dumazet
2005-03-21 19:37               ` Andi Kleen
2005-03-22 15:24               ` Andi Kleen [this message]
2005-03-14 15:21             ` [patch] x86: fix ESP corruption CPU bug Jakob Eriksson
2005-03-14 17:03               ` linux-os
2005-03-14 17:10                 ` Pavel Machek
2005-03-14 19:24                 ` Brian Gerst
2005-03-14 20:21                   ` Stas Sergeev
2005-03-14 18:02               ` Stas Sergeev
2005-03-14 17:29             ` Stas Sergeev

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=20050322152442.GA73893@muc.de \
    --to=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=dada1@cosmosbay.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