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.
[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 ? 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. > > (One optimization here would be to only do this when the sizes > differ i.e. in the 32bit-on-64 case...) > > Thanx! > Juergen
pgpMEErYWv5o5.pgp
Description: PGP signature