lkml.org 
[lkml]   [2005]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Subject[question] What's the difference between /dev/kmem and /dev/mem
From
Date
OK, I thought I use to know this. But what is the difference
between /dev/kmem and /dev/mem. I thought that with /dev/kmem you could
use the actual kernel addresses to read from.

For example, if I wanted to read the current variable X in the kernel, I
could look up the address of X in System.map, then mmaping to /dev/kmem
I could get to that variable using the address that I got from
System.map. But this doesn't seem to work.

I'm getting an IO error on read. And looking at this I see:


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);
}

I printed out the value in vma->vm_pgoff, and it still has the
0xc0000000 (but shifted >> 12). Isn't this suppose to also remove the
0xc? Or am I just totally off here?

Thanks,

-- Steve



-
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-08-11 23:39    [W:0.129 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site