diff --git a/arch/x86_64/kernel/include/syscall_list.h b/arch/x86_64/kernel/include/syscall_list.h index 48b1ea0a..3d02f63a 100644 --- a/arch/x86_64/kernel/include/syscall_list.h +++ b/arch/x86_64/kernel/include/syscall_list.h @@ -39,7 +39,7 @@ SYSCALL_HANDLED(15, rt_sigreturn) SYSCALL_HANDLED(16, ioctl) SYSCALL_DELEGATED(17, pread64) SYSCALL_DELEGATED(18, pwrite64) -SYSCALL_DELEGATED(20, writev) +SYSCALL_HANDLED(20, writev) SYSCALL_DELEGATED(21, access) SYSCALL_DELEGATED(23, select) SYSCALL_HANDLED(24, sched_yield) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 48701c72..7fe97940 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -3320,7 +3320,6 @@ int main_loop(struct thread_data_s *my_thread) memset(&w, '\0', sizeof w); w.cpu = cpu; w.pid = getpid(); - while (((ret = ioctl(fd, MCEXEC_UP_WAIT_SYSCALL, (unsigned long)&w)) == 0) || (ret == -1 && errno == EINTR)) { if (ret) { @@ -4201,6 +4200,7 @@ return_execve2: } do_syscall_return(fd, cpu, ret, 0, 0, 0, 0); break; + case 801: {// swapout #ifdef ENABLE_QLMPI int rc; @@ -4390,6 +4390,11 @@ return_linux_spawn: break; } + case __NR_writev: + ret = do_generic_syscall(&w); + do_syscall_return(fd, cpu, ret, 0, 0, 0, 0); + break; + default: if (archdep_syscall(&w, &ret)) { ret = do_generic_syscall(&w); diff --git a/kernel/include/process.h b/kernel/include/process.h index 32021fd6..6579e799 100644 --- a/kernel/include/process.h +++ b/kernel/include/process.h @@ -573,6 +573,8 @@ struct process { #endif // PROFILE_ENABLE int nr_processes; /* For partitioned execution */ int process_rank; /* Rank in partition */ + + void *fd_priv_table[265]; }; /* diff --git a/kernel/process.c b/kernel/process.c index 287a40e8..c97c57a1 100644 --- a/kernel/process.c +++ b/kernel/process.c @@ -138,6 +138,11 @@ init_process(struct process *proc, struct process *parent) INIT_LIST_HEAD(&proc->ptraced_siblings_list); mcs_rwlock_init(&proc->update_lock); #endif /* POSTK_DEBUG_ARCH_DEP_63 */ + } + + // Double check the inheritance from parent + memset(proc->fd_priv_table, 0, 256 * sizeof(void *)); + INIT_LIST_HEAD(&proc->threads_list); INIT_LIST_HEAD(&proc->children_list); INIT_LIST_HEAD(&proc->ptraced_children_list); diff --git a/kernel/syscall.c b/kernel/syscall.c index 19144368..a8b289d4 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -67,6 +67,8 @@ #include #include +//#include + #define SYSCALL_BY_IKC //#define DEBUG_PRINT_SC @@ -480,6 +482,7 @@ long do_syscall(struct syscall_request *req, int cpu, int pid) if (req->number == __NR_open && rc > 0) { if (res.private_data && !strncmp(req->args[0], "/dev/hfi", 8)) { + thread->proc->fd_priv_table[rc] = res.private_data; kprintf("%s: PID: %d, open fd: %d, filename: %s, private_data: 0x%lx\n", __FUNCTION__, thread->proc->pid, rc, req->args[0], res.private_data); } @@ -3086,6 +3089,20 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) return 0; } +SYSCALL_DECLARE(writev) +{ + struct process *proc = cpu_local_var(current)->proc; + int fd = ihk_mc_syscall_arg0(ctx); + int iovcnt = ihk_mc_syscall_arg2(ctx); + if (fd < 256) { + //struct hfi1_filedata *hf = (struct hfi1_filedata *)proc->fd_priv_table[fd]; + kprintf("%s: fd[%d], 0x%lx, iovcnt[%d]\n", __FUNCTION__, fd, proc->fd_priv_table[fd], iovcnt); + } else { + kprintf("%s: fd[%d] > 256\n", __FUNCTION__, fd); + } + return syscall_generic_forwarding(__NR_writev, ctx); +} + SYSCALL_DECLARE(read) { int fd = ihk_mc_syscall_arg0(ctx);