From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYMV-0005BV-HG for qemu-devel@nongnu.org; Mon, 11 Jan 2016 04:02:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIYMQ-0005Mj-38 for qemu-devel@nongnu.org; Mon, 11 Jan 2016 04:02:03 -0500 Received: from out1134-251.mail.aliyun.com ([42.120.134.251]:45767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYMP-0005Md-Jd for qemu-devel@nongnu.org; Mon, 11 Jan 2016 04:01:58 -0500 From: chengang@emindsoft.com.cn Date: Mon, 11 Jan 2016 17:01:05 +0800 Message-Id: <1452502867-12148-1-git-send-email-chengang@emindsoft.com.cn> Subject: [Qemu-devel] [PATCH v2 1/3] linux-user/mmap.c: Set prot page flags for the correct region in mmap_frag() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: riku.voipio@iki.fi, laurent@vivier.eu Cc: peter.maydell@linaro.org, Chen Gang , Chen Gang , qemu-devel@nongnu.org, rth@twiddle.net From: Chen Gang mmap() size in mmap_frag() is qemu_host_page_size, but the outside calls page_set_flags() may be not with qemu_host_page_size. So after mmap(), call page_set_flags() in time. After this fix, for the next call for the same region, prot1 will be PAGE_VALID (not 0), so can avoid to enter "if (prot1 == 0)" case, again. Signed-off-by: Chen Gang --- linux-user/mmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 445e8c6..7807ed0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -162,6 +162,8 @@ static int mmap_frag(abi_ulong real_start, flags | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) return -1; + page_set_flags(real_start, real_start + qemu_host_page_size, + PAGE_VALID); prot1 = prot; } prot1 &= PAGE_BITS; -- 1.9.1