aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel/skas/mmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/kernel/skas/mmu.c')
-rw-r--r--arch/um/kernel/skas/mmu.c68
1 files changed, 23 insertions, 45 deletions
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 007d5503f49b..94abdcc1d6ad 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -54,35 +54,22 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
54 unsigned long stack = 0; 54 unsigned long stack = 0;
55 int ret = -ENOMEM; 55 int ret = -ENOMEM;
56 56
57 if (skas_needs_stub) { 57 stack = get_zeroed_page(GFP_KERNEL);
58 stack = get_zeroed_page(GFP_KERNEL); 58 if (stack == 0)
59 if (stack == 0) 59 goto out;
60 goto out;
61 }
62 60
63 to_mm->id.stack = stack; 61 to_mm->id.stack = stack;
64 if (current->mm != NULL && current->mm != &init_mm) 62 if (current->mm != NULL && current->mm != &init_mm)
65 from_mm = &current->mm->context; 63 from_mm = &current->mm->context;
66 64
67 if (proc_mm) { 65 if (from_mm)
68 ret = new_mm(stack); 66 to_mm->id.u.pid = copy_context_skas0(stack,
69 if (ret < 0) { 67 from_mm->id.u.pid);
70 printk(KERN_ERR "init_new_context_skas - " 68 else to_mm->id.u.pid = start_userspace(stack);
71 "new_mm failed, errno = %d\n", ret); 69
72 goto out_free; 70 if (to_mm->id.u.pid < 0) {
73 } 71 ret = to_mm->id.u.pid;
74 to_mm->id.u.mm_fd = ret; 72 goto out_free;
75 }
76 else {
77 if (from_mm)
78 to_mm->id.u.pid = copy_context_skas0(stack,
79 from_mm->id.u.pid);
80 else to_mm->id.u.pid = start_userspace(stack);
81
82 if (to_mm->id.u.pid < 0) {
83 ret = to_mm->id.u.pid;
84 goto out_free;
85 }
86 } 73 }
87 74
88 ret = init_new_ldt(to_mm, from_mm); 75 ret = init_new_ldt(to_mm, from_mm);
@@ -105,9 +92,6 @@ void uml_setup_stubs(struct mm_struct *mm)
105{ 92{
106 int err, ret; 93 int err, ret;
107 94
108 if (!skas_needs_stub)
109 return;
110
111 ret = init_stub_pte(mm, STUB_CODE, 95 ret = init_stub_pte(mm, STUB_CODE,
112 (unsigned long) &__syscall_stub_start); 96 (unsigned long) &__syscall_stub_start);
113 if (ret) 97 if (ret)
@@ -154,25 +138,19 @@ void destroy_context(struct mm_struct *mm)
154{ 138{
155 struct mm_context *mmu = &mm->context; 139 struct mm_context *mmu = &mm->context;
156 140
157 if (proc_mm) 141 /*
158 os_close_file(mmu->id.u.mm_fd); 142 * If init_new_context wasn't called, this will be
159 else { 143 * zero, resulting in a kill(0), which will result in the
160 /* 144 * whole UML suddenly dying. Also, cover negative and
161 * If init_new_context wasn't called, this will be 145 * 1 cases, since they shouldn't happen either.
162 * zero, resulting in a kill(0), which will result in the 146 */
163 * whole UML suddenly dying. Also, cover negative and 147 if (mmu->id.u.pid < 2) {
164 * 1 cases, since they shouldn't happen either. 148 printk(KERN_ERR "corrupt mm_context - pid = %d\n",
165 */ 149 mmu->id.u.pid);
166 if (mmu->id.u.pid < 2) { 150 return;
167 printk(KERN_ERR "corrupt mm_context - pid = %d\n",
168 mmu->id.u.pid);
169 return;
170 }
171 os_kill_ptraced_process(mmu->id.u.pid, 1);
172 } 151 }
152 os_kill_ptraced_process(mmu->id.u.pid, 1);
173 153
174 if (skas_needs_stub) 154 free_page(mmu->id.stack);
175 free_page(mmu->id.stack);
176
177 free_ldt(mmu); 155 free_ldt(mmu);
178} 156}