All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <chengang@emindsoft.com.cn>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Riku Voipio <riku.voipio@iki.fi>,
	Laurent Vivier <laurent@vivier.eu>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] linux-user/mmap.c: Set prot page flags for the correct region in mmap_frag()
Date: Wed, 27 Jan 2016 09:37:44 +0800	[thread overview]
Message-ID: <56A81F68.2050706@emindsoft.com.cn> (raw)
In-Reply-To: <CAFEAcA-cHT0skfZGc901L1w+_BE79Wv8DkwTU6RmnfPiTt7r+Q@mail.gmail.com>



On 2016年01月26日 18:26, Peter Maydell wrote:
> On 26 January 2016 at 10:19, Chen Gang <chengang@emindsoft.com.cn> wrote:
>> When I run WeChat.exe with i386 wine with qemu-i386 under sw_64 arch.
>>
>>  - The related command:
>>
>>    "./i386-linux-user/qemu-i386 -strace -L /upstream/i386_wine /upstream/i386_wine/usr/local/bin/wine "C:\\Program Files\\Tencent\\WeChat\\WeChat.exe" > ana/try/info-strace.log 2>&1"
>>
>>  - The related output (no any munmap, 135168 = 128KB + 4KB):
>>
>>    4600 mmap2(0x00340000,135168,PROT_READ,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0) = 0x00340000
>>    4600 mmap2(0x00340000,135168,PROT_READ,MAP_SHARED|MAP_FIXED,8,0) = 0x00340000
>>    4600 rt_sigprocmask(SIG_SETMASK,0x0033f574,NULL) = 0
>>    4600 rt_sigprocmask(SIG_BLOCK,0x7bced7e0,0x0033f5d0) = 0
>>    4600 write(3,0x33f6cc,64) = 64
>>    4600 read(4,0x33f6cc,64) = 1
>>    4600 rt_sigprocmask(SIG_SETMASK,0x0033f5d0,NULL) = 0
>>    4600 close(8) = 0
>>    4600 rt_sigprocmask(SIG_BLOCK,0x7bced7e0,0x0033f674) = 0
>>    4600 mprotect(0x00160000,65536,PROT_READ|PROT_WRITE) = 0
>>    4600 rt_sigprocmask(SIG_SETMASK,0x0033f674,NULL) = 0
>>    4600 rt_sigprocmask(SIG_BLOCK,0x7bced7e0,0x0033f990) = 0
>>    4600 mmap2(0x00340000,135168,PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED|MAP_NORESERVE,-1,0) = 0x00340000
>>
>> wine often does like above, map the same position multiple times.
> 
> That output seems to show all the mmap calls working fine, though.
>

OK, thanks.
 
>>
>> For the case I provide above, it can call mmap_frag() twice for the same
>> host page.
> 
> For the same single call to target_mmap() ? What is the code flow
> within QEMU that causes this?
> 

Within one single call to target_mmap(), it should be OK.

But multiple call to target_mmap(), may call mmap_frag() multiple times
for the same host page (also for the same target page). In our case:

 - 4600 mmap2(0x00340000,135168,PROT_READ,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0) = 0x00340000

   It will call mmap_frag() with start address 0x00340000 + 128KB, and
   set the target page with PAGE_VALID. But left the half below host
   page without PAGE_VALID.

 - 4600 mmap2(0x00340000,135168,PROT_READ,MAP_SHARED|MAP_FIXED,8,0) = 0x00340000

   It will call mmap_frag() with start address 0x00340000 + 128KB, and
   check the half below host page which has no PAGE_VALID, then "prot1
   == 0", mmap_frag() thinks "no page was there, so we allocate one".

 - But in fact, the first mmap_frag() has already allocated one page at
   0x00340000 + 128KB.

Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

  reply	other threads:[~2016-01-27  1:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11  9:01 [Qemu-devel] [PATCH v2 1/3] linux-user/mmap.c: Set prot page flags for the correct region in mmap_frag() chengang
2016-01-11  9:01 ` [Qemu-devel] [PATCH v2 2/3] linux-user/mmap.c: Remove useless variable p for mmap_frag chengang
2016-01-11  9:01 ` [Qemu-devel] [PATCH v2 3/3] linux-user/mmap.c: Use TARGET_PAGE_SIZE as the increasing step chengang
2016-01-25 15:07 ` [Qemu-devel] [PATCH v2 1/3] linux-user/mmap.c: Set prot page flags for the correct region in mmap_frag() Peter Maydell
2016-01-26  2:58   ` Chen Gang
2016-01-26  9:11     ` Peter Maydell
2016-01-26 10:19       ` Chen Gang
2016-01-26 10:26         ` Peter Maydell
2016-01-27  1:37           ` Chen Gang [this message]
2016-01-28 14:54             ` Peter Maydell
2016-01-29  1:40               ` Chen Gang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56A81F68.2050706@emindsoft.com.cn \
    --to=chengang@emindsoft.com.cn \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.