According to filemap_no_page:
/*
* Semantics for shared and private memory areas are different
* past the end of the file. A shared mapping past the last page
* of the file is an error and results in a SIGBUS, while a
* private mapping just maps in a zero page.
*/
Of course you're using a shared mapping so that the page alias works, if
you want write access to both pages, right?
So you have to fill the file. Seek to one byte before the last in your
range, and write a single byte. Holes should not bus error, but access
beyond the end of the file does bus error.
What is odd is that you are able to access even the first page. IMO
that should bus error too.
> Maybe filling
> it up does the trick - however then the process will get a private copy
> of all pages in this 1Meg - even the ones that are not touched by the BIOS.
> This will give me a 1Meg footprint for each real mode image.
Create the file and fill it using lseek/write. Then only 1 page is
actually allocated in the filesystem and process image. (You can play
with ftruncate() to get 0 pages -- make the file a bit longer, then
ftruncate it to remove block allocated by the write).
When you mmap a file, no memory is actually used until someone touches
the pages. For a file that's all hole, no disk space is used either so
this is quite efficient.
It would be nice if reading an mmaped hole would map the zero page, but
I had a quick look at the path through filemap_no_page and
block_read_full_page, and it doesn't seem to do that. Since the BIOS
will probably write to every page it touches that's not such a big deal.
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/