From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEcws-0007z7-I7 for qemu-devel@nongnu.org; Thu, 31 Dec 2015 08:07:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aEcwp-0005Wu-BG for qemu-devel@nongnu.org; Thu, 31 Dec 2015 08:07:22 -0500 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:33401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEcwp-0005Wk-4y for qemu-devel@nongnu.org; Thu, 31 Dec 2015 08:07:19 -0500 Received: by mail-pf0-x22e.google.com with SMTP id q63so120164999pfb.0 for ; Thu, 31 Dec 2015 05:07:18 -0800 (PST) Message-ID: <5685293C.2090909@gmail.com> Date: Thu, 31 Dec 2015 21:10:20 +0800 From: Chen Gang MIME-Version: 1.0 References: <1451437854-3708-1-git-send-email-chengang@emindsoft.com.cn> <56832FF5.1090002@vivier.eu> In-Reply-To: <56832FF5.1090002@vivier.eu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v3] linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in mmap_frag() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier , riku.voipio@iki.fi Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, rth@twiddle.net On 12/30/15 09:14, Laurent Vivier wrote: > > Le 30/12/2015 02:10, chengang@emindsoft.com.cn a écrit : >> From: Chen Gang >> >> When mapping MAP_ANONYMOUS memory fragments, still need notice about to >> set it zero, or it will cause issues. >> >> Signed-off-by: Chen Gang >> --- >> linux-user/mmap.c | 4 +++- >> 1 files changed, 3 insertions(+), 1 deletions(-) >> >> diff --git a/linux-user/mmap.c b/linux-user/mmap.c >> index 7b459d5..c6c478e 100644 >> --- a/linux-user/mmap.c >> +++ b/linux-user/mmap.c >> @@ -186,10 +186,12 @@ static int mmap_frag(abi_ulong real_start, >> if (prot_new != (prot1 | PROT_WRITE)) >> mprotect(host_start, qemu_host_page_size, prot_new); >> } else { >> - /* just update the protection */ >> if (prot_new != prot1) { >> mprotect(host_start, qemu_host_page_size, prot_new); >> } >> + if (prot_new & PROT_WRITE) { >> + memset(g2h(start), 0, end - start); >> + } >> } >> return 0; >> } >> > > Reviewed-by: Laurent Vivier > Thank you for your work. Happy New Year! :-) -- Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed