From owner-freebsd-hackers@FreeBSD.ORG Sun Jan 30 10:33:34 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E315C106566B; Sun, 30 Jan 2011 10:33:33 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7CBC08FC0A; Sun, 30 Jan 2011 10:33:33 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p0UAXKMD069428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 30 Jan 2011 12:33:20 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p0UAXKNS056180; Sun, 30 Jan 2011 12:33:20 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p0UAXKl6056179; Sun, 30 Jan 2011 12:33:20 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 30 Jan 2011 12:33:20 +0200 From: Kostik Belousov To: Juergen Lock Message-ID: <20110130103320.GO2518@deviant.kiev.zoral.com.ua> References: <20110129201000.GA10774@triton8.kn-bremen.de> <20110129205105.GI2518@deviant.kiev.zoral.com.ua> <20110129235448.GA15788@triton8.kn-bremen.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5XswgcLA9HHGPOFO" Content-Disposition: inline In-Reply-To: <20110129235448.GA15788@triton8.kn-bremen.de> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, freebsd-emulation@freebsd.org Subject: Re: Can vm_mmap()/vm_map_remove() be called with giant held? (linuxolator dvb patches) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jan 2011 10:33:34 -0000 --5XswgcLA9HHGPOFO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 30, 2011 at 12:54:48AM +0100, Juergen Lock wrote: > On Sat, Jan 29, 2011 at 10:51:05PM +0200, Kostik Belousov wrote: > > On Sat, Jan 29, 2011 at 09:10:00PM +0100, Juergen Lock wrote: > > > Hi! > > >=20 > > > I was kinda hoping to be able to post a correct patch in public but > > > getting an answer to ${Subject} seems to be more difficult than I > > > thought... :) So, does anyone here know? copyout_map() and > > You do not need Giant locked for vm_map* functions. > >=20 > The question was more do I need to drop it first before calling them... No, you do not need to drop Giant. [snip] > > > + error =3D ENOMEM; > > > + goto out2; > > > + } > > > + error =3D copyin((void *) vps.props, l_vp, l_propsiz); > > > + if (error) > > > + goto out2; > > > + for (i =3D vps.num, l_p =3D l_vp, p =3D vp; i--; ++l_p, ++p) > > > + linux_to_bsd_dtv_property(l_p, p); > > > + > > > + error =3D copyout_map(td, &uvp, propsiz); > > > + if (error) > > > + goto out2; > > > + copyout(vp, (void *) uvp, propsiz); > > > + > > > + if ((error =3D fget(td, args->fd, &fp)) !=3D 0) { > > > + (void) copyout_unmap(td, uvp, propsiz); > > > + goto out2; > > > + } > > > + vps.props =3D (void *) uvp; > > > + if ((args->cmd & 0xffff) =3D=3D LINUX_FE_SET_PROPERTY) > > > + error =3D fo_ioctl(fp, FE_SET_PROPERTY, &vps, td->td_ucred, td); > > > + else > > > + error =3D fo_ioctl(fp, FE_GET_PROPERTY, &vps, td->td_ucred, td); > > > + if (error) { > > > + (void) copyout_unmap(td, uvp, propsiz); > > > + goto out; > > > + } > > > + error =3D copyin((void *) uvp, vp, propsiz); > > > + (void) copyout_unmap(td, uvp, propsiz); > > No need in space between cast and expression. Bigger issue is that I > > do not understand this fragment. You do copyout_map(), and then > > immediately call copyout_unmap() for the address range returned > > by copyout_map(), or am I missing something ? > >=20 > The vm allocated by copyout_map() is only needed for the fo_ioctl() > call because the struct passed to FE_[GS]ET_PROPERTY describes an > array that the drivers then copyin() and (possibly) copyout() > themselves. So that array needs to be translated from/to the 32bit > Linux version to (possibly) 64bit on the host (linux_to_bsd_dtv_property), > and the 64bit version is larger so it doesn't fit in the original > place in the userland vm. And am I right that the drivers can only take this array from the usermode ? How is the compatibility for 32/64 bit mode is handled by native FE_SET_PROPERTY handlers ? I could only say that the hack is atrocious. Might be, you indeed have no choice there. >=20 > (One optimization here would be to only do this when the sizes > differ i.e. in the 32bit-on-64 case...) >=20 > Thanx! > Juergen --5XswgcLA9HHGPOFO Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk1FPnAACgkQC3+MBN1Mb4gfFwCg84gjU/HrRn1o1TBh/nVWiNfb BBsAn3UlNnalAXADys/Lfz0/Qmkwtxdv =wnoG -----END PGP SIGNATURE----- --5XswgcLA9HHGPOFO--