From patchwork Sun Aug 6 14:30:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 109508 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp518615qge; Sun, 6 Aug 2017 07:31:01 -0700 (PDT) X-Received: by 10.84.232.134 with SMTP id i6mr10310039plk.50.1502029861750; Sun, 06 Aug 2017 07:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502029861; cv=none; d=google.com; s=arc-20160816; b=u5ID5oSd3A4HL9V4o3Y1yAVURSm3OZmCvNJp/G2ABk6Zli4pozlUX39EM8K7gPMLH9 kZ+2bGx/h/jyf5JlFNSYzZa9lKQzaCevrjjEGdD7dfbdbYABosRcnuBrW6Vge60DFaWl PMfuztcqMh/krXf8qqWLL/lfovJnDRP3CPiypf+365EME0Aba1KcbO0WKvtNL04ZHTB0 aGl5rI6OrHIwkfNN3KArZTUgzzOR8RdfX2D4SlCiGk2ddXpB9HjRyRXVqjjR3j2Ni0Cd al1Lp0HwsxxwR1+xMZgA67x+WVGTr4h5RFxGH4gHUzEIEEjLwndZThD1CQTMLjWKhOAi c0DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=DBM7/tI8+TVUZh28vhYcbQeOTpMi5UDnhuiaQFJ+hsE=; b=ECpr2bF/vQvuMs6xRj0K2DfRAK3u4oOuPR+JruHuqr9u71TVGLUcz/x1M26MnkZpOJ pHmOeN1cdAYgJvbWvn6Apzr+d8WlJ16cwfITJ+Vr3hZPf/mpg9FybgNJsuoa3q5beHV1 yPIvgwisi0mofp9W41NPyfZLM8Ry7hwcr6VWrkH8S01XKMpsG6PEhOboizFiiTkraX19 IyR0ercVuKaqlVrDsBOt1ei8xyIY7qqYReJd0F5eov+0j1RPG1WRTaWdR0NY6NNURe9M Jm5OWbNIOIdsOV7M3abp/hwZM3RaeSBq8Z6E4O8Ys/YYyPp1x1fWy2V+8eAVi1EeXEku Sfpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=MSliSQ0l; spf=pass (google.com: domain of libc-alpha-return-82781-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82781-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a186si3490340pfb.402.2017.08.06.07.31.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Aug 2017 07:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-82781-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=MSliSQ0l; spf=pass (google.com: domain of libc-alpha-return-82781-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82781-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=YxVZOwmt5KdsbwlWiPMPMqDi+ZIp3kkuZBKjR8He0a8BwSflLVMv2 mUgk0oX29jvxznyEe3UH1bGJxieDW+EtGfFycXzuNyH7T4B9eB4UFD5TCeyon6Ny QJifRm/4IL8q7aoiBFxf9g1tArt+Df1cLuFRKFB1KhdM8ITqq/A7Pg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=AH9lAJo4e+BkXIizk+BPNDIycOw=; b=MSliSQ0l2UxGjkiDHbcKAcT3mbbB f8NQF8e1zxEpxGSjbobSx+hQvon8YCK0kPe9M85thtX/Lo+FII/CsqYbpH/LpHrB gETH/bWVBWv8CFgwLraYyOCaqxp82/+qIrVWqFTvKZCnld/BZmaSeG22+m1zneEA /TUoBkfxehIj5/E= Received: (qmail 75443 invoked by alias); 6 Aug 2017 14:30:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 75399 invoked by uid 89); 6 Aug 2017 14:30:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=D*inbox.ru X-HELO: mail-qt0-f175.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=DBM7/tI8+TVUZh28vhYcbQeOTpMi5UDnhuiaQFJ+hsE=; b=ZyrsZdiooQt6sShIxsD0eU3dHCLQT4cm/XFyvQVqKL7JhOJFofD6wL8FY5rVIWTwgj X5xIBrhEdZmKCui4CrGkTMiOqTFEHS/0RjNMMHlpuGru/ZoCJjGAWk9/FPamTcjZXsvg zpJomMInq/CtrQoxua4pnIZJ1AsgOQoVbIE7ippbi4vayyUVL7uQAJZprdFFx+6QfCo7 TGFqT/8gD5AgRZPla3FaH68dW8LY7YOwcR3LRtzu9Deo5fWeapQVtwEMBtPnbgaaPtmy 6Axx0zFH6ImlmbpPIVUCpei7YaMt+H57zdbW4noiJHuoJG8R1X5yqq1Np2qdd9aFVcJ7 q25Q== X-Gm-Message-State: AHYfb5gYsPcH5rr0CVAQb1H6a+1hxVqNiw2WQxl1Lk5+xbPSm8AWqv88 1dwXkG1wngiC/kzATBdWRA== X-Received: by 10.237.62.60 with SMTP id l57mr10780417qtf.20.1502029831954; Sun, 06 Aug 2017 07:30:31 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] posix: Fix mmap for m68k and ia64 (BZ#21908) Date: Sun, 6 Aug 2017 11:30:26 -0300 Message-Id: <1502029826-29081-1-git-send-email-adhemerval.zanella@linaro.org> Default semantic for mmap2 syscall is to take the offset in 4096-byte units. However m68k and ia64 mmap2 implementation take in the configured pagesize units and for both architecture it can be different values based on how kernel was built. This patch fixes the m68k runtime discover of mmap2 offset unit and adds the ia64 definition to find it at runtime. Checked the basic tst-mmap and tst-mmap-offset on m68k (the system is configured with 4k, so current code is already passing on this system) and a sanity check on x86_64-linux-gnu (which should not be affected by this change). Sergei also states that ia64 loader now work correctly with this change. Adhemerval Zanella Sergei Trofimovich * sysdeps/unix/sysv/linux/m68k/mmap_internal.h (MMAP2_PAGE_SHIFT): Rename to MMAP2_PAGE_UNIT. * sysdeps/unix/sysv/linux/mmap.c: Include mmap_internal iff __OFF_T_MATCHES_OFF64_T is not defined. * sysdeps/unix/sysv/linux/mmap_internal.h (page_unit): Declare as uint64_t. (MMAP2_PAGE_UNIT) [MMAP2_PAGE_UNIT == -1]: Redefine to page_unit. (page_unit) [MMAP2_PAGE_UNIT != -1]: Remove definition. --- ChangeLog | 12 ++++++++++++ sysdeps/unix/sysv/linux/ia64/mmap_internal.h | 29 ++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/m68k/mmap_internal.h | 2 +- sysdeps/unix/sysv/linux/mmap.c | 2 +- sysdeps/unix/sysv/linux/mmap_internal.h | 6 +++--- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/ia64/mmap_internal.h -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/ia64/mmap_internal.h b/sysdeps/unix/sysv/linux/ia64/mmap_internal.h new file mode 100644 index 0000000..dbaaa3f --- /dev/null +++ b/sysdeps/unix/sysv/linux/ia64/mmap_internal.h @@ -0,0 +1,29 @@ +/* Common mmap definition for Linux implementation. Linux/ia64 version. + Copyright (C) 2017 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 + . */ + +#ifndef MMAP_IA64_INTERNAL_LINUX_H +#define MMAP_IA64_INTERNAL_LINUX_H + +/* Linux allows PAGE_SHIFT in range of [12-16] and expect + mmap2 offset to be provided in based on the configured pagesize. + Determine the shift dynamically with getpagesize. */ +#define MMAP2_PAGE_UNIT -1 + +#include_next + +#endif diff --git a/sysdeps/unix/sysv/linux/m68k/mmap_internal.h b/sysdeps/unix/sysv/linux/m68k/mmap_internal.h index bd8bd38..9fe9d91 100644 --- a/sysdeps/unix/sysv/linux/m68k/mmap_internal.h +++ b/sysdeps/unix/sysv/linux/m68k/mmap_internal.h @@ -22,7 +22,7 @@ /* ColdFire and Sun 3 kernels have PAGE_SHIFT set to 13 and expect mmap2 offset to be provided in 8K pages. Determine the shift dynamically with getpagesize. */ -#define MMAP2_PAGE_SHIFT -1 +#define MMAP2_PAGE_UNIT -1 #include_next diff --git a/sysdeps/unix/sysv/linux/mmap.c b/sysdeps/unix/sysv/linux/mmap.c index 98c2f88..59292b6 100644 --- a/sysdeps/unix/sysv/linux/mmap.c +++ b/sysdeps/unix/sysv/linux/mmap.c @@ -21,9 +21,9 @@ #include #include #include -#include #ifndef __OFF_T_MATCHES_OFF64_T +# include /* An architecture may override this. */ # ifndef MMAP_ADJUST_OFFSET diff --git a/sysdeps/unix/sysv/linux/mmap_internal.h b/sysdeps/unix/sysv/linux/mmap_internal.h index 499e389..47c0991 100644 --- a/sysdeps/unix/sysv/linux/mmap_internal.h +++ b/sysdeps/unix/sysv/linux/mmap_internal.h @@ -27,13 +27,13 @@ #endif #if MMAP2_PAGE_UNIT == -1 -static int page_unit; - +static uint64_t page_unit; # define MMAP_CHECK_PAGE_UNIT() \ if (page_unit == 0) \ page_unit = __getpagesize (); +# undef MMAP2_PAGE_UNIT +# define MMAP2_PAGE_UNIT page_unit #else -# define page_unit MMAP2_PAGE_UNIT # define MMAP_CHECK_PAGE_UNIT() #endif