fix potential use of uninitialized variable, noticed by jsg@.
authormlarkin <mlarkin@openbsd.org>
Wed, 28 Jun 2017 07:10:02 +0000 (07:10 +0000)
committermlarkin <mlarkin@openbsd.org>
Wed, 28 Jun 2017 07:10:02 +0000 (07:10 +0000)
sys/arch/amd64/amd64/vmm.c

index a1c7b1a..c0495ff 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmm.c,v 1.154 2017/06/20 06:25:01 mlarkin Exp $       */
+/*     $OpenBSD: vmm.c,v 1.155 2017/06/28 07:10:02 mlarkin Exp $       */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -5673,6 +5673,12 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
                vmcb->v_tlb_control = SVM_TLB_CONTROL_FLUSH_NONE;
                svm_set_clean(vcpu, SVM_CLEANBITS_ALL);
 
+               /* Record the exit reason on successful exit */
+               if (ret == 0) {
+                       exit_reason = vmcb->v_exitcode;
+                       vcpu->vc_gueststate.vg_exit_reason = exit_reason;
+               }       
+
                if (ret || exit_reason != SVM_VMEXIT_INTR) {
                        KERNEL_LOCK();
                        locked = 1;
@@ -5683,9 +5689,6 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
                if (ret == 0) {
                        resume = 1;
 
-                       exit_reason = vmcb->v_exitcode;
-                       vcpu->vc_gueststate.vg_exit_reason = exit_reason;
-
                        vcpu->vc_gueststate.vg_rflags = vmcb->v_rflags;
 
                        /*