aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2009-06-22 12:39:00 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-24 09:09:15 -0500
commit779c6befc03122c819d2f81a2052fac6a4a43536 (patch)
tree663d324d4a3635558ac8efd2c113d70330cfcc81
parent95533d5ffbdf3f45e8daa64477b63cf771376618 (diff)
Make sure to zero out memory before calling madvise to increase robustness
Avi pointed out that it's not entirely safe to rely on madvise zeroing out memory. So let's do it explicitly before calling madvise. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--vl.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/vl.c b/vl.c
index 60a00e1b25..1c077b4c86 100644
--- a/vl.c
+++ b/vl.c
@@ -3358,13 +3358,13 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
if (flags & RAM_SAVE_FLAG_COMPRESS) {
uint8_t ch = qemu_get_byte(f);
-#if defined(__linux__)
+ memset(qemu_get_ram_ptr(addr), ch, TARGET_PAGE_SIZE);
+#ifndef _WIN32
if (ch == 0 &&
(!kvm_enabled() || kvm_has_sync_mmu())) {
madvise(qemu_get_ram_ptr(addr), TARGET_PAGE_SIZE, MADV_DONTNEED);
- } else
+ }
#endif
- memset(qemu_get_ram_ptr(addr), ch, TARGET_PAGE_SIZE);
} else if (flags & RAM_SAVE_FLAG_PAGE)
qemu_get_buffer(f, qemu_get_ram_ptr(addr), TARGET_PAGE_SIZE);
} while (!(flags & RAM_SAVE_FLAG_EOS));