Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752321AbdLECO0 (ORCPT ); Mon, 4 Dec 2017 21:14:26 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:6323 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbdLECOT (ORCPT ); Mon, 4 Dec 2017 21:14:19 -0500 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 04 Dec 2017 18:15:02 -0800 Subject: Re: [PATCH v2] mmap.2: MAP_FIXED updated documentation To: Cyril Hrubis CC: Michael Kerrisk , linux-man , , Michael Ellerman , , LKML , , Jann Horn , Matthew Wilcox , Michal Hocko References: <20171204021411.4786-1-jhubbard@nvidia.com> <20171204105549.GA31332@rei> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Mon, 4 Dec 2017 18:14:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171204105549.GA31332@rei> X-Originating-IP: [10.110.48.28] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1614 Lines: 48 On 12/04/2017 02:55 AM, Cyril Hrubis wrote: > Hi! > I know that we are not touching the rest of the existing description for > MAP_FIXED however the second sentence in the manual page says that "addr > must be a multiple of the page size." Which however is misleading as > this is not enough on some architectures. Code in the wild seems to > (mis)use SHMLBA for aligment purposes but I'm not sure that we should > advise something like that in the manpages. > > So what about something as: > > "addr must be suitably aligned, for most architectures multiple of page > size is sufficient, however some may impose additional restrictions for > page mapping addresses." > Hi Cyril, Right, so I've been looking into this today, and I think we can go a bit further than that, even. The kernel, as far back as the *original* git commit in 2005, implements mmap on ARM by requiring that the address is aligned to SHMLBA: arch/arm/mm/mmap.c:50: if (flags & MAP_FIXED) { if (aliasing && flags & MAP_SHARED && (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) return -EINVAL; return addr; } So, given that this has been the implementation for the last 12+ years (and probably the whole time, in fact), I think we can be bold enough to use this wording for the second sentence of MAP_FIXED: "addr must be a multiple of SHMLBA (), which in turn is either the system page size (on many architectures) or a multiple of the system page size (on some architectures)." What do you think? thanks, John Hubbard NVIDIA > Which should at least hint the reader that this is architecture specific. >