I am working on an SH4 port of linux. Things that I am doing here
might seem totally unreasonable. But all this is an attempt to
overcome a hardware limitation with SH4, which allows a PCI memory
window of 16MB. In order for applications to be able to transparently
use more than that I need to do the following:
I anonymously mmap 16MB of PCI window memory into the user space using
the following call:
ptr = mmap((void*)0, 0x01000000, PROT_WRITE | PROT_READ,
MAP_SHARED|MAP_ANONYMOUS|MAP_PCI, -1, 0);
Within the kernel I use the MAP_PCI flag to call remap_page_range
from within the kernel and create page tables (I don't know of a
better way to build page tables for this map, please suggest if there
After this if I dump page tables I see that all mappings have been
correctly created. However, later on when the process makes more calls
to mmap(on other devices) I see the following error.
forget_pte: old mapping existed!
kernel BUG at memory.c:303!
What happens is that the pte_alloc gets a page which was earlier being
used by this anonymous mmap thereby overwriting the entries for the
anonymous mmap. This error happens with some apps and not with others.
On a side note when I see the memory map for this process I see the
anonymous entry as:
29800000-2a800000 rw-s 00000000 00:05 440 /dev/zero (deleted)
Anyone have an idea why the pte_alloc is getting an already used page?