From owner-freebsd-hackers Wed Apr 24 17:15:57 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wemm.org (12-232-135-171.client.attbi.com [12.232.135.171]) by hub.freebsd.org (Postfix) with ESMTP id 91BF537B404; Wed, 24 Apr 2002 17:15:47 -0700 (PDT) Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by fw.wemm.org (8.11.6/8.11.6) with ESMTP id g3ONpMe36529; Wed, 24 Apr 2002 16:51:22 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (Postfix) with ESMTP id 263FB38FD; Wed, 24 Apr 2002 16:51:22 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Kenneth Culver Cc: Andrew Gallatin , Brandon S Allbery KF8NH , freebsd-hackers@FreeBSD.ORG, FreeBSD-CURRENT List Subject: Re: implementing linux mmap2 syscall In-Reply-To: <20020424161828.R38664-100000@alpha.yumyumyum.org> Date: Wed, 24 Apr 2002 16:51:22 -0700 From: Peter Wemm Message-Id: <20020424235122.263FB38FD@overcee.wemm.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Kenneth Culver wrote: > > > > Brandon S Allbery KF8NH writes: > > > On Wed, 2002-04-24 at 10:41, Andrew Gallatin wrote: > > > > Maybe the argument isn't where you expect it to be, but is there. > > > > Can you make a test program which calls mmap2 with its 6th arg as > > > > something unique like 0xdeadbeef? Then print out (in hex :) the trapf rame > > > > from the linux prepsyscall routine & see if you can find the deadbeef. > > > > > > My recollection is that beyond 5 arguments, a pointer to the remaining > > > ones is passed. (But my recollection may be wrong and I don't wish to > > > subject myself to the source cesspool at the moment....) > > > > > > > I think that's how it used to work. Apparently, they've changed it > > recently and they now pass 6 args in registers. Eg, in the linux > > kernel sources, old_mmap() fetches its args via copy_from_user(), > > whereas the newer sys_mmap2() doesn't. > > > > Drew > > > Yep, according to the docs and source code I looked at in the linux > kernel, the sixth arg is in the ebp register. I've looked all over the > FreeBSD kernel and the linux emulator for the place that actually sets > these, and unfortunately, due to my lack of asm coding knowledge, I can't > find anything. Here's where it happens: sys/i386/linux/linux_sysvec.c static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params) { args[0] = tf->tf_ebx; args[1] = tf->tf_ecx; args[2] = tf->tf_edx; args[3] = tf->tf_esi; args[4] = tf->tf_edi; *params = NULL; /* no copyin */ } You probably want to add: args[5] = tf->tf_ebp; so that it ends up in the syscallargs struct. For FreeBSD syscalls, we copy this from the top of stack for the number of 32 bit words specified in the syscall table in i386/trap.c: if (params && (i = narg * sizeof(int)) && (error = copyin(params, (caddr_t)args, (u_int)i))) { (narg comes from the syscall table). Cheers, -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message