Re: Switch from User space to Kernel space.

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

 



Sanjay Kumar, Noida (sanjayku@xxxxxxxxxxxxxxxxx) wrote:
> The inline assembley code is
> making a system call ( int $0x80)
> passing system call number (__NR_##name) and argument( arg1) it requires.
> The value returned from the system call is obtained in __res variable
> a and b denotes eax and ebx registers respectively.
> Basically the inline assembly format is like
> asm ( assembler template
> : output operands
> : input operands);


hi,

As I know, to switch from user to kernel land, parameters are push on
stack and eax contains nr_syscall (number of the system call).
Afterwards, an 0x80 int are generated: (int $0x80).
Now you are in : linux/arch/i386/kernel/entry.S and syscall are choiced
by eax register and kernel sys_ function is called.

If I say some awful mistake, please correct me. I am here to learn :-)
--

A little correction, First the parametrs are stored in i386 registers, syscall number in EAX and int 0x80 is a linux syscall which takes control to entry.s. Then only the general puropse registers are pushed in stack. kernel stack not in user stack.
It is necessary because In in system call with 1 parameter, 1 GPR is used, but others need to be preserved. So all gprs are saved.


Now after int instruction, i386/kernel/entry.s  ENTRY(system_call)
executes because it is registered in Interrupt Descriptor Table.
set_system_gate(SYSCALL_VECTOR,&system_call); in traps.h

regards manish

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus



-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/


[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