aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-01-18 20:42:48 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-18 22:20:20 -0500
commit09ee011eb322c2072ec184a88763c250a5485d8b (patch)
treeea13731ab3d7fe143b27b0f060956b3cec0f727a /arch/um/os-Linux
parentabaf69773d8dda98b917d94c07757f6520da7bec (diff)
[PATCH] uml: eliminate some globals
Stop using global variables to hold the file descriptor and offset used to map the skas0 stubs. Instead, calculate them using the page physical addresses. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r--arch/um/os-Linux/skas/process.c28
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
153extern int __syscall_stub_start; 153extern int __syscall_stub_start;
154int stub_code_fd = -1;
155__u64 stub_code_offset;
156 154
157static int userspace_tramp(void *stack) 155static 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))