From patchwork Fri Nov 4 19:01:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 59963 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C75603858288 for ; Fri, 4 Nov 2022 19:05:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C75603858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667588733; bh=SCdFZC4yIzi2+pZdhiVHA3Fw2dQ1lGJ95UCYYNgkWWg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gMSzarSb5NsXw2AqjG62oGDjRgTDBZ5c48cTWkFIPpLyuBmXAPXCAeM6yZGk4I4f9 uqJtxli/SCR2DThV4+FacOOH3n8IT0L2UDd6qX3TZ4OC76kL4b+On1CyCAht9ctuUW M2Oa8Ajf2WDSM1GOW8JghlM8EzEHjM9ras7GbrHs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by sourceware.org (Postfix) with ESMTPS id A734E3858431 for ; Fri, 4 Nov 2022 19:01:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A734E3858431 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-13c2cfd1126so6499312fac.10 for ; Fri, 04 Nov 2022 12:01:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SCdFZC4yIzi2+pZdhiVHA3Fw2dQ1lGJ95UCYYNgkWWg=; b=xw1hwg6G9QHa3aQRUbD6qRc30sj/tPUdmlfV+BidRw08LhWQ9q5J512xLVQch3U14f v4YnmA+4J1nEb/J3lQBR/LSp1G7KzMklAeuZS4NcovqUYlGi1ADG0rzAktn5nR+/fqPL T84xhphTlJDN3uSTfwKRQ0TtQvJc8gnnc+Kimzb0vy9WIkE96QA4ZVcVYTI+D+UAktUi fbqddUEHp9ur2kyrD7lmzrs1JQOC5EGQUb8dE98GKF5Ba6ggnLdTiYqARxhSC8v050t/ zntqsCKZEiFKfgLZe/zAxyFrmkpDTki8ui3ADzT0upKO/q5DkAH1hbtTftAIPGv3J3uw q4ng== X-Gm-Message-State: ACrzQf1yiSO/jq3jFh4XyDZCMHQ1UnDqzI9wl5UI7TQkfEik4vTb6KFv W4moPFwS5fvS2Q+o8hddzBgfgNqhX8RTImRl X-Google-Smtp-Source: AMsMyM5nstneTmgwk7OaCesVAYboWCsz1f8v6snGHukjdwd1I7rzYROT3k8ESfk7XCEvCF1FkjqIkw== X-Received: by 2002:a05:6870:a997:b0:12a:e54e:c8ee with SMTP id ep23-20020a056870a99700b0012ae54ec8eemr30773918oab.172.1667588487355; Fri, 04 Nov 2022 12:01:27 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:a9f4:f725:94bd:4cc1:1762]) by smtp.gmail.com with ESMTPSA id 24-20020aca1018000000b0035763a9a36csm1764713oiq.44.2022.11.04.12.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 12:01:27 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy , "H . J . Lu" Subject: [PATCH v2 06/11] aarch64: Add the clone3 wrapper Date: Fri, 4 Nov 2022 16:01:07 -0300 Message-Id: <20221104190112.2566409-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221104190112.2566409-1-adhemerval.zanella@linaro.org> References: <20221104190112.2566409-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Cc: Christian Brauner Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It follow the internal signature: extern int clone3 (struct clone_args *__cl_args, size_t __size, int (*__func) (void *__arg), void *__arg); Checked on aarch64-linux-gnu. Reviewed-by: Szabolcs Nagy --- sysdeps/unix/sysv/linux/aarch64/clone3.S | 85 ++++++++++++++++++++++++ sysdeps/unix/sysv/linux/aarch64/sysdep.h | 2 + 2 files changed, 87 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S diff --git a/sysdeps/unix/sysv/linux/aarch64/clone3.S b/sysdeps/unix/sysv/linux/aarch64/clone3.S new file mode 100644 index 0000000000..5d42bc03e9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/clone3.S @@ -0,0 +1,85 @@ +/* The clone3 syscall wrapper. Linux/aarch64 version. + Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#define _ERRNO_H 1 +#include + +/* The userland implementation is: + int clone3 (struct clone_args *cl_args, size_t size, + int (*func)(void *arg), void *arg); + + the kernel entry is: + int clone3 (struct clone_args *cl_args, size_t size); + + The parameters are passed in registers from userland: + x0: cl_args + x1: size + x2: func + x3: arg */ + + .text +ENTRY(__clone3) + PTR_ARG (0) + PTR_ARG (1) + PTR_ARG (3) + PTR_ARG (4) + /* Save args for the child. */ + mov x10, x0 /* cl_args */ + mov x11, x2 /* func */ + mov x12, x3 /* args */ + + /* Sanity check args. */ + mov x0, #-EINVAL + cbz x10, .Lsyscall_error /* No NULL cl_args pointer. */ + cbz x2, .Lsyscall_error /* No NULL function pointer. */ + + /* Do the system call, the kernel expects: + x8: system call number + x0: cl_args + x1: size */ + mov x0, x10 + mov x8, #SYS_ify(clone3) + svc 0x0 + + cmp x0, #0 + beq thread_start + blt .Lsyscall_error + RET +PSEUDO_END (__clone3) + + .align 4 + .type thread_start, %function +thread_start: + cfi_startproc + cfi_undefined (x30) + mov x29, 0 + + /* Pick the function arg and execute. */ + mov x0, x12 + blr x11 + + /* We are done, pass the return value through x0. */ + mov x8, #SYS_ify(exit) + svc 0x0 + cfi_endproc + .size thread_start, .-thread_start + +libc_hidden_def (__clone3) +weak_alias (__clone3, clone3) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index 8ba50dab8f..00c0a02693 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -164,6 +164,8 @@ # define HAVE_CLOCK_GETTIME64_VSYSCALL "__kernel_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday" +# define HAVE_CLONE3_WRAPPER 1 + # undef INTERNAL_SYSCALL_RAW # define INTERNAL_SYSCALL_RAW(name, nr, args...) \ ({ long _sys_result; \