fix offset for MMIO subpage access

Message ID
State New
Headers show

Commit Message

Vincent Palatin March 2, 2011, 9:23 p.m.
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

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,
             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);