From owner-freebsd-hackers Tue Jul 29 18:46:21 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id SAA28117 for hackers-outgoing; Tue, 29 Jul 1997 18:46:21 -0700 (PDT) Received: from implode.root.com (implode.root.com [198.145.90.17]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id SAA28107 for ; Tue, 29 Jul 1997 18:46:17 -0700 (PDT) Received: from implode.root.com (localhost [127.0.0.1]) by implode.root.com (8.8.5/8.8.5) with ESMTP id SAA11272; Tue, 29 Jul 1997 18:46:09 -0700 (PDT) Message-Id: <199707300146.SAA11272@implode.root.com> To: Terry Lambert cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Location of copyin() and copyout().. In-reply-to: Your message of "Tue, 29 Jul 1997 17:30:46 PDT." <199707300030.RAA03691@phaeton.artisoft.com> From: David Greenman Reply-To: dg@root.com Date: Tue, 29 Jul 1997 18:46:08 -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >> 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