From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHIVk-0007Ey-7C for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:54:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHIVf-0007Dy-Ek for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:54:55 -0500 Received: from [199.232.76.173] (port=43731 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHIVf-0007Dv-98 for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:54:51 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:42247) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHIVe-0003R4-Jn for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:54:51 -0500 Message-ID: <4B1BC5B9.2020607@web.de> Date: Sun, 06 Dec 2009 15:54:49 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <4B1BC4EC.90704@web.de> In-Reply-To: <4B1BC4EC.90704@web.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6CCA104CFBEA96F078AE8E25" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] kvm: x86: Fix initial kvm_has_msr_star List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Marcelo Tosatti , qemu-devel , Avi Kivity This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6CCA104CFBEA96F078AE8E25 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Sorry, this is of course a critical fix for all branches that have KVM support. Jan Jan Kiszka wrote: > KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too > small for all MSRs. But this is precisely the error we trigger with the= > initial request in order to obtain that size. Do not fail in that case.= >=20 > This caused a subtle corruption of the guest state as MSR_STAR was not > properly saved/restored. The corruption became visible with latest kvm > optimizing the MSR updates. >=20 > Signed-off-by: Jan Kiszka > --- >=20 > target-i386/kvm.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index 3b61a7f..88b504c 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -244,9 +244,9 @@ static int kvm_has_msr_star(CPUState *env) > * save/restore */ > msr_list.nmsrs =3D 0; > ret =3D kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr= _list); > - if (ret < 0) > + if (ret < 0 && ret !=3D -E2BIG) { > return 0; > - > + } > /* Old kernel modules had a bug and could write beyond the pro= vided > memory. Allocate at least a safe amount of 1K. */ > kvm_msr_list =3D qemu_mallocz(MAX(1024, sizeof(msr_list) + >=20 --------------enig6CCA104CFBEA96F078AE8E25 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 iEYEARECAAYFAksbxbkACgkQitSsb3rl5xS+nACdEJJAk3INEMqvy+sTlDReuZjo 7KAAoJ9jReqEAgko1nRHnlm1gKOaAF0Y =OrOr -----END PGP SIGNATURE----- --------------enig6CCA104CFBEA96F078AE8E25--