From patchwork Thu Jan 12 13:58:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 63101 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 7293538493CC for ; Thu, 12 Jan 2023 14:00:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7293538493CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673532053; bh=Rsk0yRx5gO16zT+RO2xJvBBrvyA2e1X1gmNvuqHRlsQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qs+Ya6osumhS6qFyEGpI9FZQqmMeCGofr/Zjf4nJwmn9ehUNkF/UPbZUIyG3jlO4o ouCwJ1zgqmf/3/SNkaV+4fkpcxT6jUzQjJWXSEb32w1o+5PrSiBwdyuIJmxZcJg51U kgVB5WIIG7cR6qMhB5KIhedV3WKpHz1RS64ICWlM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 63B083853573 for ; Thu, 12 Jan 2023 13:59:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63B083853573 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-12c8312131fso18949305fac.4 for ; Thu, 12 Jan 2023 05:59:08 -0800 (PST) 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rsk0yRx5gO16zT+RO2xJvBBrvyA2e1X1gmNvuqHRlsQ=; b=h1wbSd2mGkfTWmuLczwWuuNPp3cFHtdq3g7oMgaIHkNif3kInnH4yHfniJWw8caXvH P1854gFepfIYGU2EcSMunfkJKzjHO+mWGsi7MP42nQc/m+TQXQfWKzgi2qQERBqUMG/N FIGtN+qQY/vgz17XzTcCCvlBXTWRgez+F2p1ZZri/fleqMsaZfLd2OCumQuZD9MDxsGs f3RhLjmBrWXfxsEsQMowS1TJGbS/j/98aE+2pC52N1CFyktIlcV+XbNdV7/cE7ORku6y FgExySBYTzG/yrosF9BEQ7j/3sAYHuRDoAqBKkDp4fTva+vVGgqyhTgDrkPQqfNjsBdE 5mSA== X-Gm-Message-State: AFqh2ko3Mh+cyaMkL9Qn9TM+bSuRHvN4VD3YLQMGY0utzTYR9rmDPQ9N yonoCZQvoAoI30xkgLwRr4X7GencsOR4EzDyr1w= X-Google-Smtp-Source: AMrXdXtPsZEQt1oOeeP68gr8xAwAbrUyc5EKv+5K3nanyC2v7DPwA0/oz9vdJ9dZAmJDX1BuazBOmg== X-Received: by 2002:a05:6870:2c97:b0:15e:9c48:c9b6 with SMTP id oh23-20020a0568702c9700b0015e9c48c9b6mr3328094oab.34.1673531947200; Thu, 12 Jan 2023 05:59:07 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:bf1c:dea8:4fd2:4310]) by smtp.gmail.com with ESMTPSA id m26-20020a4abc9a000000b004a0aac2d28fsm8335402oop.35.2023.01.12.05.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 05:59:06 -0800 (PST) To: libc-alpha@sourceware.org, Carlos O'Donell Subject: [PATCH v4 5/6] aarch64: Add the clone3 wrapper Date: Thu, 12 Jan 2023 10:58:52 -0300 Message-Id: <20230112135853.3786675-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112135853.3786675-1-adhemerval.zanella@linaro.org> References: <20230112135853.3786675-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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 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: Carlos O'Donell --- 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..88a1fa1e89 --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/clone3.S @@ -0,0 +1,85 @@ +/* The clone3 syscall wrapper. Linux/aarch64 version. + Copyright (C) 2023 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 6520fa15da..e94d1703ad 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -165,6 +165,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; \