The vcpu thread can be preempted after the guest_debug_pre() callback,
resulting in invalid debug registers on the new vcpu.
Move it inside the non-preemptable section.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
        down_read(&vcpu->kvm->slots_lock);
        vapic_enter(vcpu);
 
-preempted:
-       if (vcpu->guest_debug.enabled)
-               kvm_x86_ops->guest_debug_pre(vcpu);
-
 again:
        if (vcpu->requests)
                if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests))
                goto out;
        }
 
+       if (vcpu->guest_debug.enabled)
+               kvm_x86_ops->guest_debug_pre(vcpu);
+
        vcpu->guest_mode = 1;
        /*
         * Make sure that guest_mode assignment won't happen after
        if (r > 0) {
                kvm_resched(vcpu);
                down_read(&vcpu->kvm->slots_lock);
-               goto preempted;
+               goto again;
        }
 
        post_kvm_run_save(vcpu, kvm_run);