add generic system call forwarding
This commit is contained in:
@@ -64,6 +64,8 @@ static void process_msg_prepare_process(unsigned long rphys)
|
||||
|
||||
proc = create_process(p->entry);
|
||||
proc->pid = 1024;
|
||||
proc->vm->region.user_start = pn->user_start;
|
||||
proc->vm->region.user_end = pn->user_end;
|
||||
|
||||
/* TODO: Clear it at the proper timing */
|
||||
cpu_local_var(scp).post_idx = 0;
|
||||
@@ -254,6 +256,7 @@ static void process_msg_prepare_process(unsigned long rphys)
|
||||
dkprintf("env OK\n");
|
||||
|
||||
p->rprocess = (unsigned long)proc;
|
||||
p->rpgtable = virt_to_phys(proc->vm->page_table);
|
||||
init_process_stack(proc, pn, argc, argv, envc, env);
|
||||
|
||||
dkprintf("new process : %p [%d] / table : %p\n", proc, proc->pid,
|
||||
|
||||
@@ -40,6 +40,7 @@ struct vm_regions {
|
||||
unsigned long brk_start, brk_end;
|
||||
unsigned long map_start, map_end;
|
||||
unsigned long stack_start, stack_end;
|
||||
unsigned long user_start, user_end;
|
||||
};
|
||||
|
||||
struct process_vm;
|
||||
|
||||
@@ -89,7 +89,10 @@ struct program_load_desc {
|
||||
int cpu;
|
||||
int pid;
|
||||
unsigned long entry;
|
||||
unsigned long user_start;
|
||||
unsigned long user_end;
|
||||
unsigned long rprocess;
|
||||
unsigned long rpgtable;
|
||||
unsigned long at_phdr;
|
||||
unsigned long at_phent;
|
||||
unsigned long at_phnum;
|
||||
|
||||
@@ -140,6 +140,14 @@ int add_process_large_range(struct process *process,
|
||||
int npages_allocated = 0;
|
||||
void *virt;
|
||||
|
||||
if ((start < process->vm->region.user_start)
|
||||
|| (process->vm->region.user_end < end)) {
|
||||
kprintf("large range(%#lx - %#lx) is not in user avail(%#lx - %#lx)\n",
|
||||
start, end, process->vm->region.user_start,
|
||||
process->vm->region.user_end);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
range = kmalloc(sizeof(struct vm_range), 0);
|
||||
if (!range) {
|
||||
return -ENOMEM;
|
||||
@@ -194,6 +202,14 @@ int add_process_memory_range(struct process *process,
|
||||
{
|
||||
struct vm_range *range;
|
||||
|
||||
if ((start < process->vm->region.user_start)
|
||||
|| (process->vm->region.user_end < end)) {
|
||||
kprintf("range(%#lx - %#lx) is not in user avail(%#lx - %#lx)\n",
|
||||
start, end, process->vm->region.user_start,
|
||||
process->vm->region.user_end);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
range = kmalloc(sizeof(struct vm_range), 0);
|
||||
if (!range) {
|
||||
return -ENOMEM;
|
||||
@@ -239,16 +255,15 @@ void init_process_stack(struct process *process, struct program_load_desc *pn,
|
||||
{
|
||||
int s_ind = 0;
|
||||
int arg_ind;
|
||||
unsigned long size = USER_STACK_NR_PAGES * PAGE_SIZE;
|
||||
char *stack = ihk_mc_alloc_pages(USER_STACK_NR_PAGES, 0);
|
||||
unsigned long *p = (unsigned long *)(stack +
|
||||
(USER_STACK_NR_PAGES * PAGE_SIZE));
|
||||
unsigned long *p = (unsigned long *)(stack + size);
|
||||
unsigned long end = process->vm->region.user_end;
|
||||
unsigned long start = end - size;
|
||||
|
||||
memset(stack, 0, USER_STACK_NR_PAGES * PAGE_SIZE);
|
||||
memset(stack, 0, size);
|
||||
|
||||
add_process_memory_range(process, USER_END -
|
||||
(USER_STACK_NR_PAGES * PAGE_SIZE),
|
||||
USER_END,
|
||||
virt_to_phys(stack), VR_STACK);
|
||||
add_process_memory_range(process, start, end, virt_to_phys(stack), VR_STACK);
|
||||
|
||||
s_ind = -1;
|
||||
p[s_ind--] = 0; /* AT_NULL */
|
||||
@@ -274,10 +289,9 @@ void init_process_stack(struct process *process, struct program_load_desc *pn,
|
||||
p[s_ind] = argc;
|
||||
|
||||
ihk_mc_modify_user_context(process->uctx, IHK_UCR_STACK_POINTER,
|
||||
USER_END + sizeof(unsigned long) * s_ind);
|
||||
process->vm->region.stack_end = USER_END;
|
||||
process->vm->region.stack_start = USER_END -
|
||||
(USER_STACK_NR_PAGES * PAGE_SIZE);
|
||||
end + sizeof(unsigned long) * s_ind);
|
||||
process->vm->region.stack_end = end;
|
||||
process->vm->region.stack_start = start;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1291,6 +1291,14 @@ static int clone_init(void)
|
||||
|
||||
#endif
|
||||
|
||||
long syscall_generic_forwarding(int n, ihk_mc_user_context_t *ctx)
|
||||
{
|
||||
SYSCALL_HEADER;
|
||||
dkprintf("syscall_generic_forwarding(%d)\n", n);
|
||||
SYSCALL_ARGS_6(D,D,D,D,D,D);
|
||||
SYSCALL_FOOTER;
|
||||
}
|
||||
|
||||
long syscall(int num, ihk_mc_user_context_t *ctx)
|
||||
{
|
||||
long l;
|
||||
@@ -1324,7 +1332,8 @@ long syscall(int num, ihk_mc_user_context_t *ctx)
|
||||
dkprintf("\n");
|
||||
|
||||
|
||||
if (syscall_table[num]) {
|
||||
if ((0 <= num) && (num < sizeof(syscall_table)/sizeof(syscall_table[0]))
|
||||
&& (syscall_table[num] != NULL)) {
|
||||
l = syscall_table[num](num, ctx);
|
||||
|
||||
dkprintf("SC(%d)[%3d] ret: %d\n",
|
||||
@@ -1335,8 +1344,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx)
|
||||
ihk_mc_syscall_arg2(ctx), ihk_mc_syscall_arg3(ctx),
|
||||
ihk_mc_syscall_arg4(ctx), ihk_mc_syscall_pc(ctx),
|
||||
ihk_mc_syscall_sp(ctx));
|
||||
//while(1);
|
||||
l = -ENOSYS;
|
||||
l = syscall_generic_forwarding(num, ctx);
|
||||
}
|
||||
|
||||
return l;
|
||||
|
||||
Reference in New Issue
Block a user