From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHISY-0005xe-50 for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:51:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHIST-0005tF-OH for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:51:37 -0500 Received: from [199.232.76.173] (port=52577 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHIST-0005t8-Gx for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:51:33 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:39367) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHISS-00035j-SU for qemu-devel@nongnu.org; Sun, 06 Dec 2009 09:51:33 -0500 Message-ID: <4B1BC4EC.90704@web.de> Date: Sun, 06 Dec 2009 15:51:24 +0100 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig14A7819E9AEA9AFA5EA0D31B" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [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) --------------enig14A7819E9AEA9AFA5EA0D31B Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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. 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. Signed-off-by: Jan Kiszka --- target-i386/kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) 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_l= ist); - if (ret < 0) + if (ret < 0 && ret !=3D -E2BIG) { return 0; - + } /* Old kernel modules had a bug and could write beyond the provi= ded memory. Allocate at least a safe amount of 1K. */ kvm_msr_list =3D qemu_mallocz(MAX(1024, sizeof(msr_list) + --------------enig14A7819E9AEA9AFA5EA0D31B 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 iEYEARECAAYFAksbxPAACgkQitSsb3rl5xQadACdGw/EEOLQD8t1VioagxBk5aPE AwMAn0fCfl6keGCEk/Ul7sK751Rrgw3h =NJPS -----END PGP SIGNATURE----- --------------enig14A7819E9AEA9AFA5EA0D31B--