From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-5.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BBCF51F953 for ; Tue, 30 Nov 2021 11:55:54 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C6F23857C73 for ; Tue, 30 Nov 2021 11:55:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C6F23857C73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638273353; bh=Ema1YJAvz9jKXw+YhHyz8FbgXLdF2h4weh9Xm5+HnQY=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FFN+iTFgr2zEsyxa7B1udDHyju/5ZHQ93scCz5u4+0HzHZKBL8VMsZHKMzk+RHfAH aJE6vykxIDHg08HE82WOiwwuo5srjytlF7l3pWD3DYxvXxZX2QIF+x5eaufVM7y5xO XtnhJ6lT2j7oRauX7JPcRJw2pkwEudaoj+pJhn7M= Received: from mail-ua1-x92f.google.com (mail-ua1-x92f.google.com [IPv6:2607:f8b0:4864:20::92f]) by sourceware.org (Postfix) with ESMTPS id EA4E83858C2C for ; Tue, 30 Nov 2021 11:55:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA4E83858C2C Received: by mail-ua1-x92f.google.com with SMTP id o1so40764784uap.4 for ; Tue, 30 Nov 2021 03:55:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ema1YJAvz9jKXw+YhHyz8FbgXLdF2h4weh9Xm5+HnQY=; b=YHDrjbKQh+1ZUqarrcyUEoa0TgceIlWl+jqhAirCCLjo5aEeZNAeqyeyxH/i/jyMrd 4FxkcG05YVg+5G5VCwRV83SOplbTxABYPwsYUveIav3OghBGadtcqxZyNxOsIGTcNxkT OL9rUSGdc5CZeFDMFmLmIRDwe9JGAqL0+oX/ZP3kV7Oa6dwqC88y1rwft0Ok6Vu94gMX 6bCdyvyFiF25mg2NAOsjgahDcyBVLl2hhkjTIbBIXV9J0TOwh4eERhLPIRikba7Gs6nE LD+mXT/ONTb6H9ng38tatMzZ4RORJGMCGB13dOJXbVdDy22FJnYXEQSCSvX8k8MSUUdH FUFw== X-Gm-Message-State: AOAM531SdTYec2e22n/cS4w71e0lRLaxKLsWf+eB4YP2g1bjJBAPUy+3 6gXQDg770c41fYP+CAnh7wVvRe65XWm6sA== X-Google-Smtp-Source: ABdhPJwmv0VF72F2iAsU7ZCb9hFG2vKVWumhHSB0FIHgIXOpRIaGGKMohb0l4MBi3EkKlAu1Lw9DWQ== X-Received: by 2002:a67:c402:: with SMTP id c2mr39969149vsk.53.1638273332534; Tue, 30 Nov 2021 03:55:32 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:30f8:6601:a360:bcd5:8568? ([2804:431:c7cb:30f8:6601:a360:bcd5:8568]) by smtp.gmail.com with ESMTPSA id q9sm9913172vkn.44.2021.11.30.03.55.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Nov 2021 03:55:32 -0800 (PST) Message-ID: Date: Tue, 30 Nov 2021 08:55:30 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 3/6] linux: Implement mremap in C Content-Language: en-US To: Stafford Horne References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> <20211122185437.1934590-4-adhemerval.zanella@linaro.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 25/11/2021 21:26, Stafford Horne wrote: > On Mon, Nov 22, 2021 at 03:54:34PM -0300, Adhemerval Zanella wrote: >> Variadic function calls in syscalls.list does not work for all ABIs >> (for instance where the argument are passed on the stack instead of >> registers) and might have underlying issues depending of the variadic >> type (for instance if a 64-bit argument is used). >> >> Checked on x86_64-linux-gnu. >> --- >> sysdeps/unix/sysv/linux/Makefile | 1 + >> sysdeps/unix/sysv/linux/mremap.c | 41 +++++++++++++++++++++++++++ >> sysdeps/unix/sysv/linux/syscalls.list | 1 - >> 3 files changed, 42 insertions(+), 1 deletion(-) >> create mode 100644 sysdeps/unix/sysv/linux/mremap.c >> >> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile >> index aa10754b98..1dd6ec9ef9 100644 >> --- a/sysdeps/unix/sysv/linux/Makefile >> +++ b/sysdeps/unix/sysv/linux/Makefile >> @@ -68,6 +68,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ >> closefrom_fallback \ >> clone3 clone-internal \ >> fanotify_mark \ >> + mremap \ >> >> CFLAGS-gethostid.c = -fexceptions >> CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables >> diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c >> new file mode 100644 >> index 0000000000..83b4e95338 >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/mremap.c >> @@ -0,0 +1,41 @@ >> +/* Remap a virtual memory address. Linux specific syscall. >> + Copyright (C) 2020 Free Software Foundation, Inc. >> + This file is part of the GNU C Library. > > 2021 Ack. > >> + >> + 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 >> +#include >> + >> +void * >> +__mremap (void *addr, size_t old_len, size_t new_len, int flags, ...) >> +{ >> + va_list va; >> + void *new_addr = NULL; >> + >> + if (flags & MREMAP_FIXED) >> + { >> + va_start (va, flags); >> + new_addr = va_arg (va, void *); >> + va_end (va); >> + } >> + >> + return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags, >> + new_addr); >> +} >> +libc_hidden_def (__mremap) >> +weak_alias (__mremap, mremap) >> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list >> index 29899eb264..2acd7551d3 100644 >> --- a/sysdeps/unix/sysv/linux/syscalls.list >> +++ b/sysdeps/unix/sysv/linux/syscalls.list >> @@ -35,7 +35,6 @@ mincore - mincore i:aUV mincore >> mlock - mlock i:bU mlock >> mlockall - mlockall i:i mlockall >> mount EXTRA mount i:sssUp __mount mount >> -mremap EXTRA mremap b:aUUip __mremap mremap >> munlock - munlock i:aU munlock >> munlockall - munlockall i: munlockall >> nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28 >> -- >> 2.32.0 >> > > This looks OK to me. > > Note, I guess this syscall would be broken in or1k at the moment as it passes > variadic args on the stack. However, I didn't see any test failures due to > this. I think it would be for MREMAP_FIXED and the there is no failures because we don't use the flag neither internally nor on any test.