Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bench'
Browse files Browse the repository at this point in the history
  • Loading branch information
nyuichi committed Jul 10, 2017
2 parents 0241ce1 + 2bfd3bb commit 5745695
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
8 changes: 8 additions & 0 deletions lib/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,16 @@ vmm_reentry(struct vmm_snapshot *snapshot)
hv_return_t ret;

printk("vmm_restore\n");
bool retried = false;
retry:
ret = hv_vm_create(HV_VM_DEFAULT);
if (ret != HV_SUCCESS) {
if (!retried && ret == HV_NO_DEVICE) {
sleep(0);
retried = true;
printk("retried\n");
goto retry;
}
panic("could not create the vm: error code %x", ret);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ warnk(const char *fmt, ...)
print_to_sink(warnk_sink, &printk_sync, mes);

#ifndef NDEBUG
const char *magenda = "\x1b[35m", *reset = "\x1b[0m";
fprintf(stderr, "%sNoah WARNING: %s%s", magenda, mes, reset);
//const char *magenda = "\x1b[35m", *reset = "\x1b[0m";
//fprintf(stderr, "%sNoah WARNING: %s%s", magenda, mes, reset);
#endif

free(mes);
Expand Down Expand Up @@ -153,7 +153,7 @@ panic(const char *fmt, ...)
vasprintf(&given, fmt, ap);
asprintf(&mes, "!!PANIC!!\nperror is \"%s\" if it is valid\n%s\n", strerror(err), given);

printk("%s", mes);
printk("!!PANIC!!%s", mes);
printbt_to_sink(printk_sink, &printk_sync);

print_to_sink(warnk_sink, &warnk_sync, mes);
Expand Down
8 changes: 7 additions & 1 deletion src/ipc/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ wake_sighandler()
meta_strace_sigdeliver(sig);
switch (proc.sigaction[sig - 1].lsa_handler) {
case LINUX_SIG_DFL:
warnk("Handling default signal in Noah is not implemented yet\n");
//warnk("Handling default signal in Noah is not implemented yet\n");
/* fall through */
case LINUX_SIG_IGN:
continue;
Expand Down Expand Up @@ -414,6 +414,11 @@ DEFINE_SYSCALL(rt_sigsuspend, gaddr_t, nset, size_t, size)
}
LINUX_SIGDELSET(&lnset, LINUX_SIGKILL);
LINUX_SIGDELSET(&lnset, LINUX_SIGSTOP);

sigset_t dwset, doset;
linux_to_darwin_sigset(&lnset, &dwset);
pthread_sigmask(SIG_SETMASK, &dwset, &doset);

task.sigmask = lnset;

while (1) {
Expand All @@ -426,6 +431,7 @@ DEFINE_SYSCALL(rt_sigsuspend, gaddr_t, nset, size_t, size)
}
handle_signal();
warnk("signal handled\n");
pthread_sigmask(SIG_SETMASK, &doset, NULL);
task.sigmask = loset;
return -LINUX_EINTR; /* returns -EINTR when its execution ends NORMALLY */
}
Expand Down
6 changes: 3 additions & 3 deletions src/proc/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ do_exec(const char *elf_path, int argc, char *argv[], char **envp)
if ((err = load_script(data, st.st_size, elf_path, argc, argv, envp)) < 0)
return err;
}
else if (4 <= st.st_size && memcmp(data, "\xcf\xfa\xed\xfe", 4) == 0) {
/* Mach-O */
/*else if (4 <= st.st_size && memcmp(data, "\xcf\xfa\xed\xfe", 4) == 0) {
// Mach-O
return syswrap(execve(elf_path, argv, envp));
}
}*/
else {
return -LINUX_ENOEXEC; /* unsupported file type */
}
Expand Down
7 changes: 5 additions & 2 deletions src/proc/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

#include <sys/sysctl.h>

#define _GNU_SOURCE
#include <sys/syscall.h>

struct proc proc;
_Thread_local struct task task;

Expand All @@ -34,7 +37,7 @@ DEFINE_SYSCALL(sched_yield)

DEFINE_SYSCALL(getpid)
{
return syswrap(getpid());
return syswrap(syscall(SYS_getpid));
}

DEFINE_SYSCALL(getuid)
Expand Down Expand Up @@ -255,7 +258,7 @@ DEFINE_SYSCALL(getsid, l_pid_t, pid)
DEFINE_SYSCALL(getgroups, int, gidsetsize, gaddr_t, grouplist_ptr)
{
gid_t *gl = malloc(gidsetsize * sizeof(gid_t));
int r = syswrap(getgroups(gidsetsize, gl));
int r = syswrap(getgroups(gidsetsize, gidsetsize == 0 ? NULL : gl));
if (r < 0) {
goto out;
}
Expand Down

0 comments on commit 5745695

Please sign in to comment.