From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTcmK-0000oM-8w for qemu-devel@nongnu.org; Tue, 20 Mar 2007 07:45:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTcmI-0000nM-H2 for qemu-devel@nongnu.org; Tue, 20 Mar 2007 07:45:23 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTcmI-0000nJ-Ed for qemu-devel@nongnu.org; Tue, 20 Mar 2007 06:45:22 -0500 Received: from partizan.velesys.com ([213.184.230.195]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HTcki-0003TN-Q0 for qemu-devel@nongnu.org; Tue, 20 Mar 2007 07:43:45 -0400 Date: Tue, 20 Mar 2007 13:43:15 +0200 From: "Kirill A. Shutemov" Subject: Re: [Qemu-devel] [PATCH] fcntl64 fix Message-ID: <20070320114315.GA26019@localhost.localdomain> References: <20070309215335.GB5629@localhost.localdomain> <20070319171303.GE28895@networkno.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lMM8JwqTlfDpEaS6" Content-Disposition: inline In-Reply-To: <20070319171303.GE28895@networkno.de> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thiemo Seufer Cc: qemu-devel@nongnu.org --lMM8JwqTlfDpEaS6 Content-Type: multipart/mixed; boundary="NMuMz9nt05w80d4+" Content-Disposition: inline --NMuMz9nt05w80d4+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Yep. You're right. Fixed patch in the attachment. On [Mon, 19.03.2007 17:12], Thiemo Seufer wrote: > Kirill A. Shutemov wrote: > > TARGET_F_*64 should be used instead of F_*64, because on 64-bit host > > systems F_GETLK =3D=3D F_GETLK64(same for SETLK and SETLKW), so we cann= ot > > determinate if it's a long lock or not on a target 32-bit system. > > Patch in the attachment. > >=20 > > P.S. Please, review my privious patches, which I have added description > > recently. Or should I repost it? > >=20 >=20 > > diff -uNr qemu-0.9.0.cvs20070304.orig/linux-user/syscall.c qemu-0.9.0.c= vs20070304/linux-user/syscall.c > > --- qemu-0.9.0.cvs20070304.orig/linux-user/syscall.c 2007-03-09 20:08:5= 9 +0200 > > +++ qemu-0.9.0.cvs20070304/linux-user/syscall.c 2007-03-09 20:09:54 +02= 00 > > @@ -4063,7 +4063,7 @@ > > #endif > > =20 > > switch(arg2) { > > - case F_GETLK64: > > + case TARGET_F_GETLK64: > > ret =3D get_errno(fcntl(arg1, arg2, &fl)); >=20 > This changes the bug from checking the wrong flag to (potentially) > passing down the wrong flag... >=20 > > if (ret =3D=3D 0) { > > #ifdef TARGET_ARM > > @@ -4089,8 +4089,8 @@ > > } > > break; > > =20 > > - case F_SETLK64: > > - case F_SETLKW64: > > + case TARGET_F_SETLK64: > > + case TARGET_F_SETLKW64: > > #ifdef TARGET_ARM > > if (((CPUARMState *)cpu_env)->eabi) { > > lock_user_struct(target_efl, arg3, 1); >=20 > Likewise here. We should always check TARGET_* flags and pass down the > corresponding host flag. --NMuMz9nt05w80d4+ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="qemu-0.9.0-alt-fcntl64-fix.patch" Content-Transfer-Encoding: quoted-printable diff -uNr qemu-0.9.0.cvs20070320.orig/linux-user/syscall.c qemu-0.9.0.cvs20= 070320/linux-user/syscall.c --- qemu-0.9.0.cvs20070320.orig/linux-user/syscall.c 2007-03-20 13:26:04 +0= 200 +++ qemu-0.9.0.cvs20070320/linux-user/syscall.c 2007-03-20 13:34:09 +0200 @@ -4058,15 +4058,27 @@ #if TARGET_LONG_BITS =3D=3D 32 case TARGET_NR_fcntl64: { + int cmd; struct flock64 fl; struct target_flock64 *target_fl; #ifdef TARGET_ARM struct target_eabi_flock64 *target_efl; #endif =20 + switch(arg2){ + case TARGET_F_GETLK64: + cmd =3D F_GETLK64; + case TARGET_F_SETLK64: + cmd =3D F_SETLK64; + case TARGET_F_SETLKW64: + cmd =3D F_SETLK64; + default: + cmd =3D arg2; + } + switch(arg2) { - case F_GETLK64: - ret =3D get_errno(fcntl(arg1, arg2, &fl)); + case TARGET_F_GETLK64: + ret =3D get_errno(fcntl(arg1, cmd, &fl)); if (ret =3D=3D 0) { #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { @@ -4091,8 +4103,8 @@ } break; =20 - case F_SETLK64: - case F_SETLKW64: + case TARGET_F_SETLK64: + case TARGET_F_SETLKW64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { lock_user_struct(target_efl, arg3, 1); @@ -4113,10 +4125,10 @@ fl.l_pid =3D tswapl(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } - ret =3D get_errno(fcntl(arg1, arg2, &fl)); + ret =3D get_errno(fcntl(arg1, cmd, &fl)); break; default: - ret =3D get_errno(do_fcntl(arg1, arg2, arg3)); + ret =3D get_errno(do_fcntl(arg1, cmd, arg3)); break; } break; --NMuMz9nt05w80d4+-- --lMM8JwqTlfDpEaS6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFF/8jqbWYnhzC5v6oRAolEAJ9li5+oIFM62irEGx51cdifOVkXEwCbBowu oCI/FuIdTTkQkBLLSxiXl5I= =nU7Z -----END PGP SIGNATURE----- --lMM8JwqTlfDpEaS6--