Il 04/02/2014 08:55, Alexander Graf ha scritto: >> With this change, the >> memory system is now refusing to allow an access of size >> 2 through, because it's greater than the region length. So > > Ouch. Yes, for ioport reads/writes we definitely have to only cap the port > range, not the length.
We can do it in general for MMIO. Something like this? diff --git a/exec.c b/exec.c index 9ad0a4b..9a1eef3 100644 --- a/exec.c +++ b/exec.c @@ -325,7 +325,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x hwaddr *plen, bool resolve_subpage) { MemoryRegionSection *section; - Int128 diff, diff_page; + Int128 diff; section = address_space_lookup_region(d, addr, resolve_subpage); /* Compute offset within MemoryRegionSection */ @@ -334,9 +334,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x /* Compute offset within MemoryRegion */ *xlat = addr + section->offset_within_region; - diff_page = int128_make64(((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr); diff = int128_sub(section->mr->size, int128_make64(addr)); - diff = int128_min(diff, diff_page); *plen = int128_get64(int128_min(diff, int128_make64(*plen))); return section; } @@ -370,6 +368,11 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr, as = iotlb.target_as; } + if (memory_access_is_direct(mr, is_write)) { + hwaddr page = (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE - addr; + len = MIN(page, len); + } + *plen = len; *xlat = addr; return mr; Stefano, Anthony, can you test it on Xen? I wouldn't mind sticking a "xen_enabled()" in there, and/or a comment to document why we do it. Paolo