Skip to contentSkip to conversation

sys_clone() related info/help/pointer needed

Linux-ia64 Raj Patil 2 participants 4 messages May 22, 2003 – May 30, 2003

lore
Share & tools
lore

Raj Patil

author
#0 lore raw

Hello,

I am trying to port (time permitting) a small ia32 package to ia64. One of the thing it does are not supposed to be done that way. Like it adds a new syscall entry to the syscall table. But, I am doing this just to see how this tiny stuff from ia32 works on ia64 without getting into dynamically adding the new sys call discussion.

The progam basically adds an entry to syscall table, and when this
new syscall is called, it simply calls sys_clone() with same arguments.
(like making a duplicate sys_clone call)
static long my_call(unsigned long flags, unsigned long sz)
{
rc=sys_clone(flags, sz); /* sys_clone is exported */
......
}
Everything seems to work excpet that the child process created is not
getting executed. I can see that the return value from the sys_clone is
the pid of the child process and the task struct for the child getting set
etc. But, the child process created does not get executed. I don't see
any error messages in dmesg output either. So, I am not sure what
is going wrong and what exactly to look. (Yes, I am relatively new to
Linux.) Any suggestions or pointers to try will be greatly appreciated. (Hooking up the gdb over serial port would be a stretch as the machine
is shared by other folks and I am trying this on the side. )
The sys_clone() is an assembly code which calls do_fork after setting
the regs and performing do_save_switch_stack etc.I don't see any
thing obvious there or in do_fork code.

Thanks for any suggestions/pointers/info to try.

Regards,
Raj

---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Raj Patil

Raj> The progam basically adds an entry to syscall table, and when Raj> this new syscall is called, it simply calls sys_clone() with Raj> same arguments. (like making a duplicate sys_clone call) Raj> static long my_call(unsigned long flags, unsigned long sz) { Raj> rc=sys_clone(flags, sz); /* sys_clone is exported */ ...... } Raj> Everything seems to work excpet that the child process created Raj> is not getting executed.

clone() (or, more correctly: clone2()) is special: it needs both a pt_regs and a switch_stack structure at the top of the stack (see comments in arch/ia64/kernel/process.c for copy_thread()). Your test-case doesn't work because it probably isn't creating the switch_stack structure at all.

	--david
author
#2 lore raw
In reply to Raj Patil

Thanks for your comments/info David.
(was out for few days...)

One thing I am not clear is why should it be different when sys_clone() is called as part of the regulare syscall and from a module as another syscall. Both of them are going through the same path; sys_clone(), do_fork(), copy_thread(). Am I missing something vey obvious to see the difference?

BTW: I bought "ia-64 linux kernel design and implementation" book.
It is very well wriiten.
I am going through the 3rd chapter on threads for clone2()/
switch_stack/copy_thread etc. It will take some time to digest
the info....

Thanks,
Raj

Quoted 1 line · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Raj Patil

Raj> The progam basically adds an entry to syscall table, and when Raj> this new syscall is called, it simply calls sys_clone() with Raj> same arguments. (like making a duplicate sys_clone call) Raj> static long my_call(unsigned long flags, unsigned long sz) { Raj> rc=sys_clone(flags, sz); /* sys_clone is exported */ ...... } Raj> Everything seems to work excpet that the child process created Raj> is not getting executed.

clone() (or, more correctly: clone2()) is special: it needs both a pt_regs and a switch_stack structure at the top of the stack (see comments in arch/ia64/kernel/process.c for copy_thread()). Your test-case doesn't work because it probably isn't creating the switch_stack structure at all.

--david

---------------------------------
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).

#3 lore raw
In reply to Raj Patil
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Raj Patil

Raj> Thanks for your comments/info David. (was out for few days...)

Raj> One thing I am not clear is why should it be different when Raj> sys_clone() is called as part of the regulare syscall and from Raj> a module as another syscall. Both of them are going through the Raj> same path; sys_clone(), do_fork(), copy_thread(). Am I missing Raj> something vey obvious to see the difference?

Modules are a different story: you can't call modules via the syscall table (because the global pointer will be wrong). This is actually a feature since it's almost always either wrong or illegal to install syscalls from a module. In fact, in newer kernels, the syscall table isn't exported to modules anymore. That's a good thing.

Raj> BTW: I bought "ia-64 linux kernel design and implementation" Raj> book. It is very well wriiten.

Thanks!

	--david