From owner-freebsd-arch Mon Oct 29 11:51:28 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mail12.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by hub.freebsd.org (Postfix) with ESMTP id 74C6E37B40A for ; Mon, 29 Oct 2001 11:51:21 -0800 (PST) Received: (qmail 36642 invoked from network); 29 Oct 2001 19:51:19 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail12.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 29 Oct 2001 19:51:19 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20011029143153.B14748@locore.ca> Date: Mon, 29 Oct 2001 11:50:58 -0800 (PST) From: John Baldwin To: Jake Burkholder Subject: Re: syscall() ABI questions Cc: arch@FreeBSD.ORG 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 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? -- 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