From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] KVM: VMX: Do not skip the instruction if handle_dr injects a fault Date: Fri, 20 Dec 2013 19:20:54 +0100 Message-ID: <52B48A86.9050606@redhat.com> References: <52B1E678.6060609@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:10874 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750874Ab3LTSVB (ORCPT ); Fri, 20 Dec 2013 13:21:01 -0500 In-Reply-To: <52B1E678.6060609@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: Il 18/12/2013 19:16, Jan Kiszka ha scritto: > If kvm_get_dr or kvm_set_dr reports that it raised a fault, we must not > advance the instruction pointer. Otherwise the exception will hit the > wrong instruction. > > Signed-off-by: Jan Kiszka > --- > arch/x86/kvm/vmx.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 56c654c..ee3bf54 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -5141,10 +5141,14 @@ static int handle_dr(struct kvm_vcpu *vcpu) > reg = DEBUG_REG_ACCESS_REG(exit_qualification); > if (exit_qualification & TYPE_MOV_FROM_DR) { > unsigned long val; > - if (!kvm_get_dr(vcpu, dr, &val)) > - kvm_register_write(vcpu, reg, val); > + > + if (kvm_get_dr(vcpu, dr, &val)) > + return 1; > + kvm_register_write(vcpu, reg, val); > } else > - kvm_set_dr(vcpu, dr, vcpu->arch.regs[reg]); > + if (kvm_set_dr(vcpu, dr, vcpu->arch.regs[reg])) > + return 1; > + > skip_emulated_instruction(vcpu); > return 1; > } > Applied to kvm/queue, thanks. Paolo