parlib: vmm: Allow VM uthreads to have no FP state
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 13 Sep 2017 19:56:06 +0000 (15:56 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 14 Sep 2017 20:37:58 +0000 (16:37 -0400)
This is for freshly created or reinitialized guest_threads.  They will run
with whatever the current vcore's FP state was.  We were basically doing
that already.

If we really need VM threads to have no FP state, we can add a helper to
zero the FP state (e.g. set the xstate_bv bits to 0 on x86).

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/uthread.c
user/vmm/sched.c

index 3e7443b..951b93e 100644 (file)
@@ -720,12 +720,16 @@ void __attribute__((noreturn)) run_uthread(struct uthread *uthread)
         * SW, FP should never be saved. */
        switch (uthread->u_ctx.type) {
        case ROS_HW_CTX:
-       case ROS_VM_CTX:
                assert(uthread->flags & UTHREAD_FPSAVED);
                break;
        case ROS_SW_CTX:
                assert(!(uthread->flags & UTHREAD_FPSAVED));
                break;
+       case ROS_VM_CTX:
+               /* Don't care.  This gives it the state of the vcore when it starts up.
+                * If we care about leaking FPU / XMM state, we can create a new one for
+                * every VM TF (or vthread reuse). */
+               break;
        }
        if (has_refl_fault(&uthread->u_ctx)) {
                clear_refl_fault(&uthread->u_ctx);
index 1cc5b19..26d5d17 100644 (file)
@@ -521,12 +521,8 @@ static struct guest_thread *create_guest_thread(struct virtual_machine *vm,
        }
        gth->uthread.u_ctx.type = ROS_VM_CTX;
        gth->uthread.u_ctx.tf.vm_tf.tf_guest_pcoreid = gpcoreid;
-       /* No need to init the ctlr.  It gets re-init'd each time it starts. */
        uthread_init((struct uthread*)gth, &gth_attr);
        uthread_init((struct uthread*)cth, &cth_attr);
-       /* TODO: give it a correct FP state.  Our current one is probably fine */
-       restore_fp_state(&gth->uthread.as);
-       gth->uthread.flags |= UTHREAD_FPSAVED;
        gth->halt_mtx = uth_mutex_alloc();
        gth->halt_cv = uth_cond_var_alloc();
        return gth;