Ok, I just finished making the modifications, essentially
rewriting vm_map_growstack() and vm_map_stack().
http://www.backplane.com/FreeBSD4/
http://www.backplane.com/FreeBSD4/guard-3.diff
http://www.backplane.com/FreeBSD4/guard3.c
Here are the proposed semantics:
* When you mmap() with MAP_STACK, the stack you map is
limited to the number of bytes specified in the mmap()
AND ALSO limited by the process stack resource limit
(on a per-mmap basis).
That is, *EACH* MAP_STACK mmaping may utilize up to
the process stack resource and no more, even if you
mmap a larger area.
This may be a little controversial but it's basically
how the kernel allocates the default user stack -- it
allocates the maximum kernel limit and assumes the
stack will be limited by the stack resource. I think
it could be useful for debugging, too.
(Also, with MAP_STACK, a fixed address and an anonymous
mmap is implied, and the mmap() will fail if the
specified region already contains mappings).
* When you mmap() with MAP_GUARDED, the offset field in
the mmap() call specifies the number of guard pages
at the beginning and end of the map. If you specify 0,
you don't get any guard pages (which is kinda useless).
Normally getpagesize() bytes is specified.
An anonymous mmap is implied.
* When you mmap() with MAP_GUARDED|MAP_STACK, you get
a guarded stack. The system will not create a
growable stack, though, it pre-reserves the space
(but, of course, does not allocate physical pages
for things you haven't touched).
The new semantics use the offset field in the mmap to
indicate the number of guard pages at the beginning and
end of the map, in bytes, so the semantics of MAP_GUARDED
mmap's has been changed somewhat. You nominally have
to call it with an offset of getpagesize() to get the
'single guard page at beginning and end' behavior.
So, to make the threads library use this you mmap
MAP_STACK|MAP_GUARDED with an offset of getpagesize()
(or more).
-Matt
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message