public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: [PATCH] KVM: x86: Add instruction length to VCPU event state
Date: Sat, 13 Feb 2010 10:51:40 +0100	[thread overview]
Message-ID: <4B76762C.10107@web.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 2430 bytes --]

From: Jan Kiszka <jan.kiszka@siemens.com>

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.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Existing qemu[-kvm]-0.12 that is already prepared for 2.6.33 will need
an update now. Whenever we actually ran into the case that
event_exit_inst_len was evaluated by VMX, we were playing roulette with
a high probability to crash the guest. This will not changes for already
released 0.12.x versions.

 Documentation/kvm/api.txt  |    2 ++
 arch/x86/include/asm/kvm.h |    3 ++-
 arch/x86/kvm/x86.c         |    4 ++++
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt
index c6416a3..aa11d70 100644
--- a/Documentation/kvm/api.txt
+++ b/Documentation/kvm/api.txt
@@ -686,6 +686,8 @@ struct kvm_vcpu_events {
 	} nmi;
 	__u32 sipi_vector;
 	__u32 flags;
+	__u32 instruction_length; /* used by VMX */
+	__u32 reserved[9];
 };
 
 4.30 KVM_SET_VCPU_EVENTS
diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index f46b79f..570b6cc 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -281,7 +281,8 @@ struct kvm_vcpu_events {
 	} nmi;
 	__u32 sipi_vector;
 	__u32 flags;
-	__u32 reserved[10];
+	__u32 instruction_length; /* used by VMX */
+	__u32 reserved[9];
 };
 
 #endif /* _ASM_X86_KVM_H */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 86b739f..0cc6cfb 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2134,6 +2134,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
 	events->nmi.pending = vcpu->arch.nmi_pending;
 	events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu);
 
+	events->instruction_length = vcpu->arch.event_exit_inst_len;
+
 	events->sipi_vector = vcpu->arch.sipi_vector;
 
 	events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING
@@ -2170,6 +2172,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
 	if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR)
 		vcpu->arch.sipi_vector = events->sipi_vector;
 
+	vcpu->arch.event_exit_inst_len = events->instruction_length;
+
 	vcpu_put(vcpu);
 
 	return 0;


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

             reply	other threads:[~2010-02-13  9:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-13  9:51 Jan Kiszka [this message]
2010-02-13 10:21 ` [PATCH] KVM: x86: Add instruction length to VCPU event state Avi Kivity
2010-02-13 10:55   ` Jan Kiszka
2010-02-13 15:26 ` Gleb Natapov
2010-02-13 17:49   ` Jan Kiszka
2010-02-13 18:22     ` Gleb Natapov
2010-02-13 18:41       ` Jan Kiszka
2010-02-13 19:06         ` Gleb Natapov
2010-02-13 19:20           ` Jan Kiszka
2010-02-13 19:25             ` Gleb Natapov
2010-02-14 10:19               ` Jan Kiszka
2010-02-14 13:44             ` Paolo Bonzini
2010-02-14 14:38               ` Gleb Natapov
2010-02-14 15:10               ` Avi Kivity

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=4B76762C.10107@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@redhat.com \
    --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