qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/3] memory_region_init_ram_ptr: only allow n*TARGET


From: Igor Mitsyanko
Subject: [Qemu-devel] [PATCH 3/3] memory_region_init_ram_ptr: only allow n*TARGET_PAGE_SIZE memory sizes
Date: Sun, 10 Mar 2013 18:21:49 +0400

Registering memory regions using preallocated memory which size is not a 
multiple of
target page size will result in inconsistency in QEMU memory system. Do not
allow to do that at all by checking for that case (and asserting) in
memory_region_init_ram_ptr().

Signed-off-by: Igor Mitsyanko <address@hidden>
---
 include/exec/memory.h |    2 +-
 memory.c              |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 2322732..87b9292 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -279,7 +279,7 @@ void memory_region_init_ram(MemoryRegion *mr,
  *
  * @mr: the #MemoryRegion to be initialized.
  * @name: the name of the region.
- * @size: size of the region.
+ * @size: size of the region. Must be a multiple of target page size.
  * @ptr: memory to be mapped; must contain at least @size bytes.
  */
 void memory_region_init_ram_ptr(MemoryRegion *mr,
diff --git a/memory.c b/memory.c
index 92a2196..15cb47f 100644
--- a/memory.c
+++ b/memory.c
@@ -949,6 +949,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
                                 uint64_t size,
                                 void *ptr)
 {
+    assert((size & (TARGET_PAGE_SIZE - 1)) == 0);
     memory_region_init(mr, name, size);
     mr->ram = true;
     mr->terminates = true;
-- 
1.7.5.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]