From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] KVM: x86: Add instruction length to VCPU event state Date: Sat, 13 Feb 2010 20:22:53 +0200 Message-ID: <20100213182253.GB2511@redhat.com> References: <4B76762C.10107@web.de> <20100213152635.GA2511@redhat.com> <4B76E638.5010100@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , Marcelo Tosatti , kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:28214 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753201Ab0BMSWz (ORCPT ); Sat, 13 Feb 2010 13:22:55 -0500 Content-Disposition: inline In-Reply-To: <4B76E638.5010100@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On Sat, Feb 13, 2010 at 06:49:44PM +0100, Jan Kiszka wrote: > Gleb Natapov wrote: > > On Sat, Feb 13, 2010 at 10:51:40AM +0100, Jan Kiszka wrote: > >> From: Jan Kiszka > >> > >> VMX requires a properly set instruction length VM entry field when > >> trying to inject soft exception and interrupts. We have to preserve this > >> state across VM save/restore to avoid breaking the re-injection of such > >> events on Intel. So add it to the new VCPU event state. > >> > > We shouldn't re-inject soft exceptions/interrupts after migration, but > > re-execute instruction instead. Instruction length field doesn't exist > > on SVM and migration shouldn't expose implementation details. > > > > Hmm, then I guess this totally untested patch should fly: > I don't understand what problem are you trying to solve by your patch. During normal operation event_exit_inst_len will be set to correct value. After migration rip will point to int instruction an no even will be pending at all. Here is the patch: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a1b71da..519f867 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2121,14 +2121,18 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu, { vcpu_load(vcpu); - events->exception.injected = vcpu->arch.exception.pending; - events->exception.nr = vcpu->arch.exception.nr; - events->exception.has_error_code = vcpu->arch.exception.has_error_code; - events->exception.error_code = vcpu->arch.exception.error_code; - - events->interrupt.injected = vcpu->arch.interrupt.pending; - events->interrupt.nr = vcpu->arch.interrupt.nr; - events->interrupt.soft = vcpu->arch.interrupt.soft; + if (!kvm_exception_is_soft(nr)) { + events->exception.injected = vcpu->arch.exception.pending; + events->exception.nr = vcpu->arch.exception.nr; + events->exception.has_error_code = vcpu->arch.exception.has_error_code; + events->exception.error_code = vcpu->arch.exception.error_code; + } + + if (!events->interrupt.soft) { + events->interrupt.injected = vcpu->arch.interrupt.pending; + events->interrupt.nr = vcpu->arch.interrupt.nr; + events->interrupt.soft = vcpu->arch.interrupt.soft; + } events->nmi.injected = vcpu->arch.nmi_injected; events->nmi.pending = vcpu->arch.nmi_pending; -- Gleb.