public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Do not return soft events in vcpu_events
Date: Sun, 14 Feb 2010 12:25:53 +0200	[thread overview]
Message-ID: <20100214102553.GG2511@redhat.com> (raw)
In-Reply-To: <4B77CE7C.8050606@web.de>

On Sun, Feb 14, 2010 at 11:20:44AM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> 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 <jan.kiszka@siemens.com>
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.

      reply	other threads:[~2010-02-14 10:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14 10:20 [PATCH] KVM: x86: Do not return soft events in vcpu_events Jan Kiszka
2010-02-14 10:25 ` Gleb Natapov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100214102553.GG2511@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox