From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 6EE223858D3C for ; Thu, 25 May 2023 17:36:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EE223858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-19a77e4c8dcso1518350fac.1 for ; Thu, 25 May 2023 10:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685036196; x=1687628196; h=content-transfer-encoding:in-reply-to:organization:references:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=CUIff7hOxle2XcZqGobHyMLmhgqNrPy5ATN+Kk4BqHU=; b=o3Xkp084MPThqCIZSk4O4qe29y9tnkHf+hwVr2CX/xsTixhxKvC6UsX9RIGBVmUI/R vSM5lZL9XjLmKIN36Z7jZSdJe+/Nv7wdy3xs0QEaE4kupaf5SB2oluRVbXLFGU9CSkle 6PzLIIjALu2wHIHsoQ2j+/kOzgBY7w27vHXD4sK0P1C9O2Sg5LN8kerE7Ky9R6AtmzRu vpQL0Q9OnUXv/bsuN4XD3up0Il+Su4o/kbcHBZz4kQJqjM89XDHnpjHonzBohJFmW0kh 0/0ztUzhAFPV8rhzjZyG4eogLuu0E6VQ/NKo6IyaARg/c1dJ5C7P94rQSjJkZ2SXQske Zt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685036196; x=1687628196; h=content-transfer-encoding:in-reply-to:organization:references:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CUIff7hOxle2XcZqGobHyMLmhgqNrPy5ATN+Kk4BqHU=; b=EYv8OJOgbd6Lnvi/YODr2PSRtAm1bANuxb1Z8MbVjPjsC8Vp+3KyXp1iT04AI0JqKP 9d4K+H4ilZsrTPyVVnwnSyr9MqMZNH0E9H+6ADNOp6FHif6rwmCHVNWAoVlv+EiATdeT LTU9gUq8BWbUA76hTPlACkEpW/VFjzC2VTj7FOkdTRQJE48fkrFdv+jX9GG8mGh03934 2j5tBGX8HerhXG+q8yrqBfSs31g3cA5y6Y5vedlJDh8i6yfJK9muwEtoEJrzxcyTCc+i uqoKqGxXQ2lT6XH0dyKk8XwdRInRor4QFPqk2H1ERrqN9u3IazQz5h8aF9ZPKCQoJHYo eWNQ== X-Gm-Message-State: AC+VfDzeRXW8gfWmRi+WC4PsOzBplBSMHcb2skw5TgZeRspkKQF9srWF xW2Ti9bBDIMgMFcekhuSvLoX/v7IguJP0roANd9bEw== X-Google-Smtp-Source: ACHHUZ5c9UQBgNOjSAo4koakok9y0D4VOo9D4HfXdYYnSOQPib/mIdtS7kagovP5R/MvUQM5luEJoA== X-Received: by 2002:a05:6870:a2d6:b0:187:9783:a20e with SMTP id w22-20020a056870a2d600b001879783a20emr2695575oak.37.1685036196197; Thu, 25 May 2023 10:36:36 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:4dd5:80c6:51f7:4cf7:20d3? ([2804:1b3:a7c1:4dd5:80c6:51f7:4cf7:20d3]) by smtp.gmail.com with ESMTPSA id n34-20020a056870822200b001931cb17a86sm846069oae.27.2023.05.25.10.36.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 May 2023 10:36:34 -0700 (PDT) Message-ID: Date: Thu, 25 May 2023 14:36:33 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.1 Subject: Re: [PATCH 3/5] riscv: Add the clone3 wrapper Content-Language: en-US From: Adhemerval Zanella Netto To: libc-alpha@sourceware.org References: <20230203171237.1220878-1-adhemerval.zanella@linaro.org> <20230203171237.1220878-4-adhemerval.zanella@linaro.org> Organization: Linaro In-Reply-To: <20230203171237.1220878-4-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Ping. On 03/02/23 14:12, Adhemerval Zanella wrote: > It follows the internal signature: > > extern int clone3 (struct clone_args *__cl_args, size_t __size, > int (*__func) (void *__arg), void *__arg); > > Checked on riscv64-linux-gnu-rv64imafdc-lp64d. > --- > sysdeps/unix/sysv/linux/riscv/clone3.S | 80 ++++++++++++++++++++++++++ > sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + > 2 files changed, 81 insertions(+) > create mode 100644 sysdeps/unix/sysv/linux/riscv/clone3.S > > diff --git a/sysdeps/unix/sysv/linux/riscv/clone3.S b/sysdeps/unix/sysv/linux/riscv/clone3.S > new file mode 100644 > index 0000000000..ee5780ee2f > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/clone3.S > @@ -0,0 +1,80 @@ > +/* The clone3 syscall wrapper. Linux/RISC-V 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 > +#include > +#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: > + a0: cl_args > + a1: size > + a2: func > + a3: arg */ > + > + .text > +ENTRY(__clone3) > + /* Sanity check args. */ > + beqz a0, L(invalid) /* No NULL cl_args pointer. */ > + beqz a2, L(invalid) /* No NULL function pointer. */ > + > + /* Do the system call, the kernel expects: > + a7: system call number > + a0: cl_args > + a1: size */ > + li a7, __NR_clone3 > + scall > + > + bltz a0, L(error) > + beqz a0, L(thread_start) > + > + ret > + > +L(invalid): > + li a0, -EINVAL > +L(error): > + tail __syscall_error > +END (__clone3) > + > +ENTRY(__thread_start_clone3) > +L(thread_start): > + /* Terminate call stack by noting ra is undefined. Use a dummy > + .cfi_label to force starting the FDE. */ > + .cfi_label .Ldummy > + cfi_undefined (ra) > + > + /* Restore the arg for user's function and call the user's > + function. */ > + mv a1, a2 /* Function pointer. */ > + mv a0, a3 /* Argument pointer. */ > + jalr a1 > + > + /* Call exit with the function's return value. */ > + li a7, __NR_exit > + scall > +END(__thread_start_clone3) > + > +libc_hidden_def (__clone3) > +weak_alias (__clone3, clone3) > diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h > index 4af5fe5dbc..e96a930409 100644 > --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h > +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h > @@ -151,6 +151,7 @@ > > /* RV32 does not support the gettime VDSO syscalls. */ > # endif > +# define HAVE_CLONE3_WRAPPER 1 > > /* List of system calls which are supported as vsyscalls (for RV32 and > RV64). */