]> Git Repo - qemu.git/commitdiff
exec.c: Use subpages for large unaligned mappings
authorTyler Hall <[email protected]>
Wed, 25 Jul 2012 22:45:04 +0000 (18:45 -0400)
committerStefan Hajnoczi <[email protected]>
Fri, 3 Aug 2012 13:25:22 +0000 (14:25 +0100)
Registering a multi-page memory region that is non-page-aligned results
in a subpage from the start to the page boundary, some number of full
pages, and possibly another subpage from the last page boundary to the
end. The full pages will have a value for offset_within_region that is
not a multiple of TARGET_PAGE_SIZE. Accesses through softmmu are unable
to handle this and will segfault.

Handling full pages through subpages is not optimal, but only
non-page-aligned mappings take the penalty.

Signed-off-by: Tyler Hall <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Avi Kivity <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
exec.c

diff --git a/exec.c b/exec.c
index 27b100cb2373cd5543a1ac9096d67b0d8714fb3f..e6ac3e70650cd01e71ccf7d8d8d6d078173e652b 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -2305,10 +2305,15 @@ void cpu_register_physical_memory_log(MemoryRegionSection *section,
         remain.offset_within_address_space += now.size;
         remain.offset_within_region += now.size;
     }
-    now = remain;
-    now.size &= TARGET_PAGE_MASK;
-    if (now.size) {
-        register_multipage(&now);
+    while (remain.size >= TARGET_PAGE_SIZE) {
+        now = remain;
+        if (remain.offset_within_region & ~TARGET_PAGE_MASK) {
+            now.size = TARGET_PAGE_SIZE;
+            register_subpage(&now);
+        } else {
+            now.size &= TARGET_PAGE_MASK;
+            register_multipage(&now);
+        }
         remain.size -= now.size;
         remain.offset_within_address_space += now.size;
         remain.offset_within_region += now.size;
This page took 0.027981 seconds and 4 git commands to generate.