diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2009-10-30 07:46:59 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-12-03 02:32:24 -0500 |
commit | 4f926bf291863c237188bd2e27222ed801f12094 (patch) | |
tree | f7cd491f8f05f0bc265271defc8be0b8012867be /arch/x86/kvm/x86.c | |
parent | e50212bb51356f0df48d6cce0aae5acf41df336d (diff) |
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>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cd6fe0a5797f..ba8958dca3c4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4656,10 +4656,20 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, | |||
4656 | struct kvm_guest_debug *dbg) | 4656 | struct kvm_guest_debug *dbg) |
4657 | { | 4657 | { |
4658 | unsigned long rflags; | 4658 | unsigned long rflags; |
4659 | int i; | 4659 | int i, r; |
4660 | 4660 | ||
4661 | vcpu_load(vcpu); | 4661 | vcpu_load(vcpu); |
4662 | 4662 | ||
4663 | if (dbg->control & (KVM_GUESTDBG_INJECT_DB | KVM_GUESTDBG_INJECT_BP)) { | ||
4664 | r = -EBUSY; | ||
4665 | if (vcpu->arch.exception.pending) | ||
4666 | goto unlock_out; | ||
4667 | if (dbg->control & KVM_GUESTDBG_INJECT_DB) | ||
4668 | kvm_queue_exception(vcpu, DB_VECTOR); | ||
4669 | else | ||
4670 | kvm_queue_exception(vcpu, BP_VECTOR); | ||
4671 | } | ||
4672 | |||
4663 | /* | 4673 | /* |
4664 | * Read rflags as long as potentially injected trace flags are still | 4674 | * Read rflags as long as potentially injected trace flags are still |
4665 | * filtered out. | 4675 | * filtered out. |
@@ -4695,14 +4705,12 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, | |||
4695 | 4705 | ||
4696 | kvm_x86_ops->set_guest_debug(vcpu, dbg); | 4706 | kvm_x86_ops->set_guest_debug(vcpu, dbg); |
4697 | 4707 | ||
4698 | if (vcpu->guest_debug & KVM_GUESTDBG_INJECT_DB) | 4708 | r = 0; |
4699 | kvm_queue_exception(vcpu, DB_VECTOR); | ||
4700 | else if (vcpu->guest_debug & KVM_GUESTDBG_INJECT_BP) | ||
4701 | kvm_queue_exception(vcpu, BP_VECTOR); | ||
4702 | 4709 | ||
4710 | unlock_out: | ||
4703 | vcpu_put(vcpu); | 4711 | vcpu_put(vcpu); |
4704 | 4712 | ||
4705 | return 0; | 4713 | return r; |
4706 | } | 4714 | } |
4707 | 4715 | ||
4708 | /* | 4716 | /* |