From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MInse-0001HS-JJ for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:04:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MInsa-0001Ge-40 for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:04:32 -0400 Received: from [199.232.76.173] (port=41074 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MInsZ-0001GQ-Tm for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:04:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59940) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MInsY-0004XF-Ar for qemu-devel@nongnu.org; Mon, 22 Jun 2009 14:04:26 -0400 Message-ID: <4A3FC7B2.20503@redhat.com> Date: Mon, 22 Jun 2009 21:04:34 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [Qemu-commits] [COMMIT 3086844] Instead of writing a zero page, madvise it away References: <200906221549.n5MFn3Qd015389@d03av02.boulder.ibm.com> <4A3FAD69.60507@redhat.com> <4A3FB077.4040607@codemonkey.ws> <4A3FB390.4060809@redhat.com> <4A3FB95D.3060404@us.ibm.com> <4A3FBD61.8030109@redhat.com> <4A3FC30E.5030804@us.ibm.com> In-Reply-To: <4A3FC30E.5030804@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel On 06/22/2009 08:44 PM, Anthony Liguori wrote: > See attached. > Author: Anthony Liguori > Date: Mon Jun 22 12:39:00 2009 -0500 > > 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 > > diff --git a/vl.c b/vl.c > index 60a00e1..1c077b4 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)); > Pretty similar to my December patch... which had another case, is it missing? http://article.gmane.org/gmane.comp.emulators.qemu/34523 -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.