Re: lcall7/lcall27 call gates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is how the system calls with lcall7/lcall27 work:

1. Kernel sets up call gates for the functions lcall7 and lcall27
with dpl 3 and parm count 0.(arch/i386/kernel/traps.c) in the default_ldt.
0x7 and 0x27 are the selectors used by the applications using lcall7 and lcall27
respectively. Apparently, these selectors access the 0th and 4th entries of
the ldt, which have been set up as call gate descriptors.

2. Since the values stored on stack after the call to call gate is different
from that of the int 0x80, kernel modifies some values on stack to confirm to
struct pt_regs format. After this appropriate handler is called from 
current->exec_domain->handler(selector, regs).

3. After the handler executes, kernel follows the normal path of 
ret_from_sys_call. Note that eventhough kernel was entered through a call,
return will be through iret. To facilitate this, eflags will be explicitly
pushed in step 2 (eflags not stored automatically by the processor).

4. lcall7/lcall27 are provided to support iBCS emulation support(application
binary interface).  iBCS would have registered an iBCS exec domain, through
which it becomes possible to call the handler for appropriate domain in step2.
(See kernel/exec_domain.c, include/linux/personality.h)

5. Call to the call gate happens through a far call, where the offset and
selector (0x7 for lcall7 and 0x27 for lcall27) are provided to the call 
instruction. This is very similar to the syscall macros of int 0x80 type
expect that int 0x80 is replaced by far call.

6. wrt behaviour, there is no difference b/n the syscall of int 0x80 type
and lcall types except that there is an extra level of protection check
that happens when call gate is accessed.

7. To know further about how the iBCS handler works, refer to iBCS source
ftp://tsx-11.mit.edu/pub/Linux/BETA/ibcs2.

8. There may be some inaccuracies in the above description, as I studied 
all about this after seeing your note. Please excuse and correct.

Regards,
Bharata.

On Wed, Oct 10, 2001 at 10:34:56AM +0530, C.Mohanasundaram wrote:
> Hi all,
> 
> I took the below quoted lines from Linux Kernel Internals book
> 
> "There are two mechanisms under Linux for implementing system calls: 
> 
>      lcall7/lcall27 call gates; 
>      int 0x80 software interrupt. "
> 
> I understood the second one i.e
> how system calls r implemented under i386 architecture using int 0x80 
> software interrupt.
> 
> But i dont have any idea about lcall7/lcall27 call gates.
> 
> Can any one please tell me how it works.
> 
> thanks and regards,
> mohan.
> -
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> IRC Channel:   irc.openprojects.net / #kernelnewbies
> Web Page:      http://www.kernelnewbies.org/

-- 
Bharata B Rao,
IBM Linux Technology Center,
IBM Software Lab, Bangalore.

Ph: 91-80-5262355 Ex: 3962
Mail: bharata@in.ibm.com
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux