public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Jes.Sorensen@redhat.com
Cc: kvm@vger.kernel.org, avi@redhat.com, gleb@redhat.com
Subject: Re: [PATCH 1/1] Disable GUEST_INTR_STATE_STI flag before injecting NMI to guest on VMX
Date: Fri, 27 Aug 2010 10:27:37 +0200	[thread overview]
Message-ID: <4C7776F9.4070306@siemens.com> (raw)
In-Reply-To: <1282853162-16925-2-git-send-email-Jes.Sorensen@redhat.com>

Am 26.08.2010 22:06, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
> 
> Injecting an NMI while GUEST_INTR_STATE_STI is set may fail,
> which can cause an EXIT with invalid state, resulting in the
> guest dieing.

Very interesting. Reality obviously doesn't bother about the statement
of the vendor [1].

Just curious: is this limited to specific CPU models or actually a
generic issue?

> 
> Credit to Gleb for figuring out why it was failing and how to
> fix it.
> 
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>  arch/x86/kvm/vmx.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index cf56462..8e95371 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2888,6 +2888,8 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
>  		kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
>  		return;
>  	}
> +	vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
> +			vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & ~GUEST_INTR_STATE_STI);
>  	vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
>  			INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR);
>  }

Thinking about the implications: Independent of virtualization, this
means that no code code can in any way rely on the STI shadow if there
are NMIs present that could "consume" it. Because after return from
those NMIs, interrupts could then be injected on the instruction that
was originally under the shadow.

Jan

[1] http://thread.gmane.org/gmane.comp.emulators.kvm.devel/52144

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  reply	other threads:[~2010-08-27  8:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26 20:06 [PATCH 0/1] Disable GUEST_INTR_STATE_STI flag before injecting NMI to VMX guest Jes.Sorensen
2010-08-26 20:06 ` [PATCH 1/1] Disable GUEST_INTR_STATE_STI flag before injecting NMI to guest on VMX Jes.Sorensen
2010-08-27  8:27   ` Jan Kiszka [this message]
2010-08-27  8:31     ` Jes Sorensen
2010-08-27  8:39       ` Jan Kiszka
2010-08-27  9:46         ` Avi Kivity
2010-08-27 11:06           ` Jan Kiszka
2010-08-27 13:58             ` Avi Kivity
2010-08-27 14:13               ` Jan Kiszka
2010-08-27 15:50                 ` Avi Kivity
2010-08-27 16:43                   ` Jan Kiszka
2010-08-29  8:09                     ` Avi Kivity
2010-08-27  9:44     ` Avi Kivity
2010-08-27 11:06       ` Jan Kiszka
2010-08-27 13:54         ` Avi Kivity
2010-08-27 14:12           ` Jan Kiszka
2010-08-27 11:16       ` Gleb Natapov
2010-08-27 11:23         ` Jan Kiszka
2010-08-27 11:25           ` Gleb Natapov
2010-08-27 11:04     ` Gleb Natapov
2010-08-27 11:09       ` Jan Kiszka
2010-08-27  9:21   ` Avi Kivity
2010-08-27  9:41     ` Jes Sorensen
2010-08-27  9:47       ` Avi Kivity
2010-08-27  9:56         ` Jes Sorensen
2010-08-27  9:59           ` Avi Kivity
2010-08-27 10:01             ` Jes Sorensen

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=4C7776F9.4070306@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    /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