From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] KVM: x86: Fix 32-bit build breakage due to typo Date: Sat, 20 Mar 2010 10:14:13 +0100 Message-ID: <4BA491E5.4090500@web.de> References: <1268654397-6650-1-git-send-email-avi@redhat.com> <1268654397-6650-3-git-send-email-avi@redhat.com> <4BA088A5.6000201@web.de> <4BA08D39.5030005@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigCB4B69B9A8BD3DCFFD58E6BB" Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:59399 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899Ab0CTJOT (ORCPT ); Sat, 20 Mar 2010 05:14:19 -0400 In-Reply-To: <4BA08D39.5030005@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigCB4B69B9A8BD3DCFFD58E6BB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Avi Kivity wrote: > On 03/17/2010 09:45 AM, Jan Kiszka wrote: >> Avi Kivity wrote: >> =20 >>> Once upon a time, locked operations were emulated while holding the >>> mmu mutex. >>> Since mmu pages were write protected, it was safe to emulate the >>> writes in >>> a non-atomic manner, since there could be no other writer, either in = the >>> guest or in the kernel. >>> >>> These days emulation takes place without holding the mmu spinlock, so= >>> the >>> write could be preempted by an unshadowing event, which exposes the p= age >>> to writes by the guest. This may cause corruption of guest page tabl= es. >>> >>> Fix by using an atomic cmpxchg for these operations. >>> >>> Signed-off-by: Avi Kivity >>> --- >>> arch/x86/kvm/x86.c | 69 >>> ++++++++++++++++++++++++++++++++++++---------------- >>> 1 files changed, 48 insertions(+), 21 deletions(-) >>> >>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >>> index 9d02cc7..d724a52 100644 >>> --- a/arch/x86/kvm/x86.c >>> +++ b/arch/x86/kvm/x86.c >>> @@ -3299,41 +3299,68 @@ int emulator_write_emulated(unsigned long add= r, >>> } >>> EXPORT_SYMBOL_GPL(emulator_write_emulated); >>> >>> +#define CMPXCHG_TYPE(t, ptr, old, new) \ >>> + (cmpxchg((t *)(ptr), *(t *)(old), *(t *)(new)) =3D=3D *(t *)(old= )) >>> + >>> +#ifdef CONFIG_X86_64 >>> +# define CMPXCHG64(ptr, old, new) CMPXCHG_TYPE(u64, ptr, old, new) >>> +#else >>> +# define CMPXCHG64(ptr, old, new) \ >>> + (cmpxchg64((u64 *)(ptr), *(u64 *)(old), *(u *)(new)) =3D=3D *(u6= 4 >>> *)(old)) >>> =20 >> ^^^^^^ >> This should cause the 32-bit build breakage I see with the current nex= t >> branch. >> =20 >=20 > Also, Marcelo sees autotest breakage, so it's also broken on 64-bit > somehow. >=20 Obviously, the 64-bit case is considered stable now and 32 bit remained untested (not included in autotest?). So here is the build fix: ----------> KVM: x86: Fix 32-bit build breakage due to typo Signed-off-by: Jan Kiszka --- arch/x86/kvm/x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index bb9a24a..097ad3a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3322,7 +3322,7 @@ EXPORT_SYMBOL_GPL(emulator_write_emulated); # define CMPXCHG64(ptr, old, new) CMPXCHG_TYPE(u64, ptr, old, new) #else # define CMPXCHG64(ptr, old, new) \ - (cmpxchg64((u64 *)(ptr), *(u64 *)(old), *(u *)(new)) =3D=3D *(u64 *)(ol= d)) + (cmpxchg64((u64 *)(ptr), *(u64 *)(old), *(u64 *)(new)) =3D=3D *(u64 *)(= old)) #endif =20 static int emulator_cmpxchg_emulated(unsigned long addr, --=20 1.6.0.2 --------------enigCB4B69B9A8BD3DCFFD58E6BB 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 iEYEARECAAYFAkukkegACgkQitSsb3rl5xR5WQCg0XmomIAjKmo6pPzQE1/dpOEy 98EAniIW5UjcRx84tfyIgwDicxF8mqy/ =iWV5 -----END PGP SIGNATURE----- --------------enigCB4B69B9A8BD3DCFFD58E6BB--