From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxFUA-0002Ui-Fn for qemu-devel@nongnu.org; Fri, 03 Aug 2012 06:52:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxFU8-0005tf-2V for qemu-devel@nongnu.org; Fri, 03 Aug 2012 06:52:02 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:55001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxFU7-0005tb-OX for qemu-devel@nongnu.org; Fri, 03 Aug 2012 06:51:59 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 3 Aug 2012 11:51:58 +0100 Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q73ApIw92527322 for ; Fri, 3 Aug 2012 11:51:18 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q73ApH2r023856 for ; Fri, 3 Aug 2012 04:51:18 -0600 From: Stefan Hajnoczi Date: Fri, 3 Aug 2012 11:51:05 +0100 Message-Id: <1343991066-9814-7-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1343991066-9814-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1343991066-9814-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 6/7] exec.c: Use subpages for large unaligned mappings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Tyler Hall From: Tyler Hall Registering a multi-page memory region that is non-page-aligned results in a subpage from the start to the page boundary, some number of full pages, and possibly another subpage from the last page boundary to the end. The full pages will have a value for offset_within_region that is not a multiple of TARGET_PAGE_SIZE. Accesses through softmmu are unable to handle this and will segfault. Handling full pages through subpages is not optimal, but only non-page-aligned mappings take the penalty. Signed-off-by: Tyler Hall Reviewed-by: Peter Maydell Reviewed-by: Avi Kivity Signed-off-by: Stefan Hajnoczi --- exec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index 27b100c..e6ac3e7 100644 --- a/exec.c +++ b/exec.c @@ -2305,10 +2305,15 @@ void cpu_register_physical_memory_log(MemoryRegionSection *section, remain.offset_within_address_space += now.size; remain.offset_within_region += now.size; } - now = remain; - now.size &= TARGET_PAGE_MASK; - if (now.size) { - register_multipage(&now); + while (remain.size >= TARGET_PAGE_SIZE) { + now = remain; + if (remain.offset_within_region & ~TARGET_PAGE_MASK) { + now.size = TARGET_PAGE_SIZE; + register_subpage(&now); + } else { + now.size &= TARGET_PAGE_MASK; + register_multipage(&now); + } remain.size -= now.size; remain.offset_within_address_space += now.size; remain.offset_within_region += now.size; -- 1.7.10.4