Remove the frontend appserver code
[akaros.git] / kern / src / syscall.c
index 39425af..d4ffa34 100644 (file)
@@ -23,7 +23,6 @@
 #include <kmalloc.h>
 #include <profiler.h>
 #include <stdio.h>
-#include <frontend.h>
 #include <hashtable.h>
 #include <bitmask.h>
 #include <vfs.h>
@@ -1490,21 +1489,23 @@ static int sys_pop_ctx(struct proc *p, struct user_context *ctx)
        return 0;
 }
 
-/* Initializes a process to run virtual machine contexts, returning the number
- * initialized, optionally setting errno */
-static int sys_vmm_setup(struct proc *p, unsigned int nr_guest_pcores,
-                         struct vmm_gpcore_init *gpcis, int flags)
+static int sys_vmm_add_gpcs(struct proc *p, unsigned int nr_more_gpcs,
+                            struct vmm_gpcore_init *gpcis)
 {
-       int ret;
        ERRSTACK(1);
+       struct vmm *vmm = &p->vmm;
 
+       qlock(&vmm->qlock);
        if (waserror()) {
+               qunlock(&vmm->qlock);
                poperror();
                return -1;
        }
-       ret = vmm_struct_init(p, nr_guest_pcores, gpcis, flags);
+       __vmm_struct_init(p);
+       __vmm_add_gpcs(p, nr_more_gpcs, gpcis);
+       qunlock(&vmm->qlock);
        poperror();
-       return ret;
+       return nr_more_gpcs;
 }
 
 static int sys_vmm_poke_guest(struct proc *p, int guest_pcoreid)
@@ -1512,45 +1513,52 @@ static int sys_vmm_poke_guest(struct proc *p, int guest_pcoreid)
        return vmm_poke_guest(p, guest_pcoreid);
 }
 
-static int no_amd(void)
-{
-       set_error(ENOTSUP, "AMD VMMs unsupported");
-       return -1;
-}
-
 static int sys_vmm_ctl(struct proc *p, int cmd, unsigned long arg1,
                        unsigned long arg2, unsigned long arg3,
                        unsigned long arg4)
 {
+       ERRSTACK(1);
        int ret;
+       struct vmm *vmm = &p->vmm;
 
        /* Protects against concurrent setters and for gets that are not atomic
         * reads (say, multiple exec ctls). */
-       qlock(&p->vmm.qlock);
+       qlock(&vmm->qlock);
+       if (waserror()) {
+               qunlock(&vmm->qlock);
+               poperror();
+               return -1;
+       }
+       __vmm_struct_init(p);
        switch (cmd) {
        case VMM_CTL_GET_EXITS:
-               if (p->vmm.amd)
-                       ret = no_amd();
-               else
-                       ret = vmx_ctl_get_exits(&p->vmm.vmx);
+               if (vmm->amd)
+                       error(ENOTSUP, "AMD VMMs unsupported");
+               ret = vmx_ctl_get_exits(&vmm->vmx);
                break;
        case VMM_CTL_SET_EXITS:
-               if (arg1 & ~VMM_CTL_ALL_EXITS) {
-                       set_error(EINVAL, "Bad vmm_ctl_exits %x (%x)", arg1,
-                                 VMM_CTL_ALL_EXITS);
-                       ret = -1;
-                       break;
-               }
-               if (p->vmm.amd)
-                       ret = no_amd();
-               else
-                       ret = vmx_ctl_set_exits(&p->vmm.vmx, arg1);
+               if (arg1 & ~VMM_CTL_ALL_EXITS)
+                       error(EINVAL, "Bad vmm_ctl_exits %x (%x)", arg1,
+                             VMM_CTL_ALL_EXITS);
+               if (vmm->amd)
+                       error(ENOTSUP, "AMD VMMs unsupported");
+               ret = vmx_ctl_set_exits(&vmm->vmx, arg1);
+               break;
+       case VMM_CTL_GET_FLAGS:
+               ret = vmm->flags;
+               break;
+       case VMM_CTL_SET_FLAGS:
+               if (arg1 & ~VMM_CTL_ALL_FLAGS)
+                       error(EINVAL, "Bad vmm_ctl flags.  Got 0x%lx, allowed 0x%lx\n",
+                             arg1, VMM_CTL_ALL_FLAGS);
+               vmm->flags = arg1;
+               ret = 0;
                break;
        default:
-               set_error(EINVAL, "Bad vmm_ctl cmd %d", cmd);
-               ret = -1;
+               error(EINVAL, "Bad vmm_ctl cmd %d", cmd);
        }
-       qunlock(&p->vmm.qlock);
+       qunlock(&vmm->qlock);
+       poperror();
        return ret;
 }
 
@@ -1726,11 +1734,6 @@ static intreg_t sys_close(struct proc *p, int fd)
        return retval;
 }
 
-/* kept around til we remove the last ufe */
-#define ufe(which,a0,a1,a2,a3) \
-       frontend_syscall_errno(p,APPSERVER_SYSCALL_##which,\
-                          (int)(a0),(int)(a1),(int)(a2),(int)(a3))
-
 static intreg_t sys_fstat(struct proc *p, int fd, struct kstat *u_stat)
 {
        struct kstat *kbuf;
@@ -2629,7 +2632,7 @@ const struct sys_table_entry syscall_table[] = {
        [SYS_init_arsc] = {(syscall_t)sys_init_arsc, "init_arsc"},
 #endif
        [SYS_change_to_m] = {(syscall_t)sys_change_to_m, "change_to_m"},
-       [SYS_vmm_setup] = {(syscall_t)sys_vmm_setup, "vmm_setup"},
+       [SYS_vmm_add_gpcs] = {(syscall_t)sys_vmm_add_gpcs, "vmm_add_gpcs"},
        [SYS_vmm_poke_guest] = {(syscall_t)sys_vmm_poke_guest, "vmm_poke_guest"},
        [SYS_vmm_ctl] = {(syscall_t)sys_vmm_ctl, "vmm_ctl"},
        [SYS_poke_ksched] = {(syscall_t)sys_poke_ksched, "poke_ksched"},