Date: Sun, 30 Jan 2011 12:33:20 +0200 From: Kostik Belousov <kostikbel@gmail.com> To: Juergen Lock <nox@jelal.kn-bremen.de> 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) Message-ID: <20110130103320.GO2518@deviant.kiev.zoral.com.ua> In-Reply-To: <20110129235448.GA15788@triton8.kn-bremen.de> References: <20110129201000.GA10774@triton8.kn-bremen.de> <20110129205105.GI2518@deviant.kiev.zoral.com.ua> <20110129235448.GA15788@triton8.kn-bremen.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110130103320.GO2518>