* [LTP] ltp_clone
@ 2011-02-25 11:11 Will Deacon
2011-02-25 14:41 ` Hannu Heikkinen
0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2011-02-25 11:11 UTC (permalink / raw)
To: ltp-list
Hello,
The definition of ltp_clone looks like this:
int
ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg,
size_t stack_size, void *stack)
{
int ret;
#if defined(__hppa__)
ret = clone(fn, stack, clone_flags, arg);
#elif defined(__ia64__)
ret = clone2(fn, stack, stack_size, clone_flags, arg, NULL, NULL, NULL);
#elif defined(__arm__)
/*
* Stack size should be a multiple of 32 bit words
* & stack limit must be aligned to a 32 bit boundary
*/
ret = clone(fn, (stack ? stack + stack_size : NULL),
clone_flags, arg);
#else
ret = clone(fn, (stack ? stack + stack_size - 1 : NULL),
clone_flags, arg);
#endif
return ret;
}
I believe the __arm__ case is to ensure that we pass an aligned
stack pointer to the syscall (as required by the architecture).
What I don't understand, is why we pass an unaligned address in
the #else case? Given that a stack push decrements the sp before
writing on every architecture I know of, it seems that the __arm__
case should be used as the default rather than forcing a misaligned
stack on other architectures.
Will
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [LTP] ltp_clone 2011-02-25 11:11 [LTP] ltp_clone Will Deacon @ 2011-02-25 14:41 ` Hannu Heikkinen 2011-02-25 14:46 ` Will Deacon 0 siblings, 1 reply; 3+ messages in thread From: Hannu Heikkinen @ 2011-02-25 14:41 UTC (permalink / raw) To: ext Will Deacon; +Cc: ltp-list On 25/02/11 11:11 +0000, ext Will Deacon wrote: > Hello, > > The definition of ltp_clone looks like this: > > > int > ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg, > size_t stack_size, void *stack) > { > int ret; > > #if defined(__hppa__) > ret = clone(fn, stack, clone_flags, arg); > #elif defined(__ia64__) > ret = clone2(fn, stack, stack_size, clone_flags, arg, NULL, NULL, NULL); > #elif defined(__arm__) > /* > * Stack size should be a multiple of 32 bit words > * & stack limit must be aligned to a 32 bit boundary > */ > ret = clone(fn, (stack ? stack + stack_size : NULL), > clone_flags, arg); > #else > ret = clone(fn, (stack ? stack + stack_size - 1 : NULL), > clone_flags, arg); > #endif > > return ret; > } > > > I believe the __arm__ case is to ensure that we pass an aligned > stack pointer to the syscall (as required by the architecture). > What I don't understand, is why we pass an unaligned address in > the #else case? Given that a stack push decrements the sp before > writing on every architecture I know of, it seems that the __arm__ > case should be used as the default rather than forcing a misaligned > stack on other architectures. > > Will > Hi, have you fetched the latest from the git tree: git://ltp.git.sourceforge.net/gitroot/ltp/ltp ? Lines are: int ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg, size_t stack_size, void *stack) { int ret; #if defined(__hppa__) ret = clone(fn, stack, clone_flags, arg); #elif defined(__ia64__) ret = clone2(fn, stack, stack_size, clone_flags, arg, NULL, NULL, NULL); #else /* * For archs where stack grows downwards, stack points to the topmost * address of the memory space set up for the child stack. */ ret = clone(fn, (stack ? stack + stack_size : NULL), clone_flags, arg); #endif return ret; } br, Hannu ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] ltp_clone 2011-02-25 14:41 ` Hannu Heikkinen @ 2011-02-25 14:46 ` Will Deacon 0 siblings, 0 replies; 3+ messages in thread From: Will Deacon @ 2011-02-25 14:46 UTC (permalink / raw) To: 'Hannu Heikkinen'; +Cc: ltp-list Hi Hannu, > > I believe the __arm__ case is to ensure that we pass an aligned > > stack pointer to the syscall (as required by the architecture). > > What I don't understand, is why we pass an unaligned address in > > the #else case? Given that a stack push decrements the sp before > > writing on every architecture I know of, it seems that the __arm__ > > case should be used as the default rather than forcing a misaligned > > stack on other architectures. > > > > Will > > > > Hi, > > have you fetched the latest from the git tree: > git://ltp.git.sourceforge.net/gitroot/ltp/ltp ? > > Lines are: > > int > ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg, > size_t stack_size, void *stack) > { > int ret; > > #if defined(__hppa__) > ret = clone(fn, stack, clone_flags, arg); > #elif defined(__ia64__) > ret = clone2(fn, stack, stack_size, clone_flags, arg, NULL, NULL, > NULL); > #else > /* > * For archs where stack grows downwards, stack points to the topmost > * address of the memory space set up for the child stack. > */ > ret = clone(fn, (stack ? stack + stack_size : NULL), > clone_flags, arg); > #endif > > return ret; > } Wahey - that's much better! I was accidently looking in my checkout of the October stable release, where ARM is special-cased. Thanks for pointing this out. Will ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-25 14:47 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-02-25 11:11 [LTP] ltp_clone Will Deacon 2011-02-25 14:41 ` Hannu Heikkinen 2011-02-25 14:46 ` Will Deacon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox