* [PATCH] KVM: x86: Polish exception injection via KVM_SET_GUEST_DEBUG
@ 2009-10-30 11:46 Jan Kiszka
2009-11-03 13:26 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2009-10-30 11:46 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
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>
---
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 2ef3906..beaa6d4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4636,10 +4636,20 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
struct kvm_guest_debug *dbg)
{
unsigned long rflags;
- int i;
+ int i, r;
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
* filtered out.
@@ -4675,14 +4685,12 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
kvm_x86_ops->set_guest_debug(vcpu, dbg);
- if (vcpu->guest_debug & KVM_GUESTDBG_INJECT_DB)
- kvm_queue_exception(vcpu, DB_VECTOR);
- else if (vcpu->guest_debug & KVM_GUESTDBG_INJECT_BP)
- kvm_queue_exception(vcpu, BP_VECTOR);
+ r = 0;
+unlock_out:
vcpu_put(vcpu);
- return 0;
+ return r;
}
/*
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86: Polish exception injection via KVM_SET_GUEST_DEBUG
2009-10-30 11:46 [PATCH] KVM: x86: Polish exception injection via KVM_SET_GUEST_DEBUG Jan Kiszka
@ 2009-11-03 13:26 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2009-11-03 13:26 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Avi Kivity, kvm
On Fri, Oct 30, 2009 at 12:46:59PM +0100, Jan Kiszka wrote:
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-03 13:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-30 11:46 [PATCH] KVM: x86: Polish exception injection via KVM_SET_GUEST_DEBUG Jan Kiszka
2009-11-03 13:26 ` Marcelo Tosatti
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.