From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753855AbdLFIG6 convert rfc822-to-8bit (ORCPT ); Wed, 6 Dec 2017 03:06:58 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:15084 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023AbdLFIGx (ORCPT ); Wed, 6 Dec 2017 03:06:53 -0500 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 06 Dec 2017 00:06:53 -0800 Subject: Re: [PATCH 0/2] mm: introduce MAP_FIXED_SAFE To: Florian Weimer , Matthew Wilcox , Michael Ellerman CC: Cyril Hrubis , Michal Hocko , Kees Cook , Linux API , Khalid Aziz , Andrew Morton , Russell King - ARM Linux , Andrea Arcangeli , Linux-MM , LKML , linux-arch , Abdul Haleem , Joel Stanley References: <20171129144219.22867-1-mhocko@kernel.org> <20171130065835.dbw4ajh5q5whikhf@dhcp22.suse.cz> <20171201152640.GA3765@rei> <87wp20e9wf.fsf@concordia.ellerman.id.au> <20171206045433.GQ26021@bombadil.infradead.org> <20171206070355.GA32044@bombadil.infradead.org> <5f4fc834-274a-b8f1-bda0-5bcddc5902ed@nvidia.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: <27ee1755-76d8-f086-5760-9c973b31108a@nvidia.com> Date: Wed, 6 Dec 2017 00:06:52 -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: X-Originating-IP: [10.2.170.2] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/05/2017 11:35 PM, Florian Weimer wrote: > On 12/06/2017 08:33 AM, John Hubbard wrote: >> In that case, maybe: >> >>      MAP_EXACT >> >> ? ...because that's the characteristic behavior. > > Is that true?  mmap still silently rounding up the length to the page size, I assume, so even that name is misleading. Hi Florian, Not as far as I can tell, it's not doing that. For both MAP_FIXED, and this new flag, the documented (and actual) behavior is *not* to do any such rounding. Instead, the requested input address is required to be page-aligned itself, and mmap() should be honoring the exact addr. >>From the mmap(2) man page: MAP_FIXED Don't interpret addr as a hint: place the mapping at exactly that address. addr must be a multiple of the page size. And from what I can see, the do_mmap() implementation leaves addr unchanged, in the MAP_FIXED case: do_mmap(...) { /* ... */ if (!(flags & MAP_FIXED)) addr = round_hint_to_min(addr); ...although it does look like device drivers have the opportunity to break that: mmap_region(...) { /* Can addr have changed?? * * Answer: Yes, several device drivers can do it in their * f_op->mmap method. -DaveM * Bug: If addr is changed, prev, rb_link, rb_parent should * be updated for vma_link() */ WARN_ON_ONCE(addr != vma->vm_start); addr = vma->vm_start; -- thanks, John Hubbard NVIDIA > > Thanks, > Florian From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hubbard Subject: Re: [PATCH 0/2] mm: introduce MAP_FIXED_SAFE Date: Wed, 6 Dec 2017 00:06:52 -0800 Message-ID: <27ee1755-76d8-f086-5760-9c973b31108a@nvidia.com> References: <20171129144219.22867-1-mhocko@kernel.org> <20171130065835.dbw4ajh5q5whikhf@dhcp22.suse.cz> <20171201152640.GA3765@rei> <87wp20e9wf.fsf@concordia.ellerman.id.au> <20171206045433.GQ26021@bombadil.infradead.org> <20171206070355.GA32044@bombadil.infradead.org> <5f4fc834-274a-b8f1-bda0-5bcddc5902ed@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Language: en-US Sender: owner-linux-mm@kvack.org To: Florian Weimer , Matthew Wilcox , Michael Ellerman Cc: Cyril Hrubis , Michal Hocko , Kees Cook , Linux API , Khalid Aziz , Andrew Morton , Russell King - ARM Linux , Andrea Arcangeli , Linux-MM , LKML , linux-arch , Abdul Haleem , Joel Stanley List-Id: linux-api@vger.kernel.org On 12/05/2017 11:35 PM, Florian Weimer wrote: > On 12/06/2017 08:33 AM, John Hubbard wrote: >> In that case, maybe: >> >> =C2=A0=C2=A0=C2=A0=C2=A0 MAP_EXACT >> >> ? ...because that's the characteristic behavior. >=20 > Is that true?=C2=A0 mmap still silently rounding up the length to the pag= e size, I assume, so even that name is misleading. Hi Florian, Not as far as I can tell, it's not doing that. For both MAP_FIXED, and this new flag, the documented (and actual) behavior is *not* to do any such rounding. Instead, the requested input address is required to be page-aligned itself, and mmap() should be honoring the exact addr. >>From the mmap(2) man page: MAP_FIXED Don't interpret addr as a hint: place the mapping at exactly that address. addr must be a multiple of the page size.=20 And from what I can see, the do_mmap() implementation leaves addr unchanged, in the MAP_FIXED case: do_mmap(...) { /* ... */ if (!(flags & MAP_FIXED)) addr =3D round_hint_to_min(addr); ...although it does look like device drivers have the opportunity to break that: mmap_region(...) { /* Can addr have changed?? * * Answer: Yes, several device drivers can do it in their * f_op->mmap method. -DaveM * Bug: If addr is changed, prev, rb_link, rb_parent should * be updated for vma_link() */ WARN_ON_ONCE(addr !=3D vma->vm_start); addr =3D vma->vm_start; =20 -- thanks, John Hubbard NVIDIA >=20 > Thanks, > Florian -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hubbard Subject: Re: [PATCH 0/2] mm: introduce MAP_FIXED_SAFE Date: Wed, 6 Dec 2017 00:06:52 -0800 Message-ID: <27ee1755-76d8-f086-5760-9c973b31108a@nvidia.com> References: <20171129144219.22867-1-mhocko@kernel.org> <20171130065835.dbw4ajh5q5whikhf@dhcp22.suse.cz> <20171201152640.GA3765@rei> <87wp20e9wf.fsf@concordia.ellerman.id.au> <20171206045433.GQ26021@bombadil.infradead.org> <20171206070355.GA32044@bombadil.infradead.org> <5f4fc834-274a-b8f1-bda0-5bcddc5902ed@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Language: en-US Sender: owner-linux-mm@kvack.org To: Florian Weimer , Matthew Wilcox , Michael Ellerman Cc: Cyril Hrubis , Michal Hocko , Kees Cook , Linux API , Khalid Aziz , Andrew Morton , Russell King - ARM Linux , Andrea Arcangeli , Linux-MM , LKML , linux-arch , Abdul Haleem , Joel Stanley List-Id: linux-arch.vger.kernel.org On 12/05/2017 11:35 PM, Florian Weimer wrote: > On 12/06/2017 08:33 AM, John Hubbard wrote: >> In that case, maybe: >> >> =C2=A0=C2=A0=C2=A0=C2=A0 MAP_EXACT >> >> ? ...because that's the characteristic behavior. >=20 > Is that true?=C2=A0 mmap still silently rounding up the length to the pag= e size, I assume, so even that name is misleading. Hi Florian, Not as far as I can tell, it's not doing that. For both MAP_FIXED, and this new flag, the documented (and actual) behavior is *not* to do any such rounding. Instead, the requested input address is required to be page-aligned itself, and mmap() should be honoring the exact addr. >From the mmap(2) man page: MAP_FIXED Don't interpret addr as a hint: place the mapping at exactly that address. addr must be a multiple of the page size.=20 And from what I can see, the do_mmap() implementation leaves addr unchanged, in the MAP_FIXED case: do_mmap(...) { /* ... */ if (!(flags & MAP_FIXED)) addr =3D round_hint_to_min(addr); ...although it does look like device drivers have the opportunity to break that: mmap_region(...) { /* Can addr have changed?? * * Answer: Yes, several device drivers can do it in their * f_op->mmap method. -DaveM * Bug: If addr is changed, prev, rb_link, rb_parent should * be updated for vma_link() */ WARN_ON_ONCE(addr !=3D vma->vm_start); addr =3D vma->vm_start; =20 -- thanks, John Hubbard NVIDIA >=20 > Thanks, > Florian -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hqemgate14.nvidia.com ([216.228.121.143]:15084 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023AbdLFIGx (ORCPT ); Wed, 6 Dec 2017 03:06:53 -0500 Subject: Re: [PATCH 0/2] mm: introduce MAP_FIXED_SAFE References: <20171129144219.22867-1-mhocko@kernel.org> <20171130065835.dbw4ajh5q5whikhf@dhcp22.suse.cz> <20171201152640.GA3765@rei> <87wp20e9wf.fsf@concordia.ellerman.id.au> <20171206045433.GQ26021@bombadil.infradead.org> <20171206070355.GA32044@bombadil.infradead.org> <5f4fc834-274a-b8f1-bda0-5bcddc5902ed@nvidia.com> From: John Hubbard Message-ID: <27ee1755-76d8-f086-5760-9c973b31108a@nvidia.com> Date: Wed, 6 Dec 2017 00:06:52 -0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8BIT Sender: linux-arch-owner@vger.kernel.org List-ID: To: Florian Weimer , Matthew Wilcox , Michael Ellerman Cc: Cyril Hrubis , Michal Hocko , Kees Cook , Linux API , Khalid Aziz , Andrew Morton , Russell King - ARM Linux , Andrea Arcangeli , Linux-MM , LKML , linux-arch , Abdul Haleem , Joel Stanley Message-ID: <20171206080652.qGL5RsipZYzQDEMX6wS78Am-gDkXxcRtJ2TbEXbkiPE@z> On 12/05/2017 11:35 PM, Florian Weimer wrote: > On 12/06/2017 08:33 AM, John Hubbard wrote: >> In that case, maybe: >> >>      MAP_EXACT >> >> ? ...because that's the characteristic behavior. > > Is that true?  mmap still silently rounding up the length to the page size, I assume, so even that name is misleading. Hi Florian, Not as far as I can tell, it's not doing that. For both MAP_FIXED, and this new flag, the documented (and actual) behavior is *not* to do any such rounding. Instead, the requested input address is required to be page-aligned itself, and mmap() should be honoring the exact addr.