From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] KVM: x86: Do not return soft events in vcpu_events Date: Sun, 14 Feb 2010 12:25:53 +0200 Message-ID: <20100214102553.GG2511@redhat.com> References: <4B77CE7C.8050606@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]:55380 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891Ab0BNKZz (ORCPT ); Sun, 14 Feb 2010 05:25:55 -0500 Content-Disposition: inline In-Reply-To: <4B77CE7C.8050606@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Feb 14, 2010 at 11:20:44AM +0100, Jan Kiszka wrote: > From: Jan Kiszka > > Based on Gleb's suggestion: To avoid that user space migrates a pending > software exception or interrupt, mask them out on KVM_GET_VCPU_EVENTS. > Without this, user space would try to reinject them, and we would have > to reconstruct the proper instruction length for VMX event injection. > Now the pending event will be reinjected via executing the triggering > instruction again. > > Signed-off-by: Jan Kiszka Looks good to me. > --- > arch/x86/kvm/x86.c | 9 ++++++--- > 1 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 86b739f..50d1d2a 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -2121,14 +2121,17 @@ 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.injected = > + vcpu->arch.exception.pending && > + !kvm_exception_is_soft(vcpu->arch.exception.nr); > 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.injected = > + vcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft; > events->interrupt.nr = vcpu->arch.interrupt.nr; > - events->interrupt.soft = vcpu->arch.interrupt.soft; > + events->interrupt.soft = 0; > > events->nmi.injected = vcpu->arch.nmi_injected; > events->nmi.pending = vcpu->arch.nmi_pending; -- Gleb.