From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
KVM list <kvm@vger.kernel.org>
Subject: Re: [PATCH v2 1/10] KVM: MMU: fix writable sync sp mapping
Date: Mon, 28 Jun 2010 17:40:42 +0800 [thread overview]
Message-ID: <4C286E1A.7070003@cn.fujitsu.com> (raw)
In-Reply-To: <4C2868C9.8040302@redhat.com>
Avi Kivity wrote:
>>
>> for_each_gfn_indirect_valid_sp(vcpu->kvm, s, gfn, node) {
>> + if (!can_unsync)
>> + return 1;
>> +
>>
>
> What if the page is already unsync? We don't need write protection in
> this case.
Avi,
The reason is when we sync children sps, we write-protected for all sps first,
list relevant code:
| static void mmu_sync_children(...)
| {
| ......
| for_each_sp(pages, sp, parents, i)
| protected |= rmap_write_protect(vcpu->kvm, sp->gfn); <==== A
|
| if (protected)
| kvm_flush_remote_tlbs(vcpu->kvm);
|
| for_each_sp(pages, sp, parents, i) {
| kvm_sync_page(vcpu, sp, &invalid_list); <==== B
| mmu_pages_clear_parents(&parents);
| }
| ......
|}
For example:
SP1.pte[0] = P
SP2.gfn's pfn = P
[SP1.pte[0] = SP2.gfn's pfn]
At A point, SP1.gfn and SP2.gfn are write-protected.
At B point, if sync SP1 first, while it's synced. it will detect SP1.pte[0].gfn only has one unsync-sp,
that is SP2, so it will mapping it writable, then we sync SP2, we will set SP2 to sync page.
The final result is: SP2 is the sync page but SP2.gfn is writable.
Note: we not do write-protected in kvm_sync_page() anymore after commit: 95b4b26cfc
next prev parent reply other threads:[~2010-06-28 9:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-25 12:05 [PATCH v2 1/10] KVM: MMU: fix writable sync sp mapping Xiao Guangrong
2010-06-27 7:59 ` Xiao Guangrong
2010-06-28 9:18 ` Avi Kivity
2010-06-28 9:40 ` Xiao Guangrong [this message]
2010-06-28 11:41 ` Avi Kivity
2010-06-29 1:19 ` Xiao Guangrong
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=4C286E1A.7070003@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox