From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 3B8BD38515EB for ; Thu, 20 May 2021 14:53:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3B8BD38515EB Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-w7AEEtbhPq6RxvwBPmqRCA-1; Thu, 20 May 2021 10:53:05 -0400 X-MC-Unique: w7AEEtbhPq6RxvwBPmqRCA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C6BA1926DA2; Thu, 20 May 2021 14:53:03 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-137.ams2.redhat.com [10.36.112.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67DD05C233; Thu, 20 May 2021 14:53:02 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: libc-alpha@sourceware.org, Adhemerval Zanella Subject: Re: [PATCH v5 4/5] x86-64: Add the clone3 wrapper References: <20210515123442.1432385-1-hjl.tools@gmail.com> <20210515123442.1432385-5-hjl.tools@gmail.com> Date: Thu, 20 May 2021 16:53:00 +0200 In-Reply-To: <20210515123442.1432385-5-hjl.tools@gmail.com> (H. J. Lu's message of "Sat, 15 May 2021 05:34:41 -0700") Message-ID: <87y2c9mp83.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 14:53:08 -0000 * 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