Drop obsoleted patch.
[linux-flexiantxendom0-3.2.10.git] / arch / s390 / kernel / compat_exec.c
1 /*
2  * Support for 32-bit Linux for S390 ELF binaries.
3  *
4  * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
5  * Author(s): Gerhard Tonn (ton@de.ibm.com)
6  *
7  * Separated from binfmt_elf32.c to reduce exports for module enablement.
8  *
9  */
10
11 #include <linux/config.h>
12 #include <linux/slab.h>
13 #include <linux/file.h>
14 #include <linux/mman.h>
15 #include <linux/a.out.h>
16 #include <linux/stat.h>
17 #include <linux/fcntl.h>
18 #include <linux/smp_lock.h>
19 #include <linux/init.h>
20 #include <linux/pagemap.h>
21 #include <linux/mm.h>
22 #include <linux/highmem.h>
23 #include <linux/spinlock.h>
24 #include <linux/binfmts.h>
25 #include <linux/module.h>
26 #include <linux/security.h>
27
28 #include <asm/uaccess.h>
29 #include <asm/pgalloc.h>
30 #include <asm/mmu_context.h>
31
32 #ifdef CONFIG_KMOD
33 #include <linux/kmod.h>
34 #endif
35
36
37 int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack)
38 {
39         unsigned long stack_base;
40         struct vm_area_struct *mpnt;
41         struct mm_struct *mm = current->mm;
42         int i, ret;
43
44         stack_base = STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE;
45         mm->arg_start = bprm->p + stack_base;
46
47         bprm->p += stack_base;
48         if (bprm->loader)
49                 bprm->loader += stack_base;
50         bprm->exec += stack_base;
51
52         mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
53         if (!mpnt) 
54                 return -ENOMEM; 
55         
56         if (security_vm_enough_memory((STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
57                 kmem_cache_free(vm_area_cachep, mpnt);
58                 return -ENOMEM;
59         }
60
61         memset(mpnt, 0, sizeof(*mpnt));
62
63         down_write(&mm->mmap_sem);
64         {
65                 mpnt->vm_mm = mm;
66                 mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
67                 mpnt->vm_end = STACK_TOP;
68                 /* executable stack setting would be applied here */
69                 mpnt->vm_page_prot = PAGE_COPY;
70                 mpnt->vm_flags = VM_STACK_FLAGS;
71                 if ((ret = insert_vm_struct(mm, mpnt))) {
72                         up_write(&mm->mmap_sem);
73                         kmem_cache_free(vm_area_cachep, mpnt);
74                         return ret;
75                 }
76                 mm->stack_vm = mm->total_vm = vma_pages(mpnt);
77         } 
78
79         for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
80                 struct page *page = bprm->page[i];
81                 if (page) {
82                         bprm->page[i] = NULL;
83                         install_arg_page(mpnt, page, stack_base);
84                 }
85                 stack_base += PAGE_SIZE;
86         }
87         up_write(&mm->mmap_sem);
88         
89         return 0;
90 }
91
92 EXPORT_SYMBOL(setup_arg_pages32);