Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IYiZw-0004ns-Dl for qemu-devel@nongnu.org; Fri, 21 Sep 2007 09:29:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IYiZv-0004n5-Nc for qemu-devel@nongnu.org; Fri, 21 Sep 2007 09:29:56 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IYiZv-0004mn-Gb for qemu-devel@nongnu.org; Fri, 21 Sep 2007 09:29:55 -0400 Received: from miranda.se.axis.com ([193.13.178.8]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IYiZu-00085m-Uf for qemu-devel@nongnu.org; Fri, 21 Sep 2007 09:29:55 -0400 Received: from axis.com (edgar.se.axis.com [10.92.151.1]) by miranda.se.axis.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l8LDTlR4013182 for ; Fri, 21 Sep 2007 15:29:47 +0200 Date: Fri, 21 Sep 2007 15:29:47 +0200 From: "Edgar E. Iglesias" Message-ID: <20070921132947.GN20171@edgar.underground.se.axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] TARGET_PAGE_SIZE > host page size Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hello, I'm working on a new target port and the linux-user emulation is fairly functional and passing quite extensive test-suites. I've got a problem though, my target has 8K page sizes, so for example when running on a x86 host TARGET_PAGE_SIZE > host page size. I'm not very familiar with linux-user/mmap.c, but I though I'd let you know that with this patch things seem to be working fine for me. I am not sure if the patch is correct so if anyone with more experience sees an obvious flaw I'd appreciate to know. Thanks! Edgar E. Iglesias Axis Communications AB Index: linux-user/mmap.c =================================================================== RCS file: /sources/qemu/qemu/linux-user/mmap.c,v retrieving revision 1.14 diff -u -p -b -u -p -r1.14 mmap.c --- linux-user/mmap.c 17 Sep 2007 08:09:49 -0000 1.14 +++ linux-user/mmap.c 21 Sep 2007 13:24:42 -0000 @@ -209,26 +209,34 @@ long target_mmap(target_ulong start, tar last_start += HOST_PAGE_ALIGN(len); } #endif - if (0 && qemu_host_page_size != qemu_real_host_page_size) { + if (qemu_host_page_size != qemu_real_host_page_size) { /* NOTE: this code is only for debugging with '-p' option */ /* ??? Can also occur when TARGET_PAGE_SIZE > host page size. */ /* reserve a memory area */ /* ??? This needs fixing for remapping. */ -abort(); - host_len = HOST_PAGE_ALIGN(len) + qemu_host_page_size - TARGET_PAGE_SIZE; + + /* Make sure we have enough room for fixing up the buffer. */ + host_len = HOST_PAGE_ALIGN(len + TARGET_PAGE_SIZE); real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (real_start == -1) return real_start; real_end = real_start + host_len; - start = HOST_PAGE_ALIGN(real_start); - end = start + HOST_PAGE_ALIGN(len); + + /* Find start and end, aligned to the targets pagesize with-in the + mmaped area. */ + start = TARGET_PAGE_ALIGN(real_start); + end = start + TARGET_PAGE_ALIGN(len); + /* Chop off the leftovers, if any. */ if (start > real_start) munmap((void *)real_start, start - real_start); if (end < real_end) munmap((void *)end, real_end - end); /* use it as a fixed mapping */ flags |= MAP_FIXED; + /* These are now real. */ + real_start = start; + real_end = end; } else { /* if not fixed, no need to do anything */ host_offset = offset & qemu_host_page_mask;