]> git.proxmox.com Git - mirror_qemu.git/commitdiff
exec: clamp accesses against the MemoryRegionSection
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 17 Jun 2015 08:36:54 +0000 (10:36 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Jun 2015 10:27:14 +0000 (12:27 +0200)
Because the clamping was done against the MemoryRegion,
address_space_rw was effectively broken if a write spanned
multiple sections that are not linear in underlying memory
(with the memory not being under an IOMMU).

This is visible with the MIPS rc4030 IOMMU, which is implemented
as a series of alias memory regions that point to the actual RAM.

Tested-by: Hervé Poussineau <hpoussin@reactos.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c

diff --git a/exec.c b/exec.c
index d00e017e19e08dc699cacf4ff2fe95621c6d6b06..f7883d22469b61572b35e6ea7bfad1f22220b4bf 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -353,7 +353,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
 
     mr = section->mr;
     if (memory_region_is_ram(mr)) {
-        diff = int128_sub(mr->size, int128_make64(addr));
+        diff = int128_sub(section->size, int128_make64(addr));
         *plen = int128_get64(int128_min(diff, int128_make64(*plen)));
     }
     return section;