exec.c: Fix off-by-one error in register_subpage
authorTyler Hall <tylerwhall@gmail.com>
Wed, 25 Jul 2012 22:45:03 +0000 (18:45 -0400)
committerEvgeny Voevodin <e.voevodin@samsung.com>
Mon, 20 Aug 2012 12:50:23 +0000 (16:50 +0400)
subpage_register() expects "end" to be the last byte in the mapping.
Registering a non-page-aligned memory region that extends up to or
beyond a page boundary causes subpage_register() to silently fail
through the (end >= PAGE_SIZE) check.

This bug does not cause noticeable problems for mappings that do not
extend to a page boundary, though they do register an extra byte.

Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
exec.c

diff --git a/exec.c b/exec.c
index d161ed175b6ddab07a82018d11b21e3d38fc88d8..23606a81d43af29975d43a935d3ac2a9426da54e 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -2380,7 +2380,7 @@ static void register_subpage(MemoryRegionSection *section)
         subpage = container_of(existing->mr, subpage_t, iomem);
     }
     start = section->offset_within_address_space & ~TARGET_PAGE_MASK;
-    end = start + section->size;
+    end = start + section->size - 1;
     subpage_register(subpage, start, end, phys_section_add(section));
 }