linux32_machdep.c (9b44bfc5560bf0cf1da18eaadb3a9da279a76efa) | linux32_machdep.c (0eef2f8a4e5f42f98983e352732b9d883d96c53a) |
---|---|
1/*- 2 * Copyright (c) 2004 Tim J. Robbins 3 * Copyright (c) 2002 Doug Rabson 4 * Copyright (c) 2000 Marcel Moolenaar 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 498 unchanged lines hidden (view full) --- 507 if (error) 508 return (error); 509 510 511 PROC_LOCK(p2); 512 p2->p_sigparent = exit_signal; 513 PROC_UNLOCK(p2); 514 td2 = FIRST_THREAD_IN_PROC(p2); | 1/*- 2 * Copyright (c) 2004 Tim J. Robbins 3 * Copyright (c) 2002 Doug Rabson 4 * Copyright (c) 2000 Marcel Moolenaar 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 498 unchanged lines hidden (view full) --- 507 if (error) 508 return (error); 509 510 511 PROC_LOCK(p2); 512 p2->p_sigparent = exit_signal; 513 PROC_UNLOCK(p2); 514 td2 = FIRST_THREAD_IN_PROC(p2); |
515 /* in a case of stack = NULL we are supposed to COW calling process stack | 515 /* 516 * in a case of stack = NULL we are supposed to COW calling process stack |
516 * this is what normal fork() does so we just keep the tf_rsp arg intact 517 */ 518 if (args->stack) 519 td2->td_frame->tf_rsp = PTROUT(args->stack); 520 521#ifdef DEBUG 522 if (ldebug(clone)) 523 printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"), --- 99 unchanged lines hidden (view full) --- 623 bsd_args.flags |= MAP_FIXED; 624 if (linux_args->flags & LINUX_MAP_ANON) 625 bsd_args.flags |= MAP_ANON; 626 else 627 bsd_args.flags |= MAP_NOSYNC; 628 if (linux_args->flags & LINUX_MAP_GROWSDOWN) { 629 bsd_args.flags |= MAP_STACK; 630 | 517 * this is what normal fork() does so we just keep the tf_rsp arg intact 518 */ 519 if (args->stack) 520 td2->td_frame->tf_rsp = PTROUT(args->stack); 521 522#ifdef DEBUG 523 if (ldebug(clone)) 524 printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"), --- 99 unchanged lines hidden (view full) --- 624 bsd_args.flags |= MAP_FIXED; 625 if (linux_args->flags & LINUX_MAP_ANON) 626 bsd_args.flags |= MAP_ANON; 627 else 628 bsd_args.flags |= MAP_NOSYNC; 629 if (linux_args->flags & LINUX_MAP_GROWSDOWN) { 630 bsd_args.flags |= MAP_STACK; 631 |
631 /* The linux MAP_GROWSDOWN option does not limit auto | 632 /* 633 * The linux MAP_GROWSDOWN option does not limit auto |
632 * growth of the region. Linux mmap with this option 633 * takes as addr the inital BOS, and as len, the initial 634 * region size. It can then grow down from addr without 635 * limit. However, linux threads has an implicit internal 636 * limit to stack size of STACK_SIZE. Its just not 637 * enforced explicitly in linux. But, here we impose 638 * a limit of (STACK_SIZE - GUARD_SIZE) on the stack 639 * region, since we can do this with our mmap. --- 10 unchanged lines hidden (view full) --- 650 */ 651 652 /* This gives us TOS */ 653 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) + 654 linux_args->len; 655 656 if ((caddr_t)PTRIN(bsd_args.addr) > 657 p->p_vmspace->vm_maxsaddr) { | 634 * growth of the region. Linux mmap with this option 635 * takes as addr the inital BOS, and as len, the initial 636 * region size. It can then grow down from addr without 637 * limit. However, linux threads has an implicit internal 638 * limit to stack size of STACK_SIZE. Its just not 639 * enforced explicitly in linux. But, here we impose 640 * a limit of (STACK_SIZE - GUARD_SIZE) on the stack 641 * region, since we can do this with our mmap. --- 10 unchanged lines hidden (view full) --- 652 */ 653 654 /* This gives us TOS */ 655 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) + 656 linux_args->len; 657 658 if ((caddr_t)PTRIN(bsd_args.addr) > 659 p->p_vmspace->vm_maxsaddr) { |
658 /* Some linux apps will attempt to mmap | 660 /* 661 * Some linux apps will attempt to mmap |
659 * thread stacks near the top of their 660 * address space. If their TOS is greater 661 * than vm_maxsaddr, vm_map_growstack() 662 * will confuse the thread stack with the 663 * process stack and deliver a SEGV if they 664 * attempt to grow the thread stack past their 665 * current stacksize rlimit. To avoid this, 666 * adjust vm_maxsaddr upwards to reflect --- 11 unchanged lines hidden (view full) --- 678 } 679 680 /* This gives us our maximum stack size */ 681 if (linux_args->len > STACK_SIZE - GUARD_SIZE) 682 bsd_args.len = linux_args->len; 683 else 684 bsd_args.len = STACK_SIZE - GUARD_SIZE; 685 | 662 * thread stacks near the top of their 663 * address space. If their TOS is greater 664 * than vm_maxsaddr, vm_map_growstack() 665 * will confuse the thread stack with the 666 * process stack and deliver a SEGV if they 667 * attempt to grow the thread stack past their 668 * current stacksize rlimit. To avoid this, 669 * adjust vm_maxsaddr upwards to reflect --- 11 unchanged lines hidden (view full) --- 681 } 682 683 /* This gives us our maximum stack size */ 684 if (linux_args->len > STACK_SIZE - GUARD_SIZE) 685 bsd_args.len = linux_args->len; 686 else 687 bsd_args.len = STACK_SIZE - GUARD_SIZE; 688 |
686 /* This gives us a new BOS. If we're using VM_STACK, then | 689 /* 690 * This gives us a new BOS. If we're using VM_STACK, then |
687 * mmap will just map the top SGROWSIZ bytes, and let 688 * the stack grow down to the limit at BOS. If we're 689 * not using VM_STACK we map the full stack, since we 690 * don't have a way to autogrow it. 691 */ 692 bsd_args.addr -= bsd_args.len; 693 } else { 694 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr); --- 321 unchanged lines hidden --- | 691 * mmap will just map the top SGROWSIZ bytes, and let 692 * the stack grow down to the limit at BOS. If we're 693 * not using VM_STACK we map the full stack, since we 694 * don't have a way to autogrow it. 695 */ 696 bsd_args.addr -= bsd_args.len; 697 } else { 698 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr); --- 321 unchanged lines hidden --- |