public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] sys_clone() related info/help/pointer needed
@ 2003-05-22 20:36 Raj Patil
  2003-05-27 16:57 ` David Mosberger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Raj Patil @ 2003-05-22 20:36 UTC (permalink / raw)
  To: linux-ia64

[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 2177 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-ia64] sys_clone() related info/help/pointer needed
  2003-05-22 20:36 [Linux-ia64] sys_clone() related info/help/pointer needed Raj Patil
@ 2003-05-27 16:57 ` David Mosberger
  2003-05-30 16:21 ` Raj Patil
  2003-05-30 17:47 ` David Mosberger
  2 siblings, 0 replies; 4+ messages in thread
From: David Mosberger @ 2003-05-27 16:57 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Thu, 22 May 2003 13:36:19 -0700 (PDT), Raj Patil <rpatil0296@yahoo.com> said:

  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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-ia64] sys_clone() related info/help/pointer needed
  2003-05-22 20:36 [Linux-ia64] sys_clone() related info/help/pointer needed Raj Patil
  2003-05-27 16:57 ` David Mosberger
@ 2003-05-30 16:21 ` Raj Patil
  2003-05-30 17:47 ` David Mosberger
  2 siblings, 0 replies; 4+ messages in thread
From: Raj Patil @ 2003-05-30 16:21 UTC (permalink / raw)
  To: linux-ia64

[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

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

David Mosberger <davidm@napali.hpl.hp.com> wrote:

>>>>> On Thu, 22 May 2003 13:36:19 -0700 (PDT), Raj Patil said:

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).

[-- Attachment #2: Type: text/html, Size: 2256 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-ia64] sys_clone() related info/help/pointer needed
  2003-05-22 20:36 [Linux-ia64] sys_clone() related info/help/pointer needed Raj Patil
  2003-05-27 16:57 ` David Mosberger
  2003-05-30 16:21 ` Raj Patil
@ 2003-05-30 17:47 ` David Mosberger
  2 siblings, 0 replies; 4+ messages in thread
From: David Mosberger @ 2003-05-30 17:47 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Fri, 30 May 2003 09:21:54 -0700 (PDT), Raj Patil <rpatil0296@yahoo.com> said:

  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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-05-30 17:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-22 20:36 [Linux-ia64] sys_clone() related info/help/pointer needed Raj Patil
2003-05-27 16:57 ` David Mosberger
2003-05-30 16:21 ` Raj Patil
2003-05-30 17:47 ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox