MFC: sys/amd64/linux32/linux32_machdep.c 1.46

sys/i386/linux/linux_machdep.c		1.80

Fix Linux mmap with MAP_GROWSDOWN flag.
This commit is contained in:
jkim 2008-02-14 18:41:00 +00:00
parent 926347d060
commit e5908a9796
2 changed files with 29 additions and 27 deletions

View File

@ -720,21 +720,22 @@ linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
PROC_UNLOCK(p);
}
/* This gives us our maximum stack size */
if (linux_args->len > STACK_SIZE - GUARD_SIZE)
bsd_args.len = linux_args->len;
else
bsd_args.len = STACK_SIZE - GUARD_SIZE;
/*
* This gives us a new BOS. If we're using VM_STACK, then
* mmap will just map the top SGROWSIZ bytes, and let
* the stack grow down to the limit at BOS. If we're
* not using VM_STACK we map the full stack, since we
* don't have a way to autogrow it.
* This gives us our maximum stack size and a new BOS.
* If we're using VM_STACK, then mmap will just map
* the top SGROWSIZ bytes, and let the stack grow down
* to the limit at BOS. If we're not using VM_STACK
* we map the full stack, since we don't have a way
* to autogrow it.
*/
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
bsd_args.len;
if (linux_args->len > STACK_SIZE - GUARD_SIZE) {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
bsd_args.len = linux_args->len;
} else {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
(STACK_SIZE - GUARD_SIZE - linux_args->len);
bsd_args.len = STACK_SIZE - GUARD_SIZE;
}
} else {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
bsd_args.len = linux_args->len;

View File

@ -570,21 +570,22 @@ linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
PROC_UNLOCK(p);
}
/* This gives us our maximum stack size */
if (linux_args->len > STACK_SIZE - GUARD_SIZE)
bsd_args.len = linux_args->len;
else
bsd_args.len = STACK_SIZE - GUARD_SIZE;
/*
* This gives us a new BOS. If we're using VM_STACK, then
* mmap will just map the top SGROWSIZ bytes, and let
* the stack grow down to the limit at BOS. If we're
* not using VM_STACK we map the full stack, since we
* don't have a way to autogrow it.
/*
* This gives us our maximum stack size and a new BOS.
* If we're using VM_STACK, then mmap will just map
* the top SGROWSIZ bytes, and let the stack grow down
* to the limit at BOS. If we're not using VM_STACK
* we map the full stack, since we don't have a way
* to autogrow it.
*/
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
bsd_args.len;
if (linux_args->len > STACK_SIZE - GUARD_SIZE) {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
bsd_args.len = linux_args->len;
} else {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
(STACK_SIZE - GUARD_SIZE - linux_args->len);
bsd_args.len = STACK_SIZE - GUARD_SIZE;
}
} else {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
bsd_args.len = linux_args->len;