From owner-freebsd-current@FreeBSD.ORG Mon Oct 13 14:14:27 2014 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C3474A9E; Mon, 13 Oct 2014 14:14:27 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2DD48A49; Mon, 13 Oct 2014 14:14:26 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s9DEELl5049029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 Oct 2014 17:14:21 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s9DEELl5049029 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s9DEELWu049028; Mon, 13 Oct 2014 17:14:21 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 13 Oct 2014 17:14:21 +0300 From: Konstantin Belousov To: Julian Elischer Subject: Re: number of args in a syscall Message-ID: <20141013141420.GM2153@kib.kiev.ua> References: <543BB7A7.9080709@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <543BB7A7.9080709@freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: FreeBSD Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2014 14:14:27 -0000 On Mon, Oct 13, 2014 at 07:29:43PM +0800, Julian Elischer wrote: > I'm faced with porting some code that has patched the 8.0 kernel > to accept up to 16 args in a syscall. > It makes my skin crawl a bit but if I can't give a good reason to > suggest that they do things differently in 10 (pass a pointer to a > struct maybe) > then I'll just take the easy path and s/8/16/ in > the appropriate line in amd64/include/proc.h and get on with life. It should work; I assume this is for your local modifications. A fine point in the amd64 (syscall) calling sequence is that first 6 integer arguments are passed in registers, everything else and more overflows to memory. Syscall parameters passing conventions are very similar of the conventions for the regular functions, stubs do very little. The syscall arg fetch code does distinguish the registers/memory args and performs copyin for memory portion, see cpu_fetch_syscall_args(). > > I initially thought it may confuse things like ktrace or truss but I > haven't seen any problems.. > allocating more space on the stack is another thing but you only ever > do one syscall at a time. The difference in the stack usage for 8 vs.16 args would be around 100-200 bytes.