From patchwork Fri Oct 30 11:46:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 56601 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9UBlJHT032671 for ; Fri, 30 Oct 2009 11:47:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756489AbZJ3LrK (ORCPT ); Fri, 30 Oct 2009 07:47:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756534AbZJ3LrK (ORCPT ); Fri, 30 Oct 2009 07:47:10 -0400 Received: from david.siemens.de ([192.35.17.14]:19639 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756356AbZJ3LrJ (ORCPT ); Fri, 30 Oct 2009 07:47:09 -0400 Received: from mail3.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n9UBl0Kb006525; Fri, 30 Oct 2009 12:47:00 +0100 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n9UBkxGj019056; Fri, 30 Oct 2009 12:47:00 +0100 Message-ID: <4AEAD233.2010000@siemens.com> Date: Fri, 30 Oct 2009 12:46:59 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: kvm Subject: [PATCH] KVM: x86: Polish exception injection via KVM_SET_GUEST_DEBUG Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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; } /*