Convert the ia64/ia32 compat binfmt code to the new way of doing things. Clean up the x86_64/ia32 code. Signed-off-by: Peter Zijlstra --- arch/ia64/ia32/binfmt_elf32.c | 59 ++++++----------------------------------- arch/x86_64/ia32/ia32_aout.c | 2 - arch/x86_64/ia32/ia32_binfmt.c | 7 ---- fs/exec.c | 3 -- 4 files changed, 11 insertions(+), 60 deletions(-) Index: linux-2.6-2/arch/x86_64/ia32/ia32_binfmt.c =================================================================== --- linux-2.6-2.orig/arch/x86_64/ia32/ia32_binfmt.c 2007-05-22 13:10:45.000000000 +0200 +++ linux-2.6-2/arch/x86_64/ia32/ia32_binfmt.c 2007-05-22 13:16:14.000000000 +0200 @@ -281,13 +281,6 @@ static void elf32_init(struct pt_regs *r me->thread.es = __USER_DS; } -int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, - int executable_stack) -{ - return setup_arg_pages(bprm, stack_top, executable_stack); -} -EXPORT_SYMBOL(ia32_setup_arg_pages); - #ifdef CONFIG_SYSCTL /* Register vsyscall32 into the ABI table */ #include Index: linux-2.6-2/arch/ia64/ia32/binfmt_elf32.c =================================================================== --- linux-2.6-2.orig/arch/ia64/ia32/binfmt_elf32.c 2007-05-22 13:10:45.000000000 +0200 +++ linux-2.6-2/arch/ia64/ia32/binfmt_elf32.c 2007-05-22 13:16:14.000000000 +0200 @@ -198,59 +198,18 @@ ia64_elf32_init (struct pt_regs *regs) int ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack) { - unsigned long stack_base; - struct vm_area_struct *mpnt; - struct mm_struct *mm = current->mm; - int i, ret; - - stack_base = IA32_STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE; - mm->arg_start = bprm->p + stack_base; - - bprm->p += stack_base; - if (bprm->loader) - bprm->loader += stack_base; - bprm->exec += stack_base; - - mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); - if (!mpnt) - return -ENOMEM; - - down_write(¤t->mm->mmap_sem); - { - mpnt->vm_mm = current->mm; - mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p; - mpnt->vm_end = IA32_STACK_TOP; - if (executable_stack == EXSTACK_ENABLE_X) - mpnt->vm_flags = VM_STACK_FLAGS | VM_EXEC; - else if (executable_stack == EXSTACK_DISABLE_X) - mpnt->vm_flags = VM_STACK_FLAGS & ~VM_EXEC; - else - mpnt->vm_flags = VM_STACK_FLAGS; - mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)? - PAGE_COPY_EXEC: PAGE_COPY; - if ((ret = insert_vm_struct(current->mm, mpnt))) { - up_write(¤t->mm->mmap_sem); - kmem_cache_free(vm_area_cachep, mpnt); - return ret; - } - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt); - } + int ret; - for (i = 0 ; i < MAX_ARG_PAGES ; i++) { - struct page *page = bprm->page[i]; - if (page) { - bprm->page[i] = NULL; - install_arg_page(mpnt, page, stack_base); - } - stack_base += PAGE_SIZE; + ret = setup_arg_pages(bprm, IA32_STACK_TOP, executable_stack); + if (!ret) { + /* + * Can't do it in ia64_elf32_init(). Needs to be done before + * calls to elf32_map() + */ + current->thread.ppl = ia32_init_pp_list(); } - up_write(¤t->mm->mmap_sem); - - /* Can't do it in ia64_elf32_init(). Needs to be done before calls to - elf32_map() */ - current->thread.ppl = ia32_init_pp_list(); - return 0; + return ret; } static void Index: linux-2.6-2/fs/exec.c =================================================================== --- linux-2.6-2.orig/fs/exec.c 2007-05-22 13:10:45.000000000 +0200 +++ linux-2.6-2/fs/exec.c 2007-05-22 13:16:14.000000000 +0200 @@ -535,14 +535,13 @@ int setup_arg_pages(struct linux_binprm stack_base = PAGE_ALIGN(stack_top - stack_base); /* Make sure we didn't let the argument array grow too large. */ - if (vma->vm_end - vma->vm_start > STACK_TOP - stack_base) + if (vma->vm_end - vma->vm_start > stack_base) return -ENOMEM; stack_shift = stack_base - vma->vm_start; mm->arg_start = bprm->p + stack_shift; bprm->p = vma->vm_end + stack_shift; #else - BUG_ON(stack_top > STACK_TOP); BUG_ON(stack_top & ~PAGE_MASK); stack_base = arch_align_stack(stack_top - mm->stack_vm*PAGE_SIZE); Index: linux-2.6-2/arch/x86_64/ia32/ia32_aout.c =================================================================== --- linux-2.6-2.orig/arch/x86_64/ia32/ia32_aout.c 2007-04-24 17:43:39.000000000 +0200 +++ linux-2.6-2/arch/x86_64/ia32/ia32_aout.c 2007-05-22 13:41:11.000000000 +0200 @@ -404,7 +404,7 @@ beyond_if: set_brk(current->mm->start_brk, current->mm->brk); - retval = ia32_setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT); + retval = setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT); if (retval < 0) { /* Someone check-me: is this error path enough? */ send_sig(SIGKILL, current, 0);