From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969AbdGKOBg (ORCPT ); Tue, 11 Jul 2017 10:01:36 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:25019 "EHLO imgpgp01.kl.imgtec.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755863AbdGKOBf (ORCPT ); Tue, 11 Jul 2017 10:01:35 -0400 X-PGP-Universal: processed; by imgpgp01.kl.imgtec.org on Tue, 11 Jul 2017 16:12:11 +0100 Date: Tue, 11 Jul 2017 15:01:32 +0100 From: James Hogan To: Christoph Hellwig CC: Palmer Dabbelt , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH 16/17] RISC-V: User-facing API Message-ID: <20170711140132.GP6973@jhogan-linux.le.imgtec.org> References: <20170711013924.22085-1-palmer@dabbelt.com> <20170711013924.22085-17-palmer@dabbelt.com> <20170711133948.GA26995@infradead.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WmbeDIqooxy+l+0t" Content-Disposition: inline In-Reply-To: <20170711133948.GA26995@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [192.168.154.110] X-ESG-ENCRYPT-TAG: 1b7d744b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --WmbeDIqooxy+l+0t Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Christoph, On Tue, Jul 11, 2017 at 06:39:48AM -0700, Christoph Hellwig wrote: > > +#ifdef CONFIG_64BIT > > +SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, > > + unsigned long, prot, unsigned long, flags, > > + unsigned long, fd, off_t, offset) > > +{ > > + if (unlikely(offset & (~PAGE_MASK))) > > + return -EINVAL; > > + return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIF= T); > > +} > > +#else > > +SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, > > + unsigned long, prot, unsigned long, flags, > > + unsigned long, fd, off_t, offset) > > +{ > > + /* > > + * Note that the shift for mmap2 is constant (12), > > + * regardless of PAGE_SIZE > > + */ > > + if (unlikely(offset & (~PAGE_MASK >> 12))) > > + return -EINVAL; > > + return sys_mmap_pgoff(addr, len, prot, flags, fd, > > + offset >> (PAGE_SHIFT - 12)); > > +} > > +#endif /* !CONFIG_64BIT */ >=20 > Most modern ports seem to expose sys_mmap_pgoff as the > syscall directly. Any reason you're doing this differently? I think Palmer's patch is probably correct here. Exposing sys_mmap_pgoff is only really correct on 32-bit arches where the only page size is 4k. If other page sizes are supported then this is the correct way to handle it as the page offset from 32-bit userland is supposed to be in 4k units. 64-bit doesn't need to worry about squeezing big file offsets into the off_t offset so don't need to do the shift at all. See the mmap2 man page. It says "the final argument specifies the offset into the file in 4096-byte units", and it points out ia64 as an exception where it depends on the page size of the system. >=20 > But even the code for the older ones should probably be consolidated.. Quite probably, yes. Cheers James --WmbeDIqooxy+l+0t Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd80NauSabkiESfLYbAtpk944dnoFAllk2jQACgkQbAtpk944 dnrCNw//YaPBSKkvBhlbNb1Xx1dORfWzNfUMsnwSAC+TGEQau3bPE5wCPBqaS0Uh mmyUjRqFnpjROeemTbF1FCgZP+0y6cmrm42o4wY8gP0W0B9n1ZxxcyxqO/Tne7iO qplAHEnSfBe4MVOKCwCG1z6EY3KZ+gYFvrjPx93MB3BUwAjDFurUTAVq9BhHlLIU QMeedJKd/EG6pHAjdu3JxWbnnVf81pES6XQZpEetK+8aaFcCH0M4WE2SE3YYbJqj Ocrza1PhpnPjApRLJUM70IjQvAvDFvyJ5F3Pzsfmf2cHKLuPksKBfbdl+7IkJWHx Ep6g7dojSUdSZE0jO5RruOJfxPupBdjzRRxQOabuLnAA2h/5+uW5RhATtdAqsXVw UH0WTA++F051So18IpA97wvIKmkApDZ3oj0n0aJ5wnD6VOQBf4gVqZtxm0P6fbc0 AQz7i32kkF3QvHKaRvVu8E+qq0GLMP1IFWJfevitVlHopWGJIyNbYlSeEhBy+tZ1 VHNVg8WucGImHTjXF5es7SK+7vQWxmxpPbAu222N6PY+fSJgfjmlVCUWN6O+yrj3 VUncMRI4+G2QcCXvvXVDSDiRSWu488zuoAzqVyKAJHWYuFJ/BPZd3RD6lhHztEgc k1oB8AIJM/gm4N4OCcKK1qV4pznjHxEl7LPMNxespfIvhYQX9FI= =sc5Y -----END PGP SIGNATURE----- --WmbeDIqooxy+l+0t--