From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54669 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PutWy-00048X-R7 for qemu-devel@nongnu.org; Wed, 02 Mar 2011 16:24:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PutWx-0001Mu-Ke for qemu-devel@nongnu.org; Wed, 02 Mar 2011 16:24:24 -0500 Received: from smtp-out.google.com ([74.125.121.67]:7433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PutWx-0001Mp-DT for qemu-devel@nongnu.org; Wed, 02 Mar 2011 16:24:23 -0500 From: Vincent Palatin Date: Wed, 2 Mar 2011 16:23:57 -0500 Message-Id: <1299101037-14925-1-git-send-email-vpalatin@chromium.org> In-Reply-To: References: Subject: [Qemu-devel] [PATCH] fix offset for MMIO subpage access List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Salvatore Lionetti , Vincent Palatin When using a MMIO subpage not starting on a page boundary, the offset value given to the access handler is based on the start of the MMU page not on the subpage base. As a consequence, if you are mapping the same subpage sized MMIO device at different addresses, this is somewhat impractical and confusing since the same register will be called with different "offset" depending on the base address. My proposal is to workaround this by recording the offset in region_offset field. Signed-off-by: Vincent Palatin --- exec.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/exec.c b/exec.c index d611100..b59e7c9 100644 --- a/exec.c +++ b/exec.c @@ -2626,6 +2626,7 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2, need_subpage); if (need_subpage) { + region_offset -= (start_addr & ~TARGET_PAGE_MASK); if (!(orig_memory & IO_MEM_SUBPAGE)) { subpage = subpage_init((addr & TARGET_PAGE_MASK), &p->phys_offset, orig_memory, @@ -2658,6 +2659,7 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, end_addr2, need_subpage); if (need_subpage) { + region_offset -= (start_addr & ~TARGET_PAGE_MASK); subpage = subpage_init((addr & TARGET_PAGE_MASK), &p->phys_offset, IO_MEM_UNASSIGNED, addr & TARGET_PAGE_MASK); -- 1.7.3.1