Commit 779c6bef authored by Anthony Liguori's avatar Anthony Liguori
Browse files

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: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 95533d5f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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));