From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: libc-alpha@sourceware.org,
Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH v5 4/5] x86-64: Add the clone3 wrapper
Date: Thu, 20 May 2021 16:53:00 +0200 [thread overview]
Message-ID: <87y2c9mp83.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210515123442.1432385-5-hjl.tools@gmail.com> (H. J. Lu's message of "Sat, 15 May 2021 05:34:41 -0700")
* H. J. Lu:
> extern int clone3 (struct clone_args *__cl_args,
> int (*__func) (void *__arg), void *__arg);
> ---
> sysdeps/unix/sysv/linux/x86_64/clone3.S | 92 +++++++++++++++++++++++++
> sysdeps/unix/sysv/linux/x86_64/sysdep.h | 2 +
> 2 files changed, 94 insertions(+)
> create mode 100644 sysdeps/unix/sysv/linux/x86_64/clone3.S
>
> diff --git a/sysdeps/unix/sysv/linux/x86_64/clone3.S b/sysdeps/unix/sysv/linux/x86_64/clone3.S
> new file mode 100644
> index 0000000000..f7d4036a6a
> + .text
> +ENTRY (__clone3)
> + /* Sanity check arguments. */
> + movq $-EINVAL, %rax
> + testq %rdi, %rdi /* No NULL cl_args pointer. */
> + jz SYSCALL_ERROR_LABEL
> + testq %rsi, %rsi /* No NULL function pointer. */
> + jz SYSCALL_ERROR_LABEL
I think some of these register aren't x32-compatible. Isn't the upper
half undefined?
> + /* Save the function pointer in R8 which is preserved by the
> + syscall. */
> + movq %rsi, %r8
> +
> + /* Put sizeof (struct clone_args) in ESI. */
> + movl $CLONE_ARGS_SIZE , %esi
If this is in preparation of the public wrapper, this should actually be
an argument. Sorry didn't realize this was the direction.
> +L(thread_start):
> + cfi_startproc
> + /* Clearing frame pointer is insufficient, use CFI. */
> + cfi_undefined (rip)
> + /* Clear the frame pointer. The ABI suggests this be done, to mark
> + the outermost frame obviously. */
> + xorl %ebp, %ebp
> +
> + /* Set up arguments for the function call. */
> + movq %rdx, %rdi /* Argument. */
> + call *%r8 /* Call function. */
> + /* Call exit with return value from function call. */
> + movq %rax, %rdi
> + movl $SYS_ify(exit), %eax
> + syscall
> + cfi_endproc
> +
> + cfi_startproc
> +PSEUDO_END (__clone3)
If this is a public wrapper, should it round up %rsp to 16 bytes
at the point of the caller, to follow the x86-64 calling convention?
Thanks,
Florian
next prev parent reply other threads:[~2021-05-20 14:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 12:34 [PATCH v5 0/5] Add an internal wrapper for clone, clone2 and clone3 H.J. Lu
2021-05-15 12:34 ` [PATCH v5 1/5] " H.J. Lu
2021-05-20 14:46 ` Florian Weimer
2021-05-22 1:14 ` H.J. Lu
2021-05-15 12:34 ` [PATCH v5 2/5] nptl: Always pass stack size to create_thread H.J. Lu
2021-05-20 14:26 ` Florian Weimer
2021-05-15 12:34 ` [PATCH v5 3/5] GLIBC_PRIVATE: Export __clone_internal H.J. Lu
2021-05-17 13:54 ` Andreas Schwab
2021-05-20 14:24 ` Florian Weimer
2021-05-22 1:55 ` H.J. Lu
2021-05-15 12:34 ` [PATCH v5 4/5] x86-64: Add the clone3 wrapper H.J. Lu
2021-05-20 14:53 ` Florian Weimer [this message]
2021-05-22 1:38 ` H.J. Lu
2021-05-20 18:35 ` Noah Goldstein
2021-05-20 18:39 ` Noah Goldstein
2021-05-22 1:52 ` H.J. Lu
2021-05-15 12:34 ` [PATCH v5 5/5] Add tests for __clone_internal H.J. Lu
2021-05-20 15:08 ` Florian Weimer
2021-05-22 1:54 ` H.J. Lu
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=87y2c9mp83.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).