Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Jul 1997 18:46:08 -0700
From:      David Greenman <dg@root.com>
To:        Terry Lambert <terry@lambert.org>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Location of copyin() and copyout().. 
Message-ID:  <199707300146.SAA11272@implode.root.com>
In-Reply-To: Your message of "Tue, 29 Jul 1997 17:30:46 PDT." <199707300030.RAA03691@phaeton.artisoft.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
>> It is generally considered _extremely_ bad to use copyin/copyout, as it
>> precludes your functions from being called from within kernel space.
>> 
>> FWIW, this is what eventually stumped me when it came to getting Linux
>> WABI running on FreeBSD.
>
>This is a good point, considering that kernel preemption is one
>of my own goals.
>
>The issue is recursion with a paging operation in progress.
>
>I think with the limited cases I gave (the page is filled, the
>call made, and the page is still mapped) are OK.
>
>copying out is more likely to cause problems than copying in,
>since you copy in pages after they are touched, but you potentially
>touch on copyout.
>
>Probably there needs to be _copyin/_copyout for the internal usage,
>and a "safe" copyin/copyout for usage which isn't safed against
>reentrancy.

   There is no problem with using copyout() in the kernel to copy data out to
a user process, assuming that the currently running process is the intended
target of the copy. That is the sole purpose of the function. copyout()
correctly handles all issues of COW/ZF/page faults.
   uiomove() is escentially a wrapper for copyin/copyout that has an
optimization for the case of kernel-to-kernel copies (in which case it
uses bcopy instead).

-DG

David Greenman
Core-team/Principal Architect, The FreeBSD Project



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707300146.SAA11272>