linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* System Call parameters
@ 2003-04-16 16:58 Richard B. Johnson
  2003-04-16 17:41 ` Bruce Harada
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard B. Johnson @ 2003-04-16 16:58 UTC (permalink / raw)
  To: Linux kernel


How does the kernel get more than five parameters?

Currently...
	eax	= function code
	ebx	= first parameter
	ecx	= second parameter
	edx	= third parameter
	esi	= fourth parameter
	edi	= fifth parameter

Some functions like mmap() take 6 parameters!
Does anybody know how these parameters get passed?
I have an "ultra-light" 'C' runtime library I have
been working on and, so-far, I've got everything up
to mmap()  (in syscall.h) (89 functions) working.
I thought, maybe ebp was being used, but it doesn't
seem to be the case.

Maybe after 5 functions, there is a parameter list
passed by pointer???? I don't have a clue and I
can figure out the code, it's really obscure...


Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System Call parameters
  2003-04-16 16:58 System Call parameters Richard B. Johnson
@ 2003-04-16 17:41 ` Bruce Harada
  2003-04-16 17:58   ` Richard B. Johnson
  2003-04-16 17:47 ` Bruce Harada
  2003-04-16 20:35 ` H. Peter Anvin
  2 siblings, 1 reply; 6+ messages in thread
From: Bruce Harada @ 2003-04-16 17:41 UTC (permalink / raw)
  To: root; +Cc: linux-kernel

On Wed, 16 Apr 2003 12:58:15 -0400 (EDT)
"Richard B. Johnson" <root@chaos.analogic.com> wrote:

> 
> How does the kernel get more than five parameters?
> 
> Currently...
> 	eax	= function code
> 	ebx	= first parameter
> 	ecx	= second parameter
> 	edx	= third parameter
> 	esi	= fourth parameter
> 	edi	= fifth parameter
> 
> Some functions like mmap() take 6 parameters!
> Does anybody know how these parameters get passed?
> I have an "ultra-light" 'C' runtime library I have
> been working on and, so-far, I've got everything up
> to mmap()  (in syscall.h) (89 functions) working.
> I thought, maybe ebp was being used, but it doesn't
> seem to be the case.
> 
> Maybe after 5 functions, there is a parameter list
> passed by pointer???? I don't have a clue and I
> can figure out the code, it's really obscure...

>From http://www.google.co.jp/search?q=cache:7GJP4whNQEkC:webster.cs.ucr.edu/Page_Linux/LinuxSysCalls.pdf+Linux+mmap+parameters+ebp&hl=ja&ie=UTF-8 :

 Certain Linux 2.4 calls pass a sixth parameter in EBP. Calls compatible with earlier versions of the kernel pass six or
 more parameters in a parameter block and pass the address of the parameter block in EBX (this change was probably
 made in kernel 2.4 because someone noticed that an extra copy between kernel and user space was slowing down
 those functions with exactly six parameters; who knows the real reason, though).

Relevant? No idea.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System Call parameters
  2003-04-16 16:58 System Call parameters Richard B. Johnson
  2003-04-16 17:41 ` Bruce Harada
@ 2003-04-16 17:47 ` Bruce Harada
  2003-04-16 20:35 ` H. Peter Anvin
  2 siblings, 0 replies; 6+ messages in thread
From: Bruce Harada @ 2003-04-16 17:47 UTC (permalink / raw)
  To: root; +Cc: linux-kernel

On Wed, 16 Apr 2003 12:58:15 -0400 (EDT)
"Richard B. Johnson" <root@chaos.analogic.com> wrote:

> 
> How does the kernel get more than five parameters?

Also, this thread might be helpful:

http://www.ussg.iu.edu/hypermail/linux/kernel/0212.2/0409.html


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System Call parameters
  2003-04-16 17:41 ` Bruce Harada
@ 2003-04-16 17:58   ` Richard B. Johnson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard B. Johnson @ 2003-04-16 17:58 UTC (permalink / raw)
  To: Bruce Harada; +Cc: linux-kernel

On Thu, 17 Apr 2003, Bruce Harada wrote:

> On Wed, 16 Apr 2003 12:58:15 -0400 (EDT)
> "Richard B. Johnson" <root@chaos.analogic.com> wrote:
>
> >
> > How does the kernel get more than five parameters?
> >
> > Currently...
> > 	eax	= function code
> > 	ebx	= first parameter
> > 	ecx	= second parameter
> > 	edx	= third parameter
> > 	esi	= fourth parameter
> > 	edi	= fifth parameter
> >
> > Some functions like mmap() take 6 parameters!
> > Does anybody know how these parameters get passed?
> > I have an "ultra-light" 'C' runtime library I have
> > been working on and, so-far, I've got everything up
> > to mmap()  (in syscall.h) (89 functions) working.
> > I thought, maybe ebp was being used, but it doesn't
> > seem to be the case.
> >
> > Maybe after 5 functions, there is a parameter list
> > passed by pointer???? I don't have a clue and I
> > can figure out the code, it's really obscure...
>
> >From http://www.google.co.jp/search?q=cache:7GJP4whNQEkC:webster.cs.ucr.edu/Page_Linux/LinuxSysCalls.pdf+Linux+mmap+parameters+ebp&hl=ja&ie=UTF-8 :
>
>  Certain Linux 2.4 calls pass a sixth parameter in EBP. Calls compatible with earlier versions of the kernel pass six or
>  more parameters in a parameter block and pass the address of the parameter block in EBX (this change was probably
>  made in kernel 2.4 because someone noticed that an extra copy between kernel and user space was slowing down
>  those functions with exactly six parameters; who knows the real reason, though).
>
> Relevant? No idea.
>

Yes. Absolutely relevant. FYI, I experimentaly I found out that
the 6th parameter is passed in EBP if I use __NR_mmap2 as the
function call instead of __NR_mmap. Thanks -- and I now have that
working...


Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System Call parameters
  2003-04-16 16:58 System Call parameters Richard B. Johnson
  2003-04-16 17:41 ` Bruce Harada
  2003-04-16 17:47 ` Bruce Harada
@ 2003-04-16 20:35 ` H. Peter Anvin
  2 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2003-04-16 20:35 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <Pine.LNX.4.53.0304161256130.11667@chaos>
By author:    "Richard B. Johnson" <root@chaos.analogic.com>
In newsgroup: linux.dev.kernel
>
> How does the kernel get more than five parameters?
> 
> Currently...
> 	eax	= function code
> 	ebx	= first parameter
> 	ecx	= second parameter
> 	edx	= third parameter
> 	esi	= fourth parameter
> 	edi	= fifth parameter
> 
> Some functions like mmap() take 6 parameters!
> Does anybody know how these parameters get passed?
> I have an "ultra-light" 'C' runtime library I have
> been working on and, so-far, I've got everything up
> to mmap()  (in syscall.h) (89 functions) working.
> I thought, maybe ebp was being used, but it doesn't
> seem to be the case.
> 

%ebp is used.

However, on i386, SYS_mmap is a four-parameter system call where the
last parameter is a pointer to a parameter block.  SYS_mmap2 is the
full six-parameter sane version.

You may want to check out klibc.

	-hpa

-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: System Call parameters
@ 2003-04-17  0:39 Perez-Gonzalez, Inaky
  0 siblings, 0 replies; 6+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-04-17  0:39 UTC (permalink / raw)
  To: 'root@chaos.analogic.com',
	'lkml (linux-kernel@vger.kernel.org)'


> From: Richard B. Johnson [mailto:root@chaos.analogic.com]
>
> Some functions like mmap() take 6 parameters!
> Does anybody know how these parameters get passed?
> I have an "ultra-light" 'C' runtime library I have
> been working on and, so-far, I've got everything up
> to mmap()  (in syscall.h) (89 functions) working.
> I thought, maybe ebp was being used, but it doesn't
> seem to be the case.

I use %ebp, it seemed to work last time I played with it:

static inline
int st_mmap (void *addr, size_t len, int protection, int flags, int fd,
off_t offset)
{
  int result;
  asm volatile (
    "pushl %%ebp	\n"
    "movl  %6, %%ebp	\n"
    "movl  %7, %%eax	\n"
    "int   $0x80	\n"
    "popl  %%ebp	\n"
    : "=a" (result)
    : "b" (addr), "c" (len), "d" (protection),
      "S" (flags), "D" (fd), "m" ((offset >> PAGE_SHIFT)),
      "i" (__NR_mmap2)
    : "memory");
  return result;
}

I thing I got it from an straight disassemble dump of glibc's
mmap().

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-04-17  0:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-16 16:58 System Call parameters Richard B. Johnson
2003-04-16 17:41 ` Bruce Harada
2003-04-16 17:58   ` Richard B. Johnson
2003-04-16 17:47 ` Bruce Harada
2003-04-16 20:35 ` H. Peter Anvin
2003-04-17  0:39 Perez-Gonzalez, Inaky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).