From owner-freebsd-arch Mon Oct 29 11:56:57 2001 Delivered-To: freebsd-arch@freebsd.org Received: from p3.locore.ca (p3.locore.ca [198.96.117.171]) by hub.freebsd.org (Postfix) with ESMTP id 7F0FB37B401; Mon, 29 Oct 2001 11:56:51 -0800 (PST) Received: (from jake@localhost) by p3.locore.ca (8.11.4/8.11.4) id f9TJswT39222; Mon, 29 Oct 2001 14:54:58 -0500 (EST) (envelope-from jake) Date: Mon, 29 Oct 2001 14:54:58 -0500 From: Jake Burkholder To: John Baldwin Cc: arch@FreeBSD.ORG Subject: Re: syscall() ABI questions Message-ID: <20011029145458.C14748@locore.ca> References: <20011029143153.B14748@locore.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from jhb@FreeBSD.ORG on Mon, Oct 29, 2001 at 11:50:58AM -0800 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Apparently, On Mon, Oct 29, 2001 at 11:50:58AM -0800, John Baldwin said words to the effect of; > > On 29-Oct-01 Jake Burkholder wrote: > > Apparently, On Mon, Oct 29, 2001 at 02:16:37AM -0800, > > John Baldwin said words to the effect of; > > > >> I've got some questions about td->td_retval[1] and our syscall ABI. On some > >> archs (ia64, alpha) we preinitialie this value to 0. On other archs (i386, > >> sparc64, ppc) we set it to the value of the register it will be set to so > >> that > >> effectively this register's value is preserved across the syscall. My > >> question > >> is do our syscall ABI's actually assume that for syscalls with only one > >> return > >> value that register isn't written to? NetBSD recently changed their i386 > >> syscall code to preinitialize to 0 rather than %edx. Anyone have the > >> history > >> on this? > >> > >> Speaking of i386, I have another question. For the fork, vfork, and rfork > >> syscalls, we have custom handlers that call the syscall normally and then > >> explicitly zero the return value if %edx is 1 (i.e., the child). However, > >> in > >> vm_fork(), we already explicitly set the value in %eax to 0 for child > >> processes, so is this extra setting of that value in libc really needed? If > >> not, we can safely get rid of rfork.S, vfork.S, and fork.S in libc I think. > > > > The thing to watch for is that the system call wrappers don't follow > > the same conventions for call-safe registers. At least on i386 vfork > > stashes the return address in %ecx and expects it not to be clobbered > > by the kernel. I think all the warppers that do this use %ecx (not %edx) > > and its the same on sparc64, %o0 and %o1 are assumed to be clobbered > > but other otherwise non-call safe registers are assumed to be preserved. > > So it should be ok to always clobber retval[1] by setting it to zero. > > > > I think you're right about fork and rfork being able to use the MIASM > > code. rfork with RFMEM is special but it can';t be safely called from > > C anyway. The vfork wrapper needs to stay on x86 at least because both > > processes return to the same stack; if the retunr address is not saved in > > a register the child may clobber the parent's when it "rets" and pops > > the stack. > > Same kernel stack? The register is set in the trapframe which means it is > saved on the kernel stack. Is that shared in the vfork case? Same user stack. The trapframe is copied to the child's kernel stack. > > -- > > John Baldwin -- http://www.FreeBSD.org/~jhb/ > PGP Key: http://www.baldwin.cx/~john/pgpkey.asc > "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message