Date: Sun, 30 Jan 2011 15:53:41 +0100 From: Juergen Lock <nox@jelal.kn-bremen.de> To: Kostik Belousov <kostikbel@gmail.com> Cc: freebsd-hackers@freebsd.org, freebsd-emulation@freebsd.org, Juergen Lock <nox@jelal.kn-bremen.de> Subject: Re: Can vm_mmap()/vm_map_remove() be called with giant held? (linuxolator dvb patches) Message-ID: <20110130145341.GA36312@triton8.kn-bremen.de> In-Reply-To: <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> <20110130103320.GO2518@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 30, 2011 at 12:33:20PM +0200, Kostik Belousov wrote: > 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! > > > > > > > > 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. > > > > > The question was more do I need to drop it first before calling them... > No, you do not need to drop Giant. > Ok, thanx! > [snip] > > > > + error = ENOMEM; > > > > + goto out2; > > > > + } > > > > + error = copyin((void *) vps.props, l_vp, l_propsiz); > > > > + if (error) > > > > + goto out2; > > > > + for (i = vps.num, l_p = l_vp, p = vp; i--; ++l_p, ++p) > > > > + linux_to_bsd_dtv_property(l_p, p); > > > > + > > > > + error = copyout_map(td, &uvp, propsiz); > > > > + if (error) > > > > + goto out2; > > > > + copyout(vp, (void *) uvp, propsiz); > > > > + > > > > + if ((error = fget(td, args->fd, &fp)) != 0) { > > > > + (void) copyout_unmap(td, uvp, propsiz); > > > > + goto out2; > > > > + } > > > > + vps.props = (void *) uvp; > > > > + if ((args->cmd & 0xffff) == LINUX_FE_SET_PROPERTY) > > > > + error = fo_ioctl(fp, FE_SET_PROPERTY, &vps, td->td_ucred, td); > > > > + else > > > > + error = fo_ioctl(fp, FE_GET_PROPERTY, &vps, td->td_ucred, td); > > > > + if (error) { > > > > + (void) copyout_unmap(td, uvp, propsiz); > > > > + goto out; > > > > + } > > > > + error = 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 ? > > > > > 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 ? Yes. And it's a Linux api and Linux code too (running in webcamd) so I changing it wouldn't make too much sense. > How is the compatibility for 32/64 bit mode is handled by native > FE_SET_PROPERTY handlers ? > I'm not sure but my impression is this currently isn't handled at all even on Linux. (And neither on FreeBSD.) > I could only say that the hack is atrocious. Might be, you indeed have > no choice there. > > I'm not going to disagree there... (This is actually the second api for this, i.e. FE_[GS]ET_PROPERTY are an api extension introduced to add dvb-s2 support to the Linux dvb api, the original proposal was different but wasn't accepted by the Linux people in charge. The array is an array of `commands' that are executed by the ioctl, and the unused pointer that's in there on top of the uint32_t reserved1[3] and that causes the sizes to differ between 32/64 bits looks like it has been added later too because without it I think each array element would have been exactly 64 bytes...) Cheers, Juergen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110130145341.GA36312>