From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 1 01:00:27 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7EE6437B401 for ; Fri, 1 Aug 2003 01:00:27 -0700 (PDT) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id ECF2743F75 for ; Fri, 1 Aug 2003 01:00:26 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-38lc0ga.dialup.mindspring.com ([209.86.2.10] helo=mindspring.com) by stork.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19iUpo-000603-00; Fri, 01 Aug 2003 01:00:20 -0700 Message-ID: <3F2A1DDA.F8459FCA@mindspring.com> Date: Fri, 01 Aug 2003 00:59:22 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Ryan Sommers References: <20030731201227.28952.qmail@neuroflux.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a43adc792493174f7568cca58ba79b260f667c3043c0873f7e350badd9bab72f9c350badd9bab72f9c cc: freebsd-hackers@freebsd.org Subject: Re: Assembly Syscall Question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2003 08:00:27 -0000 Ryan Sommers wrote: > When making a system call to the kernel why is it necessary to push the > syscall value onto the stack when you don't call another function? The stack is visible in both user space and kernel space; in general, the register space won't be, unless you are on an architecture with an abundance of registers that doesn't do a save/restore on trap entries. By pushing it onto the stack, you are *positive* that the vale is visible. There is also the (small) possibility that the C compiler will take advanatage of the calling conventions to assume that a value will not change over a system call. Short of declaring that all registers are volatile, you can't really guarantee that the registers pushed in will have the values after the call that they had before the call, unless you save and restore all of them (which is more expensive than the copyin, for system calls with 3 arguments or less -- which is most of them; cost, of course, will vary by architecture). Personally, I like to look at the Linux register-based passing mechanism in the same light that they look at the FreeBSD use of the MMU hardware to assist VM, at the cost of increased FreeBSD VM system complexity (i.e. they think our VM is too convoluted, and we think their system calls are too convoluted). -- Terry