From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 33698385841A for ; Fri, 26 Nov 2021 00:26:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33698385841A Received: by mail-pj1-x102f.google.com with SMTP id h24so6123701pjq.2 for ; Thu, 25 Nov 2021 16:26:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=e5sMB2bZ8JA4YlBk9uppA8qRD00VMmzvtRIJteTIIL4=; b=VvCirWomHbArifal9rJu+mmBBsez5uPoYvbOkSxBL8XwI+7pwl6fc0N9Ly142xpFo5 A7C6YzhKqxBJIyTd8Y9W1x+1IzVY1Q7/fod4MaIqYP/dvSbqhk/d+L0j8ZSKw3BY/6y9 H3Mp20n8Y7lgaoe17IG7XrzAGzxvJlsaTGMZo4TyVcaRz0hxwDSRxlg9Vdjy5WSQa+n2 iZ4Pgxch4zug7rdoDMJu2v3G957276pjQzV7aMPD2uYH+tV1TQiUJFmtgZyEdHSepDSH K0Xfnl33JQIl+5d1MdZeUrv7E1cH6xrqYP+tFFgri588l8hs693wD1IZixmK+VgNQiu7 PelA== X-Gm-Message-State: AOAM531V9eImL0BNQrBAc0pkxKGO6la4OuIbznUcgwapTSO2i1esmBny 07wlDxPpYuoLa22PHVGqRq4PPJBs3Vw= X-Google-Smtp-Source: ABdhPJyxCpzBaiPmE9E2HazfAdjahjP1OsEvGuXUiXJ0KjDL8X7w/r89MlqUZ16vBbLkZ3wmGrkLBQ== X-Received: by 2002:a17:90b:4b09:: with SMTP id lx9mr11975219pjb.100.1637886389287; Thu, 25 Nov 2021 16:26:29 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id g20sm5307691pfj.12.2021.11.25.16.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 16:26:28 -0800 (PST) Date: Fri, 26 Nov 2021 09:26:26 +0900 From: Stafford Horne To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 3/6] linux: Implement mremap in C Message-ID: References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> <20211122185437.1934590-4-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211122185437.1934590-4-adhemerval.zanella@linaro.org> X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 26 Nov 2021 00:26:31 -0000 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 > + > + 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. -Stafford