On Tue, Mar 30, 2004 at 18:50:37 -0500, Bijoy wrote: > Hi all, > > Im trying to get some basics correct ... > > Each process created in userspace has its own kernel stack right?? > And this stack is used by syscalls and interrupt handlers. My question is that > in ENTRY(system_call) in entry.S .. the code does SAVE_ ALL ... all the > registers are gonna get saved on the kernel stack of the process ... but when > is esp changed to point to this kernel stack?? IIRC it's somehow done by the interrupt/software invocation mechanism tied to the privilege level change. > In Alessandro Rubini's document on making syscalls from kernel space, he says > that the addr_limit field must be changed so that a kernel space buffer wud > work with a syscall that is issued from kernel space .... How about modules > .... do they have a task_struct?? .... Suppose in my init_module I make a > syscall .. whose task_struct is the syscall gonna lookup?? The init_module runs inside init_module syscall done by insmod -- thus it has that insmod's task_struct. > What about kernel threads .. they have a task_struct .. is their addr_limit > set to KERNEL_DS?? ... in that case if i make a syscall from a kernel thread > I wont have to manipulate the addr_limit, right?? The daemonize() routine (used to initialise kernel threads) does not seem to touch addr_limit. You'll have to do it yourself (but you can do it just once). Usualy, you don't want to call syscalls from kernel as syscalls. Each syscall consists of a wrapper doing the copy-to/from-user and a workhorse routine. In kernel, you can call the inner routine directly. Only few syscalls (read, write, readdir and maybe ioctl are the only that come to my mind) do the copy_to/from_user in the inner routine and thus require fiddling with addr_limit. In addition you probably want to work directly with the structures (like file, socket etc.) and not filehandles. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz>
Attachment:
signature.asc
Description: Digital signature