From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpVpy-0005uK-2J for barebox@lists.infradead.org; Fri, 01 Feb 2019 10:14:19 +0000 Received: by mail-lf1-x143.google.com with SMTP id x201so3326605lff.10 for ; Fri, 01 Feb 2019 02:14:16 -0800 (PST) Date: Fri, 1 Feb 2019 13:14:09 +0300 From: Peter Mamonov Message-ID: <20190201101408.dj66i7lsfceteve5@localhost.localdomain> References: <20190129065549.29161-1-andrew.smirnov@gmail.com> <20190129065549.29161-19-andrew.smirnov@gmail.com> <20190129084847.spkfbeksb7xne46g@pengutronix.de> <20190131105452.smetw36klsxmvtaq@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH v2 18/19] drivers: mem: Create file to access second half of 64-bit memory To: Andrey Smirnov Cc: Barebox List On Thu, Jan 31, 2019 at 12:17:08PM -0800, Andrey Smirnov wrote: > On Thu, Jan 31, 2019 at 2:55 AM Peter Mamonov wrote: > > > > Hello, Andrey, > > > > > In order to allow access to second half of address space on 64-bit > > > machines, add code that creates /dev/highmem dedicated for that. > > > > > > Note that due to maximum file size being limited to MAX_LFS_FILESIZE > > > or 0x7fff_ffff_ffff_ffff bytes at addresses 0x7fff_ffff_ffff_ffff and > > > 0xffff_ffff_ffff_ffff cannot be access through /dev/mem and > > > /dev/hightmem correspondingly. > > > > Does it imply using `-s /dev/highmem` argument when accessing addresses beyond > > MAX_LFS_FILESIZE? > > Yes, it does. > > > That's not very convenient: > > > > $ git grep -l /dev/mem > > commands/crc.c > > commands/digest.c > > commands/disasm.c > > commands/md.c > > commands/memcmp.c > > commands/memcpy.c > > commands/memset.c > > commands/mm.c > > commands/mw.c > > > > I don't disagree, but there isn't much that can be done about that > AFAICT. The first version of this fix kept single /dev/mem file, but > ended up introducing quite a bit of special cases all over the FS > layer, so it was rejected. The only two options to make it more > convenient that I can see would be to either modify "/dev/mem" users > to make "/dev/highmem" substitution automatically based on offset they > are given, or, assuming it is possible, create a mapping that would > expose all of the interesting registers on MIPS64 in the lower half of > 64-bit address space. Guess we can just adopt Linux's approach. Linux recognizes /dev/mem's lseek as a special case and has a dedicated implementation for it. Here is a relevant comment from drivers/char/mem.c: /* * The memory devices use the full 32/64 bits of the offset, and so we cannot * check against negative addresses: they are ok. The return value is weird, * though, in that case (0). * * also note that seeking relative to the "end of file" isn't supported: * it has no meaning, so it returns -EINVAL. */ static loff_t memory_lseek(struct file *file, loff_t offset, int orig) { Regards, Peter _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox