From: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Louis Rilling <Louis.Rilling-aw0BnHfMbSpBDgjK7y7TUQ@public.gmane.org>
Cc: containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: Re: updated x86_64 eclone() stub
Date: Fri, 04 Dec 2009 08:21:29 -0800 [thread overview]
Message-ID: <1259943689.32391.5111.camel@nimitz> (raw)
In-Reply-To: <20091204160825.GL2430-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>
On Fri, 2009-12-04 at 17:08 +0100, Louis Rilling wrote:
> On 04/12/09 8:05 -0800, Dave Hansen wrote:
> > > syscall also destroys r11, so it should be added to the clobber list.
> >
> > Even though it is a ptregscall?
>
> The assembly instruction itself destroys r11 (same for rcx).
Thanks again for the help, Louis. How does this look?
int clone_with_pids(long flags_low, struct clone_args *clone_args, long args_size,
int *pids)
{
long retval;
__asm__ __volatile__(
"movq %5, %%r10\n\t" /* pids in r10*/
"syscall\n\t" /* Linux/x86_64 system call */
"testq %0,%0\n\t" /* check return value */
"jne 1f\n\t" /* jump if parent */
"popq %%rax\n\t" /* get subthread function */
"popq %%rdi\n\t" /* get the subthread function arg */
"call *%%rax\n\t" /* start subthread function */
"movq %6,%0\n\t"
"syscall\n" /* exit system call: exit subthread */
"1:\n\t"
:"=a" (retval)
:"0" (__NR_clone3),/* eax */
"D" (flags_low), /* rdi */
"S" (clone_args), /* rsi */
"d" (args_size), /* rdx */
"m" (pids), /* gets moved to r10 */
"i" (__NR_exit)
:"rcx", "r10", "r11", "cc"
);
/*
* glibc lists 'cc' as clobbered, so we might as
* well do it too. 'r11' and 'rcx' are clobbered
* by the 'syscall' instruction itself. 'r8' and
* 'r9' are clobbered by the clone, but that
* thread will exit before getting back out to C.
*/
if (retval < 0) {
errno = -retval;
retval = -1;
}
return retval;
}
> Thanks,
>
> Louis
>
-- Dave
next prev parent reply other threads:[~2009-12-04 16:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 15:29 updated x86_64 eclone() stub Dave Hansen
2009-12-04 16:01 ` Louis Rilling
[not found] ` <20091204160123.GJ2430-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>
2009-12-04 16:05 ` Dave Hansen
2009-12-04 16:08 ` Louis Rilling
[not found] ` <20091204160825.GL2430-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>
2009-12-04 16:21 ` Dave Hansen [this message]
2009-12-04 17:24 ` Louis Rilling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259943689.32391.5111.camel@nimitz \
--to=dave-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=Louis.Rilling-aw0BnHfMbSpBDgjK7y7TUQ@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.