[question] What's the difference between /dev/kmem and /dev/mem

Steven Rostedt
2005-08-11T21:36:33Z

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