KVM: x86: Polish exception injection via KVM_SET_GUEST_DEBUG
Decouple KVM_GUESTDBG_INJECT_DB and KVM_GUESTDBG_INJECT_BP from KVM_GUESTDBG_ENABLE, their are actually orthogonal. At this chance, avoid triggering the WARN_ON in kvm_queue_exception if there is already an exception pending and reject such invalid requests. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
parent
e50212bb51
commit
4f926bf291
|
@ -4656,10 +4656,20 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
|
||||||
struct kvm_guest_debug *dbg)
|
struct kvm_guest_debug *dbg)
|
||||||
{
|
{
|
||||||
unsigned long rflags;
|
unsigned long rflags;
|
||||||
int i;
|
int i, r;
|
||||||
|
|
||||||
vcpu_load(vcpu);
|
vcpu_load(vcpu);
|
||||||
|
|
||||||
|
if (dbg->control & (KVM_GUESTDBG_INJECT_DB | KVM_GUESTDBG_INJECT_BP)) {
|
||||||
|
r = -EBUSY;
|
||||||
|
if (vcpu->arch.exception.pending)
|
||||||
|
goto unlock_out;
|
||||||
|
if (dbg->control & KVM_GUESTDBG_INJECT_DB)
|
||||||
|
kvm_queue_exception(vcpu, DB_VECTOR);
|
||||||
|
else
|
||||||
|
kvm_queue_exception(vcpu, BP_VECTOR);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read rflags as long as potentially injected trace flags are still
|
* Read rflags as long as potentially injected trace flags are still
|
||||||
* filtered out.
|
* filtered out.
|
||||||
|
@ -4695,14 +4705,12 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
|
||||||
|
|
||||||
kvm_x86_ops->set_guest_debug(vcpu, dbg);
|
kvm_x86_ops->set_guest_debug(vcpu, dbg);
|
||||||
|
|
||||||
if (vcpu->guest_debug & KVM_GUESTDBG_INJECT_DB)
|
r = 0;
|
||||||
kvm_queue_exception(vcpu, DB_VECTOR);
|
|
||||||
else if (vcpu->guest_debug & KVM_GUESTDBG_INJECT_BP)
|
|
||||||
kvm_queue_exception(vcpu, BP_VECTOR);
|
|
||||||
|
|
||||||
|
unlock_out:
|
||||||
vcpu_put(vcpu);
|
vcpu_put(vcpu);
|
||||||
|
|
||||||
return 0;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue