2005-02-13 03:47:01

by Ryan Lortie

[permalink] [raw]
Subject: Strange /dev/mem behaviour on IA32, PPC64, (others?)

There are a couple of problems that I have encountered with /dev/mem on
the 2.6.10 kernel.

The first problem is that lseek()/read() results in different data than
mmap() and reading from the mapped memory area. I've written a small
program to demonstrate the problem. I am fairly sure it is correct (a
few others haved looked over it). The program produces unexpected
output when I run it on both IA32 and PPC64. You need to have at least
1GB of RAM to run it, but it is easy to modify if you have less.

In short, lseek()/read() returns what I believe to be the correct
values. Reading from the mmap() region gives the correct values for the
first few reads but after that it starts giving zeros.

In testing this program on IA32 I ran into an additional problem. If
you lseek() to the (very suspicious) 896MB mark and read() then read
gives EFAULT (Bad address).

I have high memory support enabled and the 'free' command reports:

total
Mem: 1036172

so seeking should be OK all the way up to 1GB.

Any information about these problems (including "you're wrong
because....") is appreciated. I'm not on the list, so please Cc:
replies.

Cheers.


Attachments:
fetch.c (920.00 B)