Modified dune syscalls and extensions structures
authorZach Zimmerman <zpzimmerman@gmail.com>
Wed, 30 Aug 2017 00:07:44 +0000 (17:07 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 31 Aug 2017 17:38:20 +0000 (13:38 -0400)
Dune syscall table is now statically defined
Extensions (if present) are linked in through a shared library

Change-Id: I76c54abed80f690e511257f42c389d975792cd08
Signed-off-by: Zach Zimmerman <zpzimmerman@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/dune/Makefrag
tests/dune/dune.c
user/vmm/include/vmm/linux_syscalls.h
user/vmm/include/vmm/linuxemu.h
user/vmm/linuxemu.c

index 1d3801e..12d90b2 100644 (file)
@@ -1,6 +1,6 @@
 DUNE_TESTS_DIR = $(TESTS_DIR)/dune
 
-DUNE_TESTS_CFLAGS += $(CFLAGS_TESTS) -Wunused -Werror
+DUNE_TESTS_CFLAGS += $(CFLAGS_TESTS) -Wunused -Werror -rdynamic
 
 ALL_DUNE_TEST_FILES := $(wildcard $(DUNE_TESTS_DIR)/*.c)
 
index 5ae8c4c..adf5afa 100644 (file)
@@ -128,6 +128,9 @@ void dune_test(void *stack)
                xnum(auxv[i].v[1]); show("\n");
        }
        show("Done dumping [argv, env, auxv]\n");
+       show("Testing syscall extensions\n");
+       __asm__ __volatile__("movq $400, %%rax\n"
+                            "vmcall\n" :: );
        hlt();
 }
 
index 99c45ce..fec8910 100644 (file)
@@ -1,322 +1,5 @@
 #pragma once
 
-#define linux_max_syscall 311
-
-char *syscalls[] = {
-[0]    "DUNE_SYS_READ",
-[1]    "DUNE_SYS_WRITE",
-[2]    "DUNE_SYS_OPEN",
-[3]    "DUNE_SYS_CLOSE",
-[4]    "DUNE_SYS_STAT",
-[5]    "DUNE_SYS_FSTAT",
-[6]    "DUNE_SYS_LSTAT",
-[7]    "DUNE_SYS_POLL",
-[8]    "DUNE_SYS_LSEEK",
-[9]    "DUNE_SYS_MMAP",
-[10]   "DUNE_SYS_MPROTECT",
-[11]   "DUNE_SYS_MUNMAP",
-[12]   "DUNE_SYS_BRK",
-[13]   "DUNE_SYS_RT_SIGACTION",
-[14]   "DUNE_SYS_RT_SIGPROCMASK",
-[15]   "DUNE_SYS_RT_SIGRETURN",
-[16]   "DUNE_SYS_IOCTL",
-[17]   "DUNE_SYS_PREAD64",
-[18]   "DUNE_SYS_PWRITE64",
-[19]   "DUNE_SYS_READV",
-[20]   "DUNE_SYS_WRITEV",
-[21]   "DUNE_SYS_ACCESS",
-[22]   "DUNE_SYS_PIPE",
-[23]   "DUNE_SYS_SELECT",
-[24]   "DUNE_SYS_SCHED_YIELD",
-[25]   "DUNE_SYS_MREMAP",
-[26]   "DUNE_SYS_MSYNC",
-[27]   "DUNE_SYS_MINCORE",
-[28]   "DUNE_SYS_MADVISE",
-[29]   "DUNE_SYS_SHMGET",
-[30]   "DUNE_SYS_SHMAT",
-[31]   "DUNE_SYS_SHMCTL",
-[32]   "DUNE_SYS_DUP",
-[33]   "DUNE_SYS_DUP2",
-[34]   "DUNE_SYS_PAUSE",
-[35]   "DUNE_SYS_NANOSLEEP",
-[36]   "DUNE_SYS_GETITIMER",
-[37]   "DUNE_SYS_ALARM",
-[38]   "DUNE_SYS_SETITIMER",
-[39]   "DUNE_SYS_GETPID",
-[40]   "DUNE_SYS_SENDFILE",
-[41]   "DUNE_SYS_SOCKET",
-[42]   "DUNE_SYS_CONNECT",
-[43]   "DUNE_SYS_ACCEPT",
-[44]   "DUNE_SYS_SENDTO",
-[45]   "DUNE_SYS_RECVFROM",
-[46]   "DUNE_SYS_SENDMSG",
-[47]   "DUNE_SYS_RECVMSG",
-[48]   "DUNE_SYS_SHUTDOWN",
-[49]   "DUNE_SYS_BIND",
-[50]   "DUNE_SYS_LISTEN",
-[51]   "DUNE_SYS_GETSOCKNAME",
-[52]   "DUNE_SYS_GETPEERNAME",
-[53]   "DUNE_SYS_SOCKETPAIR",
-[54]   "DUNE_SYS_SETSOCKOPT",
-[55]   "DUNE_SYS_GETSOCKOPT",
-[56]   "DUNE_SYS_CLONE",
-[57]   "DUNE_SYS_FORK",
-[58]   "DUNE_SYS_VFORK",
-[59]   "DUNE_SYS_EXECVE",
-[60]   "DUNE_SYS_EXIT",
-[61]   "DUNE_SYS_WAIT4",
-[62]   "DUNE_SYS_KILL",
-[63]   "DUNE_SYS_UNAME",
-[64]   "DUNE_SYS_SEMGET",
-[65]   "DUNE_SYS_SEMOP",
-[66]   "DUNE_SYS_SEMCTL",
-[67]   "DUNE_SYS_SHMDT",
-[68]   "DUNE_SYS_MSGGET",
-[69]   "DUNE_SYS_MSGSND",
-[70]   "DUNE_SYS_MSGRCV",
-[71]   "DUNE_SYS_MSGCTL",
-[72]   "DUNE_SYS_FCNTL",
-[73]   "DUNE_SYS_FLOCK",
-[74]   "DUNE_SYS_FSYNC",
-[75]   "DUNE_SYS_FDATASYNC",
-[76]   "DUNE_SYS_TRUNCATE",
-[77]   "DUNE_SYS_FTRUNCATE",
-[78]   "DUNE_SYS_GETDENTS",
-[79]   "DUNE_SYS_GETCWD",
-[80]   "DUNE_SYS_CHDIR",
-[81]   "DUNE_SYS_FCHDIR",
-[82]   "DUNE_SYS_RENAME",
-[83]   "DUNE_SYS_MKDIR",
-[84]   "DUNE_SYS_RMDIR",
-[85]   "DUNE_SYS_CREAT",
-[86]   "DUNE_SYS_LINK",
-[87]   "DUNE_SYS_UNLINK",
-[88]   "DUNE_SYS_SYMLINK",
-[89]   "DUNE_SYS_READLINK",
-[90]   "DUNE_SYS_CHMOD",
-[91]   "DUNE_SYS_FCHMOD",
-[92]   "DUNE_SYS_CHOWN",
-[93]   "DUNE_SYS_FCHOWN",
-[94]   "DUNE_SYS_LCHOWN",
-[95]   "DUNE_SYS_UMASK",
-[96]   "DUNE_SYS_GETTIMEOFDAY",
-[97]   "DUNE_SYS_GETRLIMIT",
-[98]   "DUNE_SYS_GETRUSAGE",
-[99]   "DUNE_SYS_SYSINFO",
-[100]  "DUNE_SYS_TIMES",
-[101]  "DUNE_SYS_PTRACE",
-[102]  "DUNE_SYS_GETUID",
-[103]  "DUNE_SYS_SYSLOG",
-[104]  "DUNE_SYS_GETGID",
-[105]  "DUNE_SYS_SETUID",
-[106]  "DUNE_SYS_SETGID",
-[107]  "DUNE_SYS_GETEUID",
-[108]  "DUNE_SYS_GETEGID",
-[109]  "DUNE_SYS_SETPGID",
-[110]  "DUNE_SYS_GETPPID",
-[111]  "DUNE_SYS_GETPGRP",
-[112]  "DUNE_SYS_SETSID",
-[113]  "DUNE_SYS_SETREUID",
-[114]  "DUNE_SYS_SETREGID",
-[115]  "DUNE_SYS_GETGROUPS",
-[116]  "DUNE_SYS_SETGROUPS",
-[117]  "DUNE_SYS_SETRESUID",
-[118]  "DUNE_SYS_GETRESUID",
-[119]  "DUNE_SYS_SETRESGID",
-[120]  "DUNE_SYS_GETRESGID",
-[121]  "DUNE_SYS_GETPGID",
-[122]  "DUNE_SYS_SETFSUID",
-[123]  "DUNE_SYS_SETFSGID",
-[124]  "DUNE_SYS_GETSID",
-[125]  "DUNE_SYS_CAPGET",
-[126]  "DUNE_SYS_CAPSET",
-[127]  "DUNE_SYS_RT_SIGPENDING",
-[128]  "DUNE_SYS_RT_SIGTIMEDWAIT",
-[129]  "DUNE_SYS_RT_SIGQUEUEINFO",
-[130]  "DUNE_SYS_RT_SIGSUSPEND",
-[131]  "DUNE_SYS_SIGALTSTACK",
-[132]  "DUNE_SYS_UTIME",
-[133]  "DUNE_SYS_MKNOD",
-[134]  "DUNE_SYS_USELIB",
-[135]  "DUNE_SYS_PERSONALITY",
-[136]  "DUNE_SYS_USTAT",
-[137]  "DUNE_SYS_STATFS",
-[138]  "DUNE_SYS_FSTATFS",
-[139]  "DUNE_SYS_SYSFS",
-[140]  "DUNE_SYS_GETPRIORITY",
-[141]  "DUNE_SYS_SETPRIORITY",
-[142]  "DUNE_SYS_SCHED_SETPARAM",
-[143]  "DUNE_SYS_SCHED_GETPARAM",
-[144]  "DUNE_SYS_SCHED_SETSCHEDULER",
-[145]  "DUNE_SYS_SCHED_GETSCHEDULER",
-[146]  "DUNE_SYS_SCHED_GET_PRIORITY_MAX",
-[147]  "DUNE_SYS_SCHED_GET_PRIORITY_MIN",
-[148]  "DUNE_SYS_SCHED_RR_GET_INTERVAL",
-[149]  "DUNE_SYS_MLOCK",
-[150]  "DUNE_SYS_MUNLOCK",
-[151]  "DUNE_SYS_MLOCKALL",
-[152]  "DUNE_SYS_MUNLOCKALL",
-[153]  "DUNE_SYS_VHANGUP",
-[154]  "DUNE_SYS_MODIFY_LDT",
-[155]  "DUNE_SYS_PIVOT_ROOT",
-[156]  "DUNE_SYS__SYSCTL",
-[157]  "DUNE_SYS_PRCTL",
-[158]  "DUNE_SYS_ARCH_PRCTL",
-[159]  "DUNE_SYS_ADJTIMEX",
-[160]  "DUNE_SYS_SETRLIMIT",
-[161]  "DUNE_SYS_CHROOT",
-[162]  "DUNE_SYS_SYNC",
-[163]  "DUNE_SYS_ACCT",
-[164]  "DUNE_SYS_SETTIMEOFDAY",
-[165]  "DUNE_SYS_MOUNT",
-[166]  "DUNE_SYS_UMOUNT2",
-[167]  "DUNE_SYS_SWAPON",
-[168]  "DUNE_SYS_SWAPOFF",
-[169]  "DUNE_SYS_REBOOT",
-[170]  "DUNE_SYS_SETHOSTNAME",
-[171]  "DUNE_SYS_SETDOMAINNAME",
-[172]  "DUNE_SYS_IOPL",
-[173]  "DUNE_SYS_IOPERM",
-[174]  "DUNE_SYS_CREATE_MODULE",
-[175]  "DUNE_SYS_INIT_MODULE",
-[176]  "DUNE_SYS_DELETE_MODULE",
-[177]  "DUNE_SYS_GET_KERNEL_SYMS",
-[178]  "DUNE_SYS_QUERY_MODULE",
-[179]  "DUNE_SYS_QUOTACTL",
-[180]  "DUNE_SYS_NFSSERVCTL",
-[181]  "DUNE_SYS_GETPMSG",
-[182]  "DUNE_SYS_PUTPMSG",
-[183]  "DUNE_SYS_AFS_SYSCALL",
-[184]  "DUNE_SYS_TUXCALL",
-[185]  "DUNE_SYS_SECURITY",
-[186]  "DUNE_SYS_GETTID",
-[187]  "DUNE_SYS_READAHEAD",
-[188]  "DUNE_SYS_SETXATTR",
-[189]  "DUNE_SYS_LSETXATTR",
-[190]  "DUNE_SYS_FSETXATTR",
-[191]  "DUNE_SYS_GETXATTR",
-[192]  "DUNE_SYS_LGETXATTR",
-[193]  "DUNE_SYS_FGETXATTR",
-[194]  "DUNE_SYS_LISTXATTR",
-[195]  "DUNE_SYS_LLISTXATTR",
-[196]  "DUNE_SYS_FLISTXATTR",
-[197]  "DUNE_SYS_REMOVEXATTR",
-[198]  "DUNE_SYS_LREMOVEXATTR",
-[199]  "DUNE_SYS_FREMOVEXATTR",
-[200]  "DUNE_SYS_TKILL",
-[201]  "DUNE_SYS_TIME",
-[202]  "DUNE_SYS_FUTEX",
-[203]  "DUNE_SYS_SCHED_SETAFFINITY",
-[204]  "DUNE_SYS_SCHED_GETAFFINITY",
-[205]  "DUNE_SYS_SET_THREAD_AREA",
-[206]  "DUNE_SYS_IO_SETUP",
-[207]  "DUNE_SYS_IO_DESTROY",
-[208]  "DUNE_SYS_IO_GETEVENTS",
-[209]  "DUNE_SYS_IO_SUBMIT",
-[210]  "DUNE_SYS_IO_CANCEL",
-[211]  "DUNE_SYS_GET_THREAD_AREA",
-[212]  "DUNE_SYS_LOOKUP_DCOOKIE",
-[213]  "DUNE_SYS_EPOLL_CREATE",
-[214]  "DUNE_SYS_EPOLL_CTL_OLD",
-[215]  "DUNE_SYS_EPOLL_WAIT_OLD",
-[216]  "DUNE_SYS_REMAP_FILE_PAGES",
-[217]  "DUNE_SYS_GETDENTS64",
-[218]  "DUNE_SYS_SET_TID_ADDRESS",
-[219]  "DUNE_SYS_RESTART_SYSCALL",
-[220]  "DUNE_SYS_SEMTIMEDOP",
-[221]  "DUNE_SYS_FADVISE64",
-[222]  "DUNE_SYS_TIMER_CREATE",
-[223]  "DUNE_SYS_TIMER_SETTIME",
-[224]  "DUNE_SYS_TIMER_GETTIME",
-[225]  "DUNE_SYS_TIMER_GETOVERRUN",
-[226]  "DUNE_SYS_TIMER_DELETE",
-[227]  "DUNE_SYS_CLOCK_SETTIME",
-[228]  "DUNE_SYS_CLOCK_GETTIME",
-[229]  "DUNE_SYS_CLOCK_GETRES",
-[230]  "DUNE_SYS_CLOCK_NANOSLEEP",
-[231]  "DUNE_SYS_EXIT_GROUP",
-[232]  "DUNE_SYS_EPOLL_WAIT",
-[233]  "DUNE_SYS_EPOLL_CTL",
-[234]  "DUNE_SYS_TGKILL",
-[235]  "DUNE_SYS_UTIMES",
-[236]  "DUNE_SYS_VSERVER",
-[237]  "DUNE_SYS_MBIND",
-[238]  "DUNE_SYS_SET_MEMPOLICY",
-[239]  "DUNE_SYS_GET_MEMPOLICY",
-[240]  "DUNE_SYS_MQ_OPEN",
-[241]  "DUNE_SYS_MQ_UNLINK",
-[242]  "DUNE_SYS_MQ_TIMEDSEND",
-[243]  "DUNE_SYS_MQ_TIMEDRECEIVE",
-[244]  "DUNE_SYS_MQ_NOTIFY",
-[245]  "DUNE_SYS_MQ_GETSETATTR",
-[246]  "DUNE_SYS_KEXEC_LOAD",
-[247]  "DUNE_SYS_WAITID",
-[248]  "DUNE_SYS_ADD_KEY",
-[249]  "DUNE_SYS_REQUEST_KEY",
-[250]  "DUNE_SYS_KEYCTL",
-[251]  "DUNE_SYS_IOPRIO_SET",
-[252]  "DUNE_SYS_IOPRIO_GET",
-[253]  "DUNE_SYS_INOTIFY_INIT",
-[254]  "DUNE_SYS_INOTIFY_ADD_WATCH",
-[255]  "DUNE_SYS_INOTIFY_RM_WATCH",
-[256]  "DUNE_SYS_MIGRATE_PAGES",
-[257]  "DUNE_SYS_OPENAT",
-[258]  "DUNE_SYS_MKDIRAT",
-[259]  "DUNE_SYS_MKNODAT",
-[260]  "DUNE_SYS_FCHOWNAT",
-[261]  "DUNE_SYS_FUTIMESAT",
-[262]  "DUNE_SYS_NEWFSTATAT",
-[263]  "DUNE_SYS_UNLINKAT",
-[264]  "DUNE_SYS_RENAMEAT",
-[265]  "DUNE_SYS_LINKAT",
-[266]  "DUNE_SYS_SYMLINKAT",
-[267]  "DUNE_SYS_READLINKAT",
-[268]  "DUNE_SYS_FCHMODAT",
-[269]  "DUNE_SYS_FACCESSAT",
-[270]  "DUNE_SYS_PSELECT6",
-[271]  "DUNE_SYS_PPOLL",
-[272]  "DUNE_SYS_UNSHARE",
-[273]  "DUNE_SYS_SET_ROBUST_LIST",
-[274]  "DUNE_SYS_GET_ROBUST_LIST",
-[275]  "DUNE_SYS_SPLICE",
-[276]  "DUNE_SYS_TEE",
-[277]  "DUNE_SYS_SYNC_FILE_RANGE",
-[278]  "DUNE_SYS_VMSPLICE",
-[279]  "DUNE_SYS_MOVE_PAGES",
-[280]  "DUNE_SYS_UTIMENSAT",
-[281]  "DUNE_SYS_EPOLL_PWAIT",
-[282]  "DUNE_SYS_SIGNALFD",
-[283]  "DUNE_SYS_TIMERFD_CREATE",
-[284]  "DUNE_SYS_EVENTFD",
-[285]  "DUNE_SYS_FALLOCATE",
-[286]  "DUNE_SYS_TIMERFD_SETTIME",
-[287]  "DUNE_SYS_TIMERFD_GETTIME",
-[288]  "DUNE_SYS_ACCEPT4",
-[289]  "DUNE_SYS_SIGNALFD4",
-[290]  "DUNE_SYS_EVENTFD2",
-[291]  "DUNE_SYS_EPOLL_CREATE1",
-[292]  "DUNE_SYS_DUP3",
-[293]  "DUNE_SYS_PIPE2",
-[294]  "DUNE_SYS_INOTIFY_INIT1",
-[295]  "DUNE_SYS_PREADV",
-[296]  "DUNE_SYS_PWRITEV",
-[297]  "DUNE_SYS_RT_TGSIGQUEUEINFO",
-[298]  "DUNE_SYS_PERF_EVENT_OPEN",
-[299]  "DUNE_SYS_RECVMMSG",
-[300]  "DUNE_SYS_FANOTIFY_INIT",
-[301]  "DUNE_SYS_FANOTIFY_MARK",
-[302]  "DUNE_SYS_PRLIMIT64",
-[303]  "DUNE_SYS_NAME_TO_HANDLE_AT",
-[304]  "DUNE_SYS_OPEN_BY_HANDLE_AT",
-[305]  "DUNE_SYS_CLOCK_ADJTIME",
-[306]  "DUNE_SYS_SYNCFS",
-[307]  "DUNE_SYS_SENDMMSG",
-[308]  "DUNE_SYS_SETNS",
-[309]  "DUNE_SYS_GETCPU",
-[310]  "DUNE_SYS_PROCESS_VM_READV",
-[311]  "DUNE_SYS_PROCESS_VM_WRITEV",
-};
-
 enum syscall_names {
 DUNE_SYS_READ,
 DUNE_SYS_WRITE,
index f314c04..be1af27 100644 (file)
@@ -7,13 +7,15 @@ struct dune_sys_table_entry {
        const char *name;
 };
 
-#define dune_max_syscall 1024
+#define DUNE_MAX_NUM_SYSCALLS 1024
 
-struct dune_sys_table_entry dune_syscall_table[dune_max_syscall];
+extern struct dune_sys_table_entry dune_syscall_table[];
 
-void init_syscall_table(void);
+bool init_syscall_table(void);
 void init_lemu_logging(int logging_level);
 void destroy_lemu_logging(void);
+void lemuprint(const uint32_t tid, uint64_t syscall_number,
+               const bool isError, const char *fmt, ...);
 
 bool dune_sys_write(struct vm_trapframe *tf);
 bool dune_sys_read(struct vm_trapframe *tf);
index af93afb..a513ba4 100644 (file)
@@ -46,46 +46,6 @@ void destroy_lemu_logging(void)
 }
 
 
-void lemuprint(const uint32_t tid, const char *syscallname,
-               const bool isError, const char *fmt, ...)
-{
-       va_list valist;
-       const char *prefix = "[TID %d] %s: ";
-       bool double_logging = false;
-
-
-       // Do not use global variable as a check to acquire lock.
-       // make sure it is not changed during our acquire/release.
-       int debug = lemu_debug;
-
-       // If we are not going to log anything anyway, just bail out.
-       if (!(debug > 0 || isError))
-               return;
-
-       va_start(valist, fmt);
-
-       uth_mutex_lock(lemu_logging_lock);
-
-       // Print to stderr if debug level is sufficient
-       if (debug > 1) {
-               fprintf(stderr, prefix, tid, syscallname);
-               vfprintf(stderr, fmt, valist);
-               // Checks if we will double log to stderr
-               if (lemu_global_logfile == stderr)
-                       double_logging = true;
-       }
-
-       // Log to the global logfile, if we defaulted the global logging to
-       // stderr then we don't want to log 2 times to stderr.
-       if (lemu_global_logfile != NULL && !double_logging) {
-               fprintf(lemu_global_logfile, prefix, tid, syscallname);
-               vfprintf(lemu_global_logfile, fmt, valist);
-       }
-
-       uth_mutex_unlock(lemu_logging_lock);
-
-       va_end(valist);
-}
 
 
 bool dune_sys_read(struct vm_trapframe *tf)
@@ -94,11 +54,11 @@ bool dune_sys_read(struct vm_trapframe *tf)
        int err = errno;
 
        if (retval == -1) {
-               lemuprint(tf->tf_guest_pcoreid, syscalls[tf->tf_rax], true,
+               lemuprint(tf->tf_guest_pcoreid, tf->tf_rax, true,
                          "ERROR %zd\n", err);
                tf->tf_rax = -err;
        } else {
-               lemuprint(tf->tf_guest_pcoreid, syscalls[tf->tf_rax], false,
+               lemuprint(tf->tf_guest_pcoreid, tf->tf_rax, false,
                          "SUCCESS %zd\n", retval);
                tf->tf_rax = retval;
        }
@@ -113,11 +73,11 @@ bool dune_sys_write(struct vm_trapframe *tf)
        int err = errno;
 
        if (retval == -1) {
-               lemuprint(tf->tf_guest_pcoreid, syscalls[tf->tf_rax], true,
+               lemuprint(tf->tf_guest_pcoreid, tf->tf_rax, true,
                          "ERROR %zd\n", err);
                tf->tf_rax = -err;
        } else {
-               lemuprint(tf->tf_guest_pcoreid, syscalls[tf->tf_rax], false,
+               lemuprint(tf->tf_guest_pcoreid, tf->tf_rax, false,
                          "SUCCESS %zd\n", retval);
                tf->tf_rax = retval;
        }
@@ -137,40 +97,399 @@ bool dune_sys_gettimeofday(struct vm_trapframe *tf)
        int err = errno;
 
        if (retval == -1) {
-               lemuprint(tf->tf_guest_pcoreid, syscalls[tf->tf_rax], true,
+               lemuprint(tf->tf_guest_pcoreid, tf->tf_rax, true,
                          "ERROR %d\n", err);
                tf->tf_rax = -err;
        } else {
-               lemuprint(tf->tf_guest_pcoreid, syscalls[tf->tf_rax], false,
+               lemuprint(tf->tf_guest_pcoreid, tf->tf_rax, false,
                          "SUCCESS %d\n", retval);
                tf->tf_rax = retval;
        }
        return true;
 }
 
-void init_syscall_table(void)
+
+
+struct dune_sys_table_entry dune_syscall_table[DUNE_MAX_NUM_SYSCALLS] = {
+       [DUNE_SYS_READ] = {dune_sys_read, "DUNE_SYS_READ"},
+       [DUNE_SYS_WRITE] = {dune_sys_write, "DUNE_SYS_WRITE"},
+       [DUNE_SYS_OPEN] = {NULL, "DUNE_SYS_OPEN"},
+       [DUNE_SYS_CLOSE] = {NULL, "DUNE_SYS_CLOSE"},
+       [DUNE_SYS_STAT] = {NULL, "DUNE_SYS_STAT"},
+       [DUNE_SYS_FSTAT] = {NULL, "DUNE_SYS_FSTAT"},
+       [DUNE_SYS_LSTAT] = {NULL, "DUNE_SYS_LSTAT"},
+       [DUNE_SYS_POLL] = {NULL, "DUNE_SYS_POLL"},
+       [DUNE_SYS_LSEEK] = {NULL, "DUNE_SYS_LSEEK"},
+       [DUNE_SYS_MMAP] = {NULL, "DUNE_SYS_MMAP"},
+       [DUNE_SYS_MPROTECT] = {NULL, "DUNE_SYS_MPROTECT"},
+       [DUNE_SYS_MUNMAP] = {NULL, "DUNE_SYS_MUNMAP"},
+       [DUNE_SYS_BRK] = {NULL, "DUNE_SYS_BRK"},
+       [DUNE_SYS_RT_SIGACTION] = {NULL, "DUNE_SYS_RT_SIGACTION"},
+       [DUNE_SYS_RT_SIGPROCMASK] = {NULL, "DUNE_SYS_RT_SIGPROCMASK"},
+       [DUNE_SYS_RT_SIGRETURN] = {NULL, "DUNE_SYS_RT_SIGRETURN"},
+       [DUNE_SYS_IOCTL] = {NULL, "DUNE_SYS_IOCTL"},
+       [DUNE_SYS_PREAD64] = {NULL, "DUNE_SYS_PREAD64"},
+       [DUNE_SYS_PWRITE64] = {NULL, "DUNE_SYS_PWRITE64"},
+       [DUNE_SYS_READV] = {NULL, "DUNE_SYS_READV"},
+       [DUNE_SYS_WRITEV] = {NULL, "DUNE_SYS_WRITEV"},
+       [DUNE_SYS_ACCESS] = {NULL, "DUNE_SYS_ACCESS"},
+       [DUNE_SYS_PIPE] = {NULL, "DUNE_SYS_PIPE"},
+       [DUNE_SYS_SELECT] = {NULL, "DUNE_SYS_SELECT"},
+       [DUNE_SYS_SCHED_YIELD] = {NULL, "DUNE_SYS_SCHED_YIELD"},
+       [DUNE_SYS_MREMAP] = {NULL, "DUNE_SYS_MREMAP"},
+       [DUNE_SYS_MSYNC] = {NULL, "DUNE_SYS_MSYNC"},
+       [DUNE_SYS_MINCORE] = {NULL, "DUNE_SYS_MINCORE"},
+       [DUNE_SYS_MADVISE] = {NULL, "DUNE_SYS_MADVISE"},
+       [DUNE_SYS_SHMGET] = {NULL, "DUNE_SYS_SHMGET"},
+       [DUNE_SYS_SHMAT] = {NULL, "DUNE_SYS_SHMAT"},
+       [DUNE_SYS_SHMCTL] = {NULL, "DUNE_SYS_SHMCTL"},
+       [DUNE_SYS_DUP] = {NULL, "DUNE_SYS_DUP"},
+       [DUNE_SYS_DUP2] = {NULL, "DUNE_SYS_DUP2"},
+       [DUNE_SYS_PAUSE] = {NULL, "DUNE_SYS_PAUSE"},
+       [DUNE_SYS_NANOSLEEP] = {NULL, "DUNE_SYS_NANOSLEEP"},
+       [DUNE_SYS_GETITIMER] = {NULL, "DUNE_SYS_GETITIMER"},
+       [DUNE_SYS_ALARM] = {NULL, "DUNE_SYS_ALARM"},
+       [DUNE_SYS_SETITIMER] = {NULL, "DUNE_SYS_SETITIMER"},
+       [DUNE_SYS_GETPID] = {NULL, "DUNE_SYS_GETPID"},
+       [DUNE_SYS_SENDFILE] = {NULL, "DUNE_SYS_SENDFILE"},
+       [DUNE_SYS_SOCKET] = {NULL, "DUNE_SYS_SOCKET"},
+       [DUNE_SYS_CONNECT] = {NULL, "DUNE_SYS_CONNECT"},
+       [DUNE_SYS_ACCEPT] = {NULL, "DUNE_SYS_ACCEPT"},
+       [DUNE_SYS_SENDTO] = {NULL, "DUNE_SYS_SENDTO"},
+       [DUNE_SYS_RECVFROM] = {NULL, "DUNE_SYS_RECVFROM"},
+       [DUNE_SYS_SENDMSG] = {NULL, "DUNE_SYS_SENDMSG"},
+       [DUNE_SYS_RECVMSG] = {NULL, "DUNE_SYS_RECVMSG"},
+       [DUNE_SYS_SHUTDOWN] = {NULL, "DUNE_SYS_SHUTDOWN"},
+       [DUNE_SYS_BIND] = {NULL, "DUNE_SYS_BIND"},
+       [DUNE_SYS_LISTEN] = {NULL, "DUNE_SYS_LISTEN"},
+       [DUNE_SYS_GETSOCKNAME] = {NULL, "DUNE_SYS_GETSOCKNAME"},
+       [DUNE_SYS_GETPEERNAME] = {NULL, "DUNE_SYS_GETPEERNAME"},
+       [DUNE_SYS_SOCKETPAIR] = {NULL, "DUNE_SYS_SOCKETPAIR"},
+       [DUNE_SYS_SETSOCKOPT] = {NULL, "DUNE_SYS_SETSOCKOPT"},
+       [DUNE_SYS_GETSOCKOPT] = {NULL, "DUNE_SYS_GETSOCKOPT"},
+       [DUNE_SYS_CLONE] = {NULL, "DUNE_SYS_CLONE"},
+       [DUNE_SYS_FORK] = {NULL, "DUNE_SYS_FORK"},
+       [DUNE_SYS_VFORK] = {NULL, "DUNE_SYS_VFORK"},
+       [DUNE_SYS_EXECVE] = {NULL, "DUNE_SYS_EXECVE"},
+       [DUNE_SYS_EXIT] = {NULL, "DUNE_SYS_EXIT"},
+       [DUNE_SYS_WAIT4] = {NULL, "DUNE_SYS_WAIT4"},
+       [DUNE_SYS_KILL] = {NULL, "DUNE_SYS_KILL"},
+       [DUNE_SYS_UNAME] = {NULL, "DUNE_SYS_UNAME"},
+       [DUNE_SYS_SEMGET] = {NULL, "DUNE_SYS_SEMGET"},
+       [DUNE_SYS_SEMOP] = {NULL, "DUNE_SYS_SEMOP"},
+       [DUNE_SYS_SEMCTL] = {NULL, "DUNE_SYS_SEMCTL"},
+       [DUNE_SYS_SHMDT] = {NULL, "DUNE_SYS_SHMDT"},
+       [DUNE_SYS_MSGGET] = {NULL, "DUNE_SYS_MSGGET"},
+       [DUNE_SYS_MSGSND] = {NULL, "DUNE_SYS_MSGSND"},
+       [DUNE_SYS_MSGRCV] = {NULL, "DUNE_SYS_MSGRCV"},
+       [DUNE_SYS_MSGCTL] = {NULL, "DUNE_SYS_MSGCTL"},
+       [DUNE_SYS_FCNTL] = {NULL, "DUNE_SYS_FCNTL"},
+       [DUNE_SYS_FLOCK] = {NULL, "DUNE_SYS_FLOCK"},
+       [DUNE_SYS_FSYNC] = {NULL, "DUNE_SYS_FSYNC"},
+       [DUNE_SYS_FDATASYNC] = {NULL, "DUNE_SYS_FDATASYNC"},
+       [DUNE_SYS_TRUNCATE] = {NULL, "DUNE_SYS_TRUNCATE"},
+       [DUNE_SYS_FTRUNCATE] = {NULL, "DUNE_SYS_FTRUNCATE"},
+       [DUNE_SYS_GETDENTS] = {NULL, "DUNE_SYS_GETDENTS"},
+       [DUNE_SYS_GETCWD] = {NULL, "DUNE_SYS_GETCWD"},
+       [DUNE_SYS_CHDIR] = {NULL, "DUNE_SYS_CHDIR"},
+       [DUNE_SYS_FCHDIR] = {NULL, "DUNE_SYS_FCHDIR"},
+       [DUNE_SYS_RENAME] = {NULL, "DUNE_SYS_RENAME"},
+       [DUNE_SYS_MKDIR] = {NULL, "DUNE_SYS_MKDIR"},
+       [DUNE_SYS_RMDIR] = {NULL, "DUNE_SYS_RMDIR"},
+       [DUNE_SYS_CREAT] = {NULL, "DUNE_SYS_CREAT"},
+       [DUNE_SYS_LINK] = {NULL, "DUNE_SYS_LINK"},
+       [DUNE_SYS_UNLINK] = {NULL, "DUNE_SYS_UNLINK"},
+       [DUNE_SYS_SYMLINK] = {NULL, "DUNE_SYS_SYMLINK"},
+       [DUNE_SYS_READLINK] = {NULL, "DUNE_SYS_READLINK"},
+       [DUNE_SYS_CHMOD] = {NULL, "DUNE_SYS_CHMOD"},
+       [DUNE_SYS_FCHMOD] = {NULL, "DUNE_SYS_FCHMOD"},
+       [DUNE_SYS_CHOWN] = {NULL, "DUNE_SYS_CHOWN"},
+       [DUNE_SYS_FCHOWN] = {NULL, "DUNE_SYS_FCHOWN"},
+       [DUNE_SYS_LCHOWN] = {NULL, "DUNE_SYS_LCHOWN"},
+       [DUNE_SYS_UMASK] = {NULL, "DUNE_SYS_UMASK"},
+       [DUNE_SYS_GETTIMEOFDAY] = {dune_sys_gettimeofday, "DUNE_SYS_GETTIMEOFDAY"},
+       [DUNE_SYS_GETRLIMIT] = {NULL, "DUNE_SYS_GETRLIMIT"},
+       [DUNE_SYS_GETRUSAGE] = {NULL, "DUNE_SYS_GETRUSAGE"},
+       [DUNE_SYS_SYSINFO] = {NULL, "DUNE_SYS_SYSINFO"},
+       [DUNE_SYS_TIMES] = {NULL, "DUNE_SYS_TIMES"},
+       [DUNE_SYS_PTRACE] = {NULL, "DUNE_SYS_PTRACE"},
+       [DUNE_SYS_GETUID] = {NULL, "DUNE_SYS_GETUID"},
+       [DUNE_SYS_SYSLOG] = {NULL, "DUNE_SYS_SYSLOG"},
+       [DUNE_SYS_GETGID] = {NULL, "DUNE_SYS_GETGID"},
+       [DUNE_SYS_SETUID] = {NULL, "DUNE_SYS_SETUID"},
+       [DUNE_SYS_SETGID] = {NULL, "DUNE_SYS_SETGID"},
+       [DUNE_SYS_GETEUID] = {NULL, "DUNE_SYS_GETEUID"},
+       [DUNE_SYS_GETEGID] = {NULL, "DUNE_SYS_GETEGID"},
+       [DUNE_SYS_SETPGID] = {NULL, "DUNE_SYS_SETPGID"},
+       [DUNE_SYS_GETPPID] = {NULL, "DUNE_SYS_GETPPID"},
+       [DUNE_SYS_GETPGRP] = {NULL, "DUNE_SYS_GETPGRP"},
+       [DUNE_SYS_SETSID] = {NULL, "DUNE_SYS_SETSID"},
+       [DUNE_SYS_SETREUID] = {NULL, "DUNE_SYS_SETREUID"},
+       [DUNE_SYS_SETREGID] = {NULL, "DUNE_SYS_SETREGID"},
+       [DUNE_SYS_GETGROUPS] = {NULL, "DUNE_SYS_GETGROUPS"},
+       [DUNE_SYS_SETGROUPS] = {NULL, "DUNE_SYS_SETGROUPS"},
+       [DUNE_SYS_SETRESUID] = {NULL, "DUNE_SYS_SETRESUID"},
+       [DUNE_SYS_GETRESUID] = {NULL, "DUNE_SYS_GETRESUID"},
+       [DUNE_SYS_SETRESGID] = {NULL, "DUNE_SYS_SETRESGID"},
+       [DUNE_SYS_GETRESGID] = {NULL, "DUNE_SYS_GETRESGID"},
+       [DUNE_SYS_GETPGID] = {NULL, "DUNE_SYS_GETPGID"},
+       [DUNE_SYS_SETFSUID] = {NULL, "DUNE_SYS_SETFSUID"},
+       [DUNE_SYS_SETFSGID] = {NULL, "DUNE_SYS_SETFSGID"},
+       [DUNE_SYS_GETSID] = {NULL, "DUNE_SYS_GETSID"},
+       [DUNE_SYS_CAPGET] = {NULL, "DUNE_SYS_CAPGET"},
+       [DUNE_SYS_CAPSET] = {NULL, "DUNE_SYS_CAPSET"},
+       [DUNE_SYS_RT_SIGPENDING] = {NULL, "DUNE_SYS_RT_SIGPENDING"},
+       [DUNE_SYS_RT_SIGTIMEDWAIT] = {NULL, "DUNE_SYS_RT_SIGTIMEDWAIT"},
+       [DUNE_SYS_RT_SIGQUEUEINFO] = {NULL, "DUNE_SYS_RT_SIGQUEUEINFO"},
+       [DUNE_SYS_RT_SIGSUSPEND] = {NULL, "DUNE_SYS_RT_SIGSUSPEND"},
+       [DUNE_SYS_SIGALTSTACK] = {NULL, "DUNE_SYS_SIGALTSTACK"},
+       [DUNE_SYS_UTIME] = {NULL, "DUNE_SYS_UTIME"},
+       [DUNE_SYS_MKNOD] = {NULL, "DUNE_SYS_MKNOD"},
+       [DUNE_SYS_USELIB] = {NULL, "DUNE_SYS_USELIB"},
+       [DUNE_SYS_PERSONALITY] = {NULL, "DUNE_SYS_PERSONALITY"},
+       [DUNE_SYS_USTAT] = {NULL, "DUNE_SYS_USTAT"},
+       [DUNE_SYS_STATFS] = {NULL, "DUNE_SYS_STATFS"},
+       [DUNE_SYS_FSTATFS] = {NULL, "DUNE_SYS_FSTATFS"},
+       [DUNE_SYS_SYSFS] = {NULL, "DUNE_SYS_SYSFS"},
+       [DUNE_SYS_GETPRIORITY] = {NULL, "DUNE_SYS_GETPRIORITY"},
+       [DUNE_SYS_SETPRIORITY] = {NULL, "DUNE_SYS_SETPRIORITY"},
+       [DUNE_SYS_SCHED_SETPARAM] = {NULL, "DUNE_SYS_SCHED_SETPARAM"},
+       [DUNE_SYS_SCHED_GETPARAM] = {NULL, "DUNE_SYS_SCHED_GETPARAM"},
+       [DUNE_SYS_SCHED_SETSCHEDULER] = {NULL, "DUNE_SYS_SCHED_SETSCHEDULER"},
+       [DUNE_SYS_SCHED_GETSCHEDULER] = {NULL, "DUNE_SYS_SCHED_GETSCHEDULER"},
+       [DUNE_SYS_SCHED_GET_PRIORITY_MAX] = {NULL,
+                                           "DUNE_SYS_SCHED_GET_PRIORITY_MAX"},
+       [DUNE_SYS_SCHED_GET_PRIORITY_MIN] = {NULL,
+                                           "DUNE_SYS_SCHED_GET_PRIORITY_MIN"},
+       [DUNE_SYS_SCHED_RR_GET_INTERVAL] = {NULL, "DUNE_SYS_SCHED_RR_GET_INTERVAL"},
+       [DUNE_SYS_MLOCK] = {NULL, "DUNE_SYS_MLOCK"},
+       [DUNE_SYS_MUNLOCK] = {NULL, "DUNE_SYS_MUNLOCK"},
+       [DUNE_SYS_MLOCKALL] = {NULL, "DUNE_SYS_MLOCKALL"},
+       [DUNE_SYS_MUNLOCKALL] = {NULL, "DUNE_SYS_MUNLOCKALL"},
+       [DUNE_SYS_VHANGUP] = {NULL, "DUNE_SYS_VHANGUP"},
+       [DUNE_SYS_MODIFY_LDT] = {NULL, "DUNE_SYS_MODIFY_LDT"},
+       [DUNE_SYS_PIVOT_ROOT] = {NULL, "DUNE_SYS_PIVOT_ROOT"},
+       [DUNE_SYS__SYSCTL] = {NULL, "DUNE_SYS__SYSCTL"},
+       [DUNE_SYS_PRCTL] = {NULL, "DUNE_SYS_PRCTL"},
+       [DUNE_SYS_ARCH_PRCTL] = {NULL, "DUNE_SYS_ARCH_PRCTL"},
+       [DUNE_SYS_ADJTIMEX] = {NULL, "DUNE_SYS_ADJTIMEX"},
+       [DUNE_SYS_SETRLIMIT] = {NULL, "DUNE_SYS_SETRLIMIT"},
+       [DUNE_SYS_CHROOT] = {NULL, "DUNE_SYS_CHROOT"},
+       [DUNE_SYS_SYNC] = {NULL, "DUNE_SYS_SYNC"},
+       [DUNE_SYS_ACCT] = {NULL, "DUNE_SYS_ACCT"},
+       [DUNE_SYS_SETTIMEOFDAY] = {NULL, "DUNE_SYS_SETTIMEOFDAY"},
+       [DUNE_SYS_MOUNT] = {NULL, "DUNE_SYS_MOUNT"},
+       [DUNE_SYS_UMOUNT2] = {NULL, "DUNE_SYS_UMOUNT2"},
+       [DUNE_SYS_SWAPON] = {NULL, "DUNE_SYS_SWAPON"},
+       [DUNE_SYS_SWAPOFF] = {NULL, "DUNE_SYS_SWAPOFF"},
+       [DUNE_SYS_REBOOT] = {NULL, "DUNE_SYS_REBOOT"},
+       [DUNE_SYS_SETHOSTNAME] = {NULL, "DUNE_SYS_SETHOSTNAME"},
+       [DUNE_SYS_SETDOMAINNAME] = {NULL, "DUNE_SYS_SETDOMAINNAME"},
+       [DUNE_SYS_IOPL] = {NULL, "DUNE_SYS_IOPL"},
+       [DUNE_SYS_IOPERM] = {NULL, "DUNE_SYS_IOPERM"},
+       [DUNE_SYS_CREATE_MODULE] = {NULL, "DUNE_SYS_CREATE_MODULE"},
+       [DUNE_SYS_INIT_MODULE] = {NULL, "DUNE_SYS_INIT_MODULE"},
+       [DUNE_SYS_DELETE_MODULE] = {NULL, "DUNE_SYS_DELETE_MODULE"},
+       [DUNE_SYS_GET_KERNEL_SYMS] = {NULL, "DUNE_SYS_GET_KERNEL_SYMS"},
+       [DUNE_SYS_QUERY_MODULE] = {NULL, "DUNE_SYS_QUERY_MODULE"},
+       [DUNE_SYS_QUOTACTL] = {NULL, "DUNE_SYS_QUOTACTL"},
+       [DUNE_SYS_NFSSERVCTL] = {NULL, "DUNE_SYS_NFSSERVCTL"},
+       [DUNE_SYS_GETPMSG] = {NULL, "DUNE_SYS_GETPMSG"},
+       [DUNE_SYS_PUTPMSG] = {NULL, "DUNE_SYS_PUTPMSG"},
+       [DUNE_SYS_AFS_SYSCALL] = {NULL, "DUNE_SYS_AFS_SYSCALL"},
+       [DUNE_SYS_TUXCALL] = {NULL, "DUNE_SYS_TUXCALL"},
+       [DUNE_SYS_SECURITY] = {NULL, "DUNE_SYS_SECURITY"},
+       [DUNE_SYS_GETTID] = {dune_sys_gettid, "DUNE_SYS_GETTID"},
+       [DUNE_SYS_READAHEAD] = {NULL, "DUNE_SYS_READAHEAD"},
+       [DUNE_SYS_SETXATTR] = {NULL, "DUNE_SYS_SETXATTR"},
+       [DUNE_SYS_LSETXATTR] = {NULL, "DUNE_SYS_LSETXATTR"},
+       [DUNE_SYS_FSETXATTR] = {NULL, "DUNE_SYS_FSETXATTR"},
+       [DUNE_SYS_GETXATTR] = {NULL, "DUNE_SYS_GETXATTR"},
+       [DUNE_SYS_LGETXATTR] = {NULL, "DUNE_SYS_LGETXATTR"},
+       [DUNE_SYS_FGETXATTR] = {NULL, "DUNE_SYS_FGETXATTR"},
+       [DUNE_SYS_LISTXATTR] = {NULL, "DUNE_SYS_LISTXATTR"},
+       [DUNE_SYS_LLISTXATTR] = {NULL, "DUNE_SYS_LLISTXATTR"},
+       [DUNE_SYS_FLISTXATTR] = {NULL, "DUNE_SYS_FLISTXATTR"},
+       [DUNE_SYS_REMOVEXATTR] = {NULL, "DUNE_SYS_REMOVEXATTR"},
+       [DUNE_SYS_LREMOVEXATTR] = {NULL, "DUNE_SYS_LREMOVEXATTR"},
+       [DUNE_SYS_FREMOVEXATTR] = {NULL, "DUNE_SYS_FREMOVEXATTR"},
+       [DUNE_SYS_TKILL] = {NULL, "DUNE_SYS_TKILL"},
+       [DUNE_SYS_TIME] = {NULL, "DUNE_SYS_TIME"},
+       [DUNE_SYS_FUTEX] = {NULL, "DUNE_SYS_FUTEX"},
+       [DUNE_SYS_SCHED_SETAFFINITY] = {NULL, "DUNE_SYS_SCHED_SETAFFINITY"},
+       [DUNE_SYS_SCHED_GETAFFINITY] = {NULL, "DUNE_SYS_SCHED_GETAFFINITY"},
+       [DUNE_SYS_SET_THREAD_AREA] = {NULL, "DUNE_SYS_SET_THREAD_AREA"},
+       [DUNE_SYS_IO_SETUP] = {NULL, "DUNE_SYS_IO_SETUP"},
+       [DUNE_SYS_IO_DESTROY] = {NULL, "DUNE_SYS_IO_DESTROY"},
+       [DUNE_SYS_IO_GETEVENTS] = {NULL, "DUNE_SYS_IO_GETEVENTS"},
+       [DUNE_SYS_IO_SUBMIT] = {NULL, "DUNE_SYS_IO_SUBMIT"},
+       [DUNE_SYS_IO_CANCEL] = {NULL, "DUNE_SYS_IO_CANCEL"},
+       [DUNE_SYS_GET_THREAD_AREA] = {NULL, "DUNE_SYS_GET_THREAD_AREA"},
+       [DUNE_SYS_LOOKUP_DCOOKIE] = {NULL, "DUNE_SYS_LOOKUP_DCOOKIE"},
+       [DUNE_SYS_EPOLL_CREATE] = {NULL, "DUNE_SYS_EPOLL_CREATE"},
+       [DUNE_SYS_EPOLL_CTL_OLD] = {NULL, "DUNE_SYS_EPOLL_CTL_OLD"},
+       [DUNE_SYS_EPOLL_WAIT_OLD] = {NULL, "DUNE_SYS_EPOLL_WAIT_OLD"},
+       [DUNE_SYS_REMAP_FILE_PAGES] = {NULL, "DUNE_SYS_REMAP_FILE_PAGES"},
+       [DUNE_SYS_GETDENTS64] = {NULL, "DUNE_SYS_GETDENTS64"},
+       [DUNE_SYS_SET_TID_ADDRESS] = {NULL, "DUNE_SYS_SET_TID_ADDRESS"},
+       [DUNE_SYS_RESTART_SYSCALL] = {NULL, "DUNE_SYS_RESTART_SYSCALL"},
+       [DUNE_SYS_SEMTIMEDOP] = {NULL, "DUNE_SYS_SEMTIMEDOP"},
+       [DUNE_SYS_FADVISE64] = {NULL, "DUNE_SYS_FADVISE64"},
+       [DUNE_SYS_TIMER_CREATE] = {NULL, "DUNE_SYS_TIMER_CREATE"},
+       [DUNE_SYS_TIMER_SETTIME] = {NULL, "DUNE_SYS_TIMER_SETTIME"},
+       [DUNE_SYS_TIMER_GETTIME] = {NULL, "DUNE_SYS_TIMER_GETTIME"},
+       [DUNE_SYS_TIMER_GETOVERRUN] = {NULL, "DUNE_SYS_TIMER_GETOVERRUN"},
+       [DUNE_SYS_TIMER_DELETE] = {NULL, "DUNE_SYS_TIMER_DELETE"},
+       [DUNE_SYS_CLOCK_SETTIME] = {NULL, "DUNE_SYS_CLOCK_SETTIME"},
+       [DUNE_SYS_CLOCK_GETTIME] = {NULL, "DUNE_SYS_CLOCK_GETTIME"},
+       [DUNE_SYS_CLOCK_GETRES] = {NULL, "DUNE_SYS_CLOCK_GETRES"},
+       [DUNE_SYS_CLOCK_NANOSLEEP] = {NULL, "DUNE_SYS_CLOCK_NANOSLEEP"},
+       [DUNE_SYS_EXIT_GROUP] = {NULL, "DUNE_SYS_EXIT_GROUP"},
+       [DUNE_SYS_EPOLL_WAIT] = {NULL, "DUNE_SYS_EPOLL_WAIT"},
+       [DUNE_SYS_EPOLL_CTL] = {NULL, "DUNE_SYS_EPOLL_CTL"},
+       [DUNE_SYS_TGKILL] = {NULL, "DUNE_SYS_TGKILL"},
+       [DUNE_SYS_UTIMES] = {NULL, "DUNE_SYS_UTIMES"},
+       [DUNE_SYS_VSERVER] = {NULL, "DUNE_SYS_VSERVER"},
+       [DUNE_SYS_MBIND] = {NULL, "DUNE_SYS_MBIND"},
+       [DUNE_SYS_SET_MEMPOLICY] = {NULL, "DUNE_SYS_SET_MEMPOLICY"},
+       [DUNE_SYS_GET_MEMPOLICY] = {NULL, "DUNE_SYS_GET_MEMPOLICY"},
+       [DUNE_SYS_MQ_OPEN] = {NULL, "DUNE_SYS_MQ_OPEN"},
+       [DUNE_SYS_MQ_UNLINK] = {NULL, "DUNE_SYS_MQ_UNLINK"},
+       [DUNE_SYS_MQ_TIMEDSEND] = {NULL, "DUNE_SYS_MQ_TIMEDSEND"},
+       [DUNE_SYS_MQ_TIMEDRECEIVE] = {NULL, "DUNE_SYS_MQ_TIMEDRECEIVE"},
+       [DUNE_SYS_MQ_NOTIFY] = {NULL, "DUNE_SYS_MQ_NOTIFY"},
+       [DUNE_SYS_MQ_GETSETATTR] = {NULL, "DUNE_SYS_MQ_GETSETATTR"},
+       [DUNE_SYS_KEXEC_LOAD] = {NULL, "DUNE_SYS_KEXEC_LOAD"},
+       [DUNE_SYS_WAITID] = {NULL, "DUNE_SYS_WAITID"},
+       [DUNE_SYS_ADD_KEY] = {NULL, "DUNE_SYS_ADD_KEY"},
+       [DUNE_SYS_REQUEST_KEY] = {NULL, "DUNE_SYS_REQUEST_KEY"},
+       [DUNE_SYS_KEYCTL] = {NULL, "DUNE_SYS_KEYCTL"},
+       [DUNE_SYS_IOPRIO_SET] = {NULL, "DUNE_SYS_IOPRIO_SET"},
+       [DUNE_SYS_IOPRIO_GET] = {NULL, "DUNE_SYS_IOPRIO_GET"},
+       [DUNE_SYS_INOTIFY_INIT] = {NULL, "DUNE_SYS_INOTIFY_INIT"},
+       [DUNE_SYS_INOTIFY_ADD_WATCH] = {NULL, "DUNE_SYS_INOTIFY_ADD_WATCH"},
+       [DUNE_SYS_INOTIFY_RM_WATCH] = {NULL, "DUNE_SYS_INOTIFY_RM_WATCH"},
+       [DUNE_SYS_MIGRATE_PAGES] = {NULL, "DUNE_SYS_MIGRATE_PAGES"},
+       [DUNE_SYS_OPENAT] = {NULL, "DUNE_SYS_OPENAT"},
+       [DUNE_SYS_MKDIRAT] = {NULL, "DUNE_SYS_MKDIRAT"},
+       [DUNE_SYS_MKNODAT] = {NULL, "DUNE_SYS_MKNODAT"},
+       [DUNE_SYS_FCHOWNAT] = {NULL, "DUNE_SYS_FCHOWNAT"},
+       [DUNE_SYS_FUTIMESAT] = {NULL, "DUNE_SYS_FUTIMESAT"},
+       [DUNE_SYS_NEWFSTATAT] = {NULL, "DUNE_SYS_NEWFSTATAT"},
+       [DUNE_SYS_UNLINKAT] = {NULL, "DUNE_SYS_UNLINKAT"},
+       [DUNE_SYS_RENAMEAT] = {NULL, "DUNE_SYS_RENAMEAT"},
+       [DUNE_SYS_LINKAT] = {NULL, "DUNE_SYS_LINKAT"},
+       [DUNE_SYS_SYMLINKAT] = {NULL, "DUNE_SYS_SYMLINKAT"},
+       [DUNE_SYS_READLINKAT] = {NULL, "DUNE_SYS_READLINKAT"},
+       [DUNE_SYS_FCHMODAT] = {NULL, "DUNE_SYS_FCHMODAT"},
+       [DUNE_SYS_FACCESSAT] = {NULL, "DUNE_SYS_FACCESSAT"},
+       [DUNE_SYS_PSELECT6] = {NULL, "DUNE_SYS_PSELECT6"},
+       [DUNE_SYS_PPOLL] = {NULL, "DUNE_SYS_PPOLL"},
+       [DUNE_SYS_UNSHARE] = {NULL, "DUNE_SYS_UNSHARE"},
+       [DUNE_SYS_SET_ROBUST_LIST] = {NULL, "DUNE_SYS_SET_ROBUST_LIST"},
+       [DUNE_SYS_GET_ROBUST_LIST] = {NULL, "DUNE_SYS_GET_ROBUST_LIST"},
+       [DUNE_SYS_SPLICE] = {NULL, "DUNE_SYS_SPLICE"},
+       [DUNE_SYS_TEE] = {NULL, "DUNE_SYS_TEE"},
+       [DUNE_SYS_SYNC_FILE_RANGE] = {NULL, "DUNE_SYS_SYNC_FILE_RANGE"},
+       [DUNE_SYS_VMSPLICE] = {NULL, "DUNE_SYS_VMSPLICE"},
+       [DUNE_SYS_MOVE_PAGES] = {NULL, "DUNE_SYS_MOVE_PAGES"},
+       [DUNE_SYS_UTIMENSAT] = {NULL, "DUNE_SYS_UTIMENSAT"},
+       [DUNE_SYS_EPOLL_PWAIT] = {NULL, "DUNE_SYS_EPOLL_PWAIT"},
+       [DUNE_SYS_SIGNALFD] = {NULL, "DUNE_SYS_SIGNALFD"},
+       [DUNE_SYS_TIMERFD_CREATE] = {NULL, "DUNE_SYS_TIMERFD_CREATE"},
+       [DUNE_SYS_EVENTFD] = {NULL, "DUNE_SYS_EVENTFD"},
+       [DUNE_SYS_FALLOCATE] = {NULL, "DUNE_SYS_FALLOCATE"},
+       [DUNE_SYS_TIMERFD_SETTIME] = {NULL, "DUNE_SYS_TIMERFD_SETTIME"},
+       [DUNE_SYS_TIMERFD_GETTIME] = {NULL, "DUNE_SYS_TIMERFD_GETTIME"},
+       [DUNE_SYS_ACCEPT4] = {NULL, "DUNE_SYS_ACCEPT4"},
+       [DUNE_SYS_SIGNALFD4] = {NULL, "DUNE_SYS_SIGNALFD4"},
+       [DUNE_SYS_EVENTFD2] = {NULL, "DUNE_SYS_EVENTFD2"},
+       [DUNE_SYS_EPOLL_CREATE1] = {NULL, "DUNE_SYS_EPOLL_CREATE1"},
+       [DUNE_SYS_DUP3] = {NULL, "DUNE_SYS_DUP3"},
+       [DUNE_SYS_PIPE2] = {NULL, "DUNE_SYS_PIPE2"},
+       [DUNE_SYS_INOTIFY_INIT1] = {NULL, "DUNE_SYS_INOTIFY_INIT1"},
+       [DUNE_SYS_PREADV] = {NULL, "DUNE_SYS_PREADV"},
+       [DUNE_SYS_PWRITEV] = {NULL, "DUNE_SYS_PWRITEV"},
+       [DUNE_SYS_RT_TGSIGQUEUEINFO] = {NULL, "DUNE_SYS_RT_TGSIGQUEUEINFO"},
+       [DUNE_SYS_PERF_EVENT_OPEN] = {NULL, "DUNE_SYS_PERF_EVENT_OPEN"},
+       [DUNE_SYS_RECVMMSG] = {NULL, "DUNE_SYS_RECVMMSG"},
+       [DUNE_SYS_FANOTIFY_INIT] = {NULL, "DUNE_SYS_FANOTIFY_INIT"},
+       [DUNE_SYS_FANOTIFY_MARK] = {NULL, "DUNE_SYS_FANOTIFY_MARK"},
+       [DUNE_SYS_PRLIMIT64] = {NULL, "DUNE_SYS_PRLIMIT64"},
+       [DUNE_SYS_NAME_TO_HANDLE_AT] = {NULL, "DUNE_SYS_NAME_TO_HANDLE_AT"},
+       [DUNE_SYS_OPEN_BY_HANDLE_AT] = {NULL, "DUNE_SYS_OPEN_BY_HANDLE_AT"},
+       [DUNE_SYS_CLOCK_ADJTIME] = {NULL, "DUNE_SYS_CLOCK_ADJTIME"},
+       [DUNE_SYS_SYNCFS] = {NULL, "DUNE_SYS_SYNCFS"},
+       [DUNE_SYS_SENDMMSG] = {NULL, "DUNE_SYS_SENDMMSG"},
+       [DUNE_SYS_SETNS] = {NULL, "DUNE_SYS_SETNS"},
+       [DUNE_SYS_GETCPU] = {NULL, "DUNE_SYS_GETCPU"},
+       [DUNE_SYS_PROCESS_VM_READV] = {NULL, "DUNE_SYS_PROCESS_VM_READV"},
+       [DUNE_SYS_PROCESS_VM_WRITEV] = {NULL, "DUNE_SYS_PROCESS_VM_WRITEV"},
+};
+
+bool init_syscall_table(void)
 {
        int i;
 
-       for (i = 0; i < dune_max_syscall ; ++i) {
-               dune_syscall_table[i].call = NULL;
-               dune_syscall_table[i].name = "nosyscall";
+       for (i = 0; i < DUNE_MAX_NUM_SYSCALLS ; ++i) {
+               if (dune_syscall_table[i].name == NULL)
+                       dune_syscall_table[i].name = "nosyscall";
        }
-       // For now setup the syscalls here,
-       // there is probably a better way to do this.
-       dune_syscall_table[DUNE_SYS_WRITE].call = dune_sys_write;
-       dune_syscall_table[DUNE_SYS_WRITE].name = syscalls[DUNE_SYS_WRITE];
-       dune_syscall_table[DUNE_SYS_GETTID].call = dune_sys_gettid;
-       dune_syscall_table[DUNE_SYS_GETTID].name = syscalls[DUNE_SYS_GETTID];
-       dune_syscall_table[DUNE_SYS_GETTIMEOFDAY].call = dune_sys_gettimeofday;
-       dune_syscall_table[DUNE_SYS_GETTIMEOFDAY].name =
-               syscalls[DUNE_SYS_GETTIMEOFDAY];
-       dune_syscall_table[DUNE_SYS_READ].call = dune_sys_read;
-       dune_syscall_table[DUNE_SYS_READ].name = syscalls[DUNE_SYS_READ];
-       if (dlopen("liblinuxemu_extend.so", RTLD_NOW) == NULL)
+
+       if (dlopen("liblinuxemu_extend.so", RTLD_NOW) == NULL) {
                fprintf(stderr, "Not using any syscall extensions\n Reason: %s\n",
                        dlerror());
+               return false;
+       }
 
+       return true;
+}
+
+void lemuprint(const uint32_t tid, uint64_t syscall_number,
+               const bool isError, const char *fmt, ...)
+{
+       va_list valist;
+       const char *prefix = "[TID %d] %s: ";
+       bool double_logging = false;
+
+       // Do not use global variable as a check to acquire lock.
+       // make sure it is not changed during our acquire/release.
+       int debug = lemu_debug;
+
+       // If we are not going to log anything anyway, just bail out.
+       if (!(debug > 0 || isError))
+               return;
+
+       const char *syscall_name;
+
+       if (syscall_number >= DUNE_MAX_NUM_SYSCALLS)
+               panic("lemuprint: Illegal Syscall #%d!\n", syscall_number);
+       else
+               syscall_name = dune_syscall_table[syscall_number].name;
+
+       va_start(valist, fmt);
+
+       uth_mutex_lock(lemu_logging_lock);
+
+       // Print to stderr if debug level is sufficient
+       if (debug > 1) {
+               fprintf(stderr, prefix, tid, syscall_name);
+               vfprintf(stderr, fmt, valist);
+               // Checks if we will double log to stderr
+               if (lemu_global_logfile == stderr)
+                       double_logging = true;
+       }
+
+       // Log to the global logfile, if we defaulted the global logging to
+       // stderr then we don't want to log 2 times to stderr.
+       if (lemu_global_logfile != NULL && !double_logging) {
+               fprintf(lemu_global_logfile, prefix, tid, syscall_name);
+               vfprintf(lemu_global_logfile, fmt, valist);
+       }
+
+       uth_mutex_unlock(lemu_logging_lock);
+
+       va_end(valist);
 }
 
 
@@ -185,7 +504,7 @@ linuxemu(struct guest_thread *gth, struct vm_trapframe *tf)
 {
        bool ret = false;
 
-       if (tf->tf_rax >= dune_max_syscall) {
+       if (tf->tf_rax >= DUNE_MAX_NUM_SYSCALLS) {
                fprintf(stderr, "System call %d is out of range\n", tf->tf_rax);
                return false;
        }
@@ -197,7 +516,7 @@ linuxemu(struct guest_thread *gth, struct vm_trapframe *tf)
                return false;
        }
 
-       lemuprint(tf->tf_guest_pcoreid, dune_syscall_table[tf->tf_rax].name,
+       lemuprint(tf->tf_guest_pcoreid, tf->tf_rax,
                  false, "vmcall(%d, %p, %p, %p, %p, %p, %p);\n", tf->tf_rax,
                  tf->tf_rdi, tf->tf_rsi, tf->tf_rdx, tf->tf_r10, tf->tf_r8,
                  tf->tf_r9);