process.c (ef0470c053274c343b2be8737e0146d65e17f9be) process.c (a61f334fd2864b9b040f7e882726426ed7e8a317)
1/*
2 * Copyright (C) 2002- 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include <stdlib.h>
7#include <string.h>
8#include <unistd.h>

--- 417 unchanged lines hidden (view full) ---

426 { .mmap =
427 { .addr = code,
428 .len = PAGE_SIZE,
429 .prot = PROT_EXEC,
430 .flags = MAP_FIXED | MAP_PRIVATE,
431 .fd = code_fd,
432 .offset = code_offset
433 } } });
1/*
2 * Copyright (C) 2002- 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include <stdlib.h>
7#include <string.h>
8#include <unistd.h>

--- 417 unchanged lines hidden (view full) ---

426 { .mmap =
427 { .addr = code,
428 .len = PAGE_SIZE,
429 .prot = PROT_EXEC,
430 .flags = MAP_FIXED | MAP_PRIVATE,
431 .fd = code_fd,
432 .offset = code_offset
433 } } });
434 n = os_write_file(fd, &mmop, sizeof(mmop));
434 CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
435 if(n != sizeof(mmop)){
435 if(n != sizeof(mmop)){
436 n = errno;
436 printk("mmap args - addr = 0x%lx, fd = %d, offset = %llx\n",
437 code, code_fd, (unsigned long long) code_offset);
438 panic("map_stub_pages : /proc/mm map for code failed, "
437 printk("mmap args - addr = 0x%lx, fd = %d, offset = %llx\n",
438 code, code_fd, (unsigned long long) code_offset);
439 panic("map_stub_pages : /proc/mm map for code failed, "
439 "err = %d\n", -n);
440 "err = %d\n", n);
440 }
441
442 if ( stack ) {
443 __u64 map_offset;
444 int map_fd = phys_mapping(to_phys((void *)stack), &map_offset);
445 mmop = ((struct proc_mm_op)
446 { .op = MM_MMAP,
447 .u =
448 { .mmap =
449 { .addr = data,
450 .len = PAGE_SIZE,
451 .prot = PROT_READ | PROT_WRITE,
452 .flags = MAP_FIXED | MAP_SHARED,
453 .fd = map_fd,
454 .offset = map_offset
455 } } });
441 }
442
443 if ( stack ) {
444 __u64 map_offset;
445 int map_fd = phys_mapping(to_phys((void *)stack), &map_offset);
446 mmop = ((struct proc_mm_op)
447 { .op = MM_MMAP,
448 .u =
449 { .mmap =
450 { .addr = data,
451 .len = PAGE_SIZE,
452 .prot = PROT_READ | PROT_WRITE,
453 .flags = MAP_FIXED | MAP_SHARED,
454 .fd = map_fd,
455 .offset = map_offset
456 } } });
456 n = os_write_file(fd, &mmop, sizeof(mmop));
457 CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
457 if(n != sizeof(mmop))
458 panic("map_stub_pages : /proc/mm map for data failed, "
458 if(n != sizeof(mmop))
459 panic("map_stub_pages : /proc/mm map for data failed, "
459 "err = %d\n", -n);
460 "err = %d\n", errno);
460 }
461}
462
463void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
464{
465 (*buf)[0].JB_IP = (unsigned long) handler;
466 (*buf)[0].JB_SP = (unsigned long) stack +
467 (PAGE_SIZE << UML_CONFIG_KERNEL_STACK_ORDER) - sizeof(void *);

--- 96 unchanged lines hidden ---
461 }
462}
463
464void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
465{
466 (*buf)[0].JB_IP = (unsigned long) handler;
467 (*buf)[0].JB_SP = (unsigned long) stack +
468 (PAGE_SIZE << UML_CONFIG_KERNEL_STACK_ORDER) - sizeof(void *);

--- 96 unchanged lines hidden ---