Commit 29415c37 authored by Marcelo Tosatti's avatar Marcelo Tosatti Committed by Avi Kivity

KVM: set debug registers after "schedulable" section

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: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 8349b5cd
...@@ -3113,10 +3113,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -3113,10 +3113,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
down_read(&vcpu->kvm->slots_lock); down_read(&vcpu->kvm->slots_lock);
vapic_enter(vcpu); vapic_enter(vcpu);
preempted:
if (vcpu->guest_debug.enabled)
kvm_x86_ops->guest_debug_pre(vcpu);
again: again:
if (vcpu->requests) if (vcpu->requests)
if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests))
...@@ -3170,6 +3166,9 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -3170,6 +3166,9 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
goto out; goto out;
} }
if (vcpu->guest_debug.enabled)
kvm_x86_ops->guest_debug_pre(vcpu);
vcpu->guest_mode = 1; vcpu->guest_mode = 1;
/* /*
* Make sure that guest_mode assignment won't happen after * Make sure that guest_mode assignment won't happen after
...@@ -3244,7 +3243,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -3244,7 +3243,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (r > 0) { if (r > 0) {
kvm_resched(vcpu); kvm_resched(vcpu);
down_read(&vcpu->kvm->slots_lock); down_read(&vcpu->kvm->slots_lock);
goto preempted; goto again;
} }
post_kvm_run_save(vcpu, kvm_run); post_kvm_run_save(vcpu, kvm_run);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment