From patchwork Fri Nov 4 19:01:10 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: 59959 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 08AC8385829B for ; Fri, 4 Nov 2022 19:03:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08AC8385829B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667588581; bh=lD00FDa5c+CKfGJRd2q1PYDIyqpXXcfg5csxz1To1Xc=; 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=jLkYZs4TPNs6t7MTpQB3u+vrZKjD2j3QSbMZmiHYR07ZizOYituXvDPo593KZFSLj lcPAci/pevMYXVcmc5eslBMyxnlF3TLDaP5ATRKi2Nc848vgVNuv7cMWGxmRwDybSp PrQ/7hZBmO1RNMStbSmAMzaWfyqyuO8uwz/EUsnU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id ED9333858432 for ; Fri, 4 Nov 2022 19:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED9333858432 Received: by mail-oo1-xc32.google.com with SMTP id v7-20020a4aa507000000b00496e843fdfeso793013ook.7 for ; Fri, 04 Nov 2022 12:01:34 -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=lD00FDa5c+CKfGJRd2q1PYDIyqpXXcfg5csxz1To1Xc=; b=xViu8SZI8EurZ2Uzh5HIIvknBORR1GjGWYSmAQzax2B7HfpWr4558pJZSNSefD+rWq KchrjCvU4mHd43kSm1LJG3SDRqdsdzwfn8rV/LuDZDEo6cE6su3fqL12TzFMfN2/Y/N9 6e9hGHuzZ0X9fYW0jS+Qu/sQz3GnL9R9Z/1Li/T4vZdG7TX4gFl6skyWu0cqMMqWU5IY F+i1pP+pHDTWhAH/5Dcb0PipzVCPt1EE5qgdY/1A8yidrtISc2zzujjZywhPntH+wXX0 ZmyU5nqHZAh2acDV30pnR3IDFZrifZBqdGNNNhX45mvVbhEjM8q308iCYcvz5VvrnbdP qpPQ== X-Gm-Message-State: ACrzQf21D7X3GDBKwzdLauGeEOSSc7YQeTXby0T0B8qLDaV6T1I1QlPi /Zp75fJzrQGGNbnQMRUMbfSiOQnsUp1xD3pU X-Google-Smtp-Source: AMsMyM4RH03p7khuqbyMOGebqtf0Xe/5blujAc3FiylgQMVrHDHMeXYECQYYTEDSIv1O8DhscjyS1g== X-Received: by 2002:a4a:9683:0:b0:485:880b:aacb with SMTP id s3-20020a4a9683000000b00485880baacbmr15792506ooi.8.1667588492592; Fri, 04 Nov 2022 12:01:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 12:01:32 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy , "H . J . Lu" Subject: [PATCH v2 09/11] arm: Add the clone3 wrapper Date: Fri, 4 Nov 2022 16:01:10 -0300 Message-Id: <20221104190112.2566409-10-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.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, 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 follows the internal signature: extern int clone3 (struct clone_args *__cl_args, size_t __size, int (*__func) (void *__arg), void *__arg); Checked on arm-linux-gnueabihf. --- sysdeps/unix/sysv/linux/arm/clone3.S | 80 ++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/arm/sysdep.h | 1 + 2 files changed, 81 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/arm/clone3.S diff --git a/sysdeps/unix/sysv/linux/arm/clone3.S b/sysdeps/unix/sysv/linux/arm/clone3.S new file mode 100644 index 0000000000..d5949fae77 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/clone3.S @@ -0,0 +1,80 @@ +/* The clone3 syscall wrapper. Linux/arm 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: + r0: cl_args + r1: size + r2: func + r3: arg */ + + .text +ENTRY(__clone3) + /* Sanity check args. */ + cmp r0, #0 + ite ne + cmpne r1, #0 + moveq r0, #-EINVAL + beq PLTJMP(syscall_error) + + /* Do the syscall, the kernel expects: + r7: system call number: + r0: cl_args + r1: size */ + push { r7 } + cfi_adjust_cfa_offset (4) + cfi_rel_offset (r7, 0) + ldr r7, =SYS_ify(clone3) + swi 0x0 + cfi_endproc + + cmp r0, #0 + beq 1f + pop {r7} + blt PLTJMP(C_SYMBOL_NAME(__syscall_error)) + RETINSTR(, lr) + + cfi_startproc +PSEUDO_END (__clone3) + +1: + .fnstart + .cantunwind + mov r0, r3 + mov ip, r2 + BLX (ip) + + /* And we are done, passing the return value through r0. */ + ldr r7, =SYS_ify(exit) + swi 0x0 + + .fnend + +libc_hidden_def (__clone3) +weak_alias (__clone3, clone3) diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h index 1f270b961e..fcc86189d6 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -362,6 +362,7 @@ __local_syscall_error: \ #define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" #define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime64" #define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +#define HAVE_CLONE3_WRAPPER 1 #define LOAD_ARGS_0() #define ASM_ARGS_0