From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyMJu-0005qg-JY for qemu-devel@nongnu.org; Tue, 20 Mar 2018 14:49:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyMJq-0006po-Jv for qemu-devel@nongnu.org; Tue, 20 Mar 2018 14:49:14 -0400 Received: from mav.lukeshu.com ([2001:19f0:5c00:8069:5400:ff:fe26:6a86]:40020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyMJq-0006n9-Gq for qemu-devel@nongnu.org; Tue, 20 Mar 2018 14:49:10 -0400 Date: Tue, 20 Mar 2018 14:49:01 -0400 Message-ID: <87tvtawpk2.wl-lukeshu@lukeshu.com> From: Luke Shumaker In-Reply-To: References: <20171228180814.9749-1-lukeshu@lukeshu.com> <20171228180814.9749-11-lukeshu@lukeshu.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH 10/10] linux-user: init_guest_space: Try to make ARM space+commpage continuous List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Luke Shumaker , Luke Shumaker , Riku Voipio , Laurent Vivier , QEMU Developers , Paul Brook On Fri, 02 Mar 2018 09:13:12 -0500, Peter Maydell wrote: > On 28 December 2017 at 18:08, Luke Shumaker wrote: > > + guest_full_size = > > + (0xffff0f00 & qemu_host_page_mask) + qemu_host_page_size; ^ > I think this is probably more clearly written as 0x100000000ULL, > since rounding down to the host-page-size then adding the host-page-size > gets us the full 32-bit size of the guest address space. Wait, is that right? Isn't that only true if qemu_host_page_size is at least 8KiB (16 bits), enough to fill the zero in the middle? Won't a typical qemu_host_page_size be only 4KiB? > That shows up that there's a potential problem here if the host > is 32-bit, because in that case guest_full_size (being only unsigned > long) will be 0, and we'll end up trying an mmap with an incorrect size. > > > + host_full_size = guest_full_size - guest_start; > > + real_start = (unsigned long) > > + mmap(NULL, host_full_size, PROT_NONE, flags, -1, 0); > > I think the general approach is right, though. Sorry it took so long > for us to get to reviewing this patchset. It's all good. I'm amazed at the amount of traffic qemu-devel gets! > Incidentally, this code would be rather less complicated if it didn't > have to account for qemu_host_page_size not actually being the host > page size (since then you couldn't get a return from mmap() that wasn't > aligned properly). Does anybody know why we allow the user to specify > it on the command line? (git revision history doesn't help, it just says > there's been a -pagesize argument since commit 54936004fddc5 in 2003, > right back when mmap emulation was first added...) I have no idea, I just assumed that it was a feature useful to people far smarter than me. -- Happy hacking, ~ Luke Shumaker