From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] KVM: x86: Add instruction length to VCPU event state Date: Sat, 13 Feb 2010 10:51:40 +0100 Message-ID: <4B76762C.10107@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigAE022DCD91D8D6103DFEA7A6" Cc: kvm To: Avi Kivity , Marcelo Tosatti Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:56565 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067Ab0BMJvq (ORCPT ); Sat, 13 Feb 2010 04:51:46 -0500 Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAE022DCD91D8D6103DFEA7A6 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Jan Kiszka --- 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]; }; =20 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]; }; =20 #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(stru= ct kvm_vcpu *vcpu, events->nmi.pending =3D vcpu->arch.nmi_pending; events->nmi.masked =3D kvm_x86_ops->get_nmi_mask(vcpu); =20 + events->instruction_length =3D vcpu->arch.event_exit_inst_len; + events->sipi_vector =3D vcpu->arch.sipi_vector; =20 events->flags =3D (KVM_VCPUEVENT_VALID_NMI_PENDING @@ -2170,6 +2172,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struc= t kvm_vcpu *vcpu, if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR) vcpu->arch.sipi_vector =3D events->sipi_vector; =20 + vcpu->arch.event_exit_inst_len =3D events->instruction_length; + vcpu_put(vcpu); =20 return 0; --------------enigAE022DCD91D8D6103DFEA7A6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkt2djAACgkQitSsb3rl5xSwcwCgu83kxHI/vcZ4rmR/ngCXTLbx Zs0AoJLXdIGjdswZ1jhxGwCWSODQgw/+ =qask -----END PGP SIGNATURE----- --------------enigAE022DCD91D8D6103DFEA7A6--