lkml.org 
[lkml]   [2005]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Date
From
SubjectRe: [BUG?] x86_64 : Can not read /dev/kmem ?
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-04-06 13:30    [W:0.106 / U:0.212 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site