diff options
Diffstat (limited to 'arch/um/os-Linux/skas/process.c')
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index f787854322c4..b959b2618b7f 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -151,8 +151,6 @@ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu | |||
151 | } | 151 | } |
152 | 152 | ||
153 | extern int __syscall_stub_start; | 153 | extern int __syscall_stub_start; |
154 | int stub_code_fd = -1; | ||
155 | __u64 stub_code_offset; | ||
156 | 154 | ||
157 | static int userspace_tramp(void *stack) | 155 | static int userspace_tramp(void *stack) |
158 | { | 156 | { |
@@ -167,30 +165,30 @@ static int userspace_tramp(void *stack) | |||
167 | /* This has a pte, but it can't be mapped in with the usual | 165 | /* This has a pte, but it can't be mapped in with the usual |
168 | * tlb_flush mechanism because this is part of that mechanism | 166 | * tlb_flush mechanism because this is part of that mechanism |
169 | */ | 167 | */ |
168 | int fd; | ||
169 | __u64 offset; | ||
170 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); | ||
170 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, page_size(), | 171 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, page_size(), |
171 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, | 172 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); |
172 | stub_code_fd, stub_code_offset); | ||
173 | if(addr == MAP_FAILED){ | 173 | if(addr == MAP_FAILED){ |
174 | printk("mapping stub code failed, errno = %d\n", | 174 | printk("mapping mmap stub failed, errno = %d\n", |
175 | errno); | 175 | errno); |
176 | exit(1); | 176 | exit(1); |
177 | } | 177 | } |
178 | 178 | ||
179 | if(stack != NULL){ | 179 | if(stack != NULL){ |
180 | int fd; | ||
181 | __u64 offset; | ||
182 | fd = phys_mapping(to_phys(stack), &offset); | 180 | fd = phys_mapping(to_phys(stack), &offset); |
183 | addr = mmap((void *) UML_CONFIG_STUB_DATA, page_size(), | 181 | addr = mmap((void *) UML_CONFIG_STUB_DATA, page_size(), |
184 | PROT_READ | PROT_WRITE, | 182 | PROT_READ | PROT_WRITE, |
185 | MAP_FIXED | MAP_SHARED, fd, offset); | 183 | MAP_FIXED | MAP_SHARED, fd, offset); |
186 | if(addr == MAP_FAILED){ | 184 | if(addr == MAP_FAILED){ |
187 | printk("mapping stub stack failed, " | 185 | printk("mapping segfault stack failed, " |
188 | "errno = %d\n", errno); | 186 | "errno = %d\n", errno); |
189 | exit(1); | 187 | exit(1); |
190 | } | 188 | } |
191 | } | 189 | } |
192 | } | 190 | } |
193 | if(!ptrace_faultinfo){ | 191 | if(!ptrace_faultinfo && (stack != NULL)){ |
194 | unsigned long v = UML_CONFIG_STUB_CODE + | 192 | unsigned long v = UML_CONFIG_STUB_CODE + |
195 | (unsigned long) stub_segv_handler - | 193 | (unsigned long) stub_segv_handler - |
196 | (unsigned long) &__syscall_stub_start; | 194 | (unsigned long) &__syscall_stub_start; |
@@ -216,10 +214,6 @@ int start_userspace(unsigned long stub_stack) | |||
216 | unsigned long sp; | 214 | unsigned long sp; |
217 | int pid, status, n, flags; | 215 | int pid, status, n, flags; |
218 | 216 | ||
219 | if ( stub_code_fd == -1 ) | ||
220 | stub_code_fd = phys_mapping(to_phys(&__syscall_stub_start), | ||
221 | &stub_code_offset); | ||
222 | |||
223 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, | 217 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, |
224 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 218 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
225 | if(stack == MAP_FAILED) | 219 | if(stack == MAP_FAILED) |
@@ -306,7 +300,6 @@ void userspace(union uml_pt_regs *regs) | |||
306 | printk("userspace - child stopped with signal " | 300 | printk("userspace - child stopped with signal " |
307 | "%d\n", WSTOPSIG(status)); | 301 | "%d\n", WSTOPSIG(status)); |
308 | } | 302 | } |
309 | again: | ||
310 | pid = userspace_pid[0]; | 303 | pid = userspace_pid[0]; |
311 | interrupt_end(); | 304 | interrupt_end(); |
312 | 305 | ||
@@ -395,6 +388,9 @@ void map_stub_pages(int fd, unsigned long code, | |||
395 | { | 388 | { |
396 | struct proc_mm_op mmop; | 389 | struct proc_mm_op mmop; |
397 | int n; | 390 | int n; |
391 | __u64 code_offset; | ||
392 | int code_fd = phys_mapping(to_phys((void *) &__syscall_stub_start), | ||
393 | &code_offset); | ||
398 | 394 | ||
399 | mmop = ((struct proc_mm_op) { .op = MM_MMAP, | 395 | mmop = ((struct proc_mm_op) { .op = MM_MMAP, |
400 | .u = | 396 | .u = |
@@ -403,8 +399,8 @@ void map_stub_pages(int fd, unsigned long code, | |||
403 | .len = PAGE_SIZE, | 399 | .len = PAGE_SIZE, |
404 | .prot = PROT_EXEC, | 400 | .prot = PROT_EXEC, |
405 | .flags = MAP_FIXED | MAP_PRIVATE, | 401 | .flags = MAP_FIXED | MAP_PRIVATE, |
406 | .fd = stub_code_fd, | 402 | .fd = code_fd, |
407 | .offset = stub_code_offset | 403 | .offset = code_offset |
408 | } } }); | 404 | } } }); |
409 | n = os_write_file(fd, &mmop, sizeof(mmop)); | 405 | n = os_write_file(fd, &mmop, sizeof(mmop)); |
410 | if(n != sizeof(mmop)) | 406 | if(n != sizeof(mmop)) |