From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 4/7] KVM: MMU: don't mark pte notrap if it's just sync transient Date: Sat, 12 Jun 2010 10:38:17 +0800 Message-ID: <4C12F319.6010401@cn.fujitsu.com> References: <4C1239EE.3090904@cn.fujitsu.com> <4C123ABA.3000601@cn.fujitsu.com> <20100611201420.GD12317@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , LKML , KVM list To: Marcelo Tosatti Return-path: In-Reply-To: <20100611201420.GD12317@amt.cnet> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Marcelo Tosatti wrote: > On Fri, Jun 11, 2010 at 09:31:38PM +0800, Xiao Guangrong wrote: >> If the sync-sp just sync transient, don't mark its pte notrap >> >> Signed-off-by: Xiao Guangrong >> --- >> arch/x86/include/asm/kvm_host.h | 2 +- >> arch/x86/kvm/mmu.c | 11 ++++------- >> arch/x86/kvm/paging_tmpl.h | 5 +++-- >> 3 files changed, 8 insertions(+), 10 deletions(-) > > Xiao, > > Can you explain the reasoning for this? > Marcelo, In the kvm_sync_page_transient() path, the sp is keep unsync and sp->gfn is not write protected, we can't set 'spte == shadow_notrap_nonpresent_pte' if the 'gpte.p == 0' in this case. It's because if 'gpte.p == 0', when guest change the gpte's mapping, it's no need to flush tlb(p == 0 means the mapping is not in tlb), if we set spte to 'shadow_notrap_nonpresent_pte', we will miss the chance to update the mapping, also a incorrect #PF will pass to guest directly, may cause guest crash. And, this is the reasoning we do mmu_convert_notrap() in kvm_sync_page_transient() before, this patch just avoid this unnecessary workload. :-)