2000-11-01 12:15:36

by mdaljeet

[permalink] [raw]
Subject: system call handling

Hi,

By looking into the structure of GDT as used by linux kernel(file
include/asm/desc.c, kernel ver 2.4), it appears as if linux kernel does not
use the "call gate descriptors" for system call handling. Is this correct?

If it is correct then how does the system calls are handled by the kernel
(basically how does the control gets transferred to kernel)? Does the CS of
linux kernel handles the system calls? what are the advantages of using
this scheme?

otherwise can anyone give pointers in the kernel source where i can look
into?

Thanks,
daljeet.



2000-11-01 12:22:37

by Petko Manolov

[permalink] [raw]
Subject: Re: system call handling

[email protected] wrote:
>
> Hi,
>
> By looking into the structure of GDT as used by linux kernel(file
> include/asm/desc.c, kernel ver 2.4), it appears as if linux kernel does not
> use the "call gate descriptors" for system call handling. Is this correct?

You're looking at wrong place. Look at linux/arch/i386/kernel/traps.c

> If it is correct then how does the system calls are handled by the kernel
> (basically how does the control gets transferred to kernel)? Does the CS of
> linux kernel handles the system calls? what are the advantages of using
> this scheme?

System calls in Linux are performed as an interrupt gate (0x80). It is
not
necessary to use call gate. On i386 arch both are almost identical.


Petkan

2000-11-01 12:44:40

by Richard B. Johnson

[permalink] [raw]
Subject: Re: system call handling

On Wed, 1 Nov 2000 [email protected] wrote:

> Hi,
>
> By looking into the structure of GDT as used by linux kernel(file
> include/asm/desc.c, kernel ver 2.4), it appears as if linux kernel does not
> use the "call gate descriptors" for system call handling. Is this correct?
>

You could use a call-gate to get from one priv level to another but
Linux uses a software trap (int 0x80). It provides good locality
of the kernel entry code which helps keep caches warm. If you used
call-gates, their entry points would be scattered all over kernel
space. Further, you'd have a lot of them (as many as there are
kernel functions).

If you designed it with just one call-gate, with one entry point,
you would have exactly what we have now except you would execute
a `call CALL_GATE` instead of `int 0x80`. This turns out to be
6 of one and 1/2 dozen of another when it comes to performance.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.17 on an i686 machine (801.18 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.


2000-11-01 23:54:14

by Jamie Lokier

[permalink] [raw]
Subject: Re: system call handling

Richard B. Johnson wrote:
> If you designed it with just one call-gate, with one entry point,
> you would have exactly what we have now except you would execute
> a `call CALL_GATE` instead of `int 0x80`. This turns out to be
> 6 of one and 1/2 dozen of another when it comes to performance.

The final decider is that `int 0x80' is only two bytes long.

-- Jamie