From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] kvm-kmod: x86: make sure kvm_get_desc_base() doesn't sign extend Date: Tue, 12 Oct 2010 19:43:23 +0200 Message-ID: <4CB49E3B.7050804@web.de> References: <1286897317-312-1-git-send-email-bernhard.kohl@nsn.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig5F815AA232006E74B152492A" Cc: kvm@vger.kernel.org To: Bernhard Kohl Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:35236 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757306Ab0JLRn1 (ORCPT ); Tue, 12 Oct 2010 13:43:27 -0400 In-Reply-To: <1286897317-312-1-git-send-email-bernhard.kohl@nsn.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5F815AA232006E74B152492A Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 12.10.2010 17:28, Bernhard Kohl wrote: > The current implementation of kvm_get_desc_base() sign extends the > return value because of integer promotion rules when compiled for > x86_64 kernels. For the most part, this doesn't matter, because > the top bit of base2 is usually 0. If, however, that bit is 1, then > the entire value will be 0xffff... which is probably not what the > caller intended. >=20 > We have a legacy OS which runs into errors in certain situations > (task switches) because of this bug, i.e. error on vm_entry followed > by unhandled vm_exit. >=20 > dmesg says: > vmx_handle_exit: unexpected, valid vectoring info (0x80000b0d) > and exit reason is 0x80000021 > or > vmx_handle_exit: unexpected, valid vectoring info (0x80000300) > and exit reason is 0x80000021 >=20 > qemu-kvm says: > kvm: unhandled exit 80000021 > kvm_run returned -22 >=20 > This fix was originally applied as patch 2c75910 in kvm.git: > "x86: Make sure get_user_desc() doesn't sign extend." >=20 > Signed-off-by: Bernhard Kohl > --- > x86/external-module-compat.h | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) >=20 > diff --git a/x86/external-module-compat.h b/x86/external-module-compat.= h > index 15b0280..a2af776 100644 > --- a/x86/external-module-compat.h > +++ b/x86/external-module-compat.h > @@ -435,7 +435,7 @@ struct kvm_desc_ptr { > static inline unsigned long > kvm_get_desc_base(const struct kvm_desc_struct *desc) > { > - return desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24); > + return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2= ) << 24)); > } > =20 > static inline void Merged, thanks! Jan --------------enig5F815AA232006E74B152492A 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.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAky0njsACgkQitSsb3rl5xR4LwCfYPo9bUCV0YlQCuVi0OZj6kiY +A0An1mUuLzEcc/FBsseWwo6bSp8rWx1 =cTwC -----END PGP SIGNATURE----- --------------enig5F815AA232006E74B152492A--