From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 2/2] KVM: VMX: Fix guest debugging while in L2 Date: Wed, 10 Feb 2016 15:41:19 +0100 Message-ID: <56BB4C0F.4020008@redhat.com> References: <56BA3A8D.7020106@web.de> <56BA3AC6.6000104@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Cc: kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58411 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750713AbcBJOlX (ORCPT ); Wed, 10 Feb 2016 09:41:23 -0500 In-Reply-To: <56BA3AC6.6000104@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On 09/02/2016 20:15, Jan Kiszka wrote: > From: Jan Kiszka > > When we take a #DB or #BP vmexit while in guest mode, we first of all > need to check if there is ongoing guest debugging that might be > interested in the event. Currently, we unconditionally leave L2 and > inject the event into L1 if it is intercepting the exceptions. That > breaks things marvelously. > > Signed-off-by: Jan Kiszka > --- > arch/x86/kvm/vmx.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 7852092..cb501d3 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -968,6 +968,16 @@ static inline bool is_exception_n(u32 intr_info, u8 vector) > (INTR_TYPE_HARD_EXCEPTION | vector | INTR_INFO_VALID_MASK); > } > > +static inline bool is_debug(u32 intr_info) > +{ > + return is_exception_n(intr_info, DB_VECTOR); > +} > + > +static inline bool is_breakpoint(u32 intr_info) > +{ > + return is_exception_n(intr_info, BP_VECTOR); > +} > + > static inline bool is_page_fault(u32 intr_info) > { > return is_exception_n(intr_info, PF_VECTOR); > @@ -7753,6 +7763,13 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) > else if (is_no_device(intr_info) && > !(vmcs12->guest_cr0 & X86_CR0_TS)) > return false; > + else if (is_debug(intr_info) && > + vcpu->guest_debug & > + (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) > + return false; > + else if (is_breakpoint(intr_info) && > + vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) > + return false; > return vmcs12->exception_bitmap & > (1u << (intr_info & INTR_INFO_VECTOR_MASK)); > case EXIT_REASON_EXTERNAL_INTERRUPT: > Thanks, I'll apply both patches shortly to kvm/queue. However, next time please do not sign the patches. git send-email doesn't like the way PGP signed messages escape "-" at the beginning of the line. Paolo