From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: MMU: Segregate mmu pages created with different cr4.pge settings Date: Tue, 6 Jan 2009 14:43:11 -0200 Message-ID: <20090106164311.GA4902@amt.cnet> References: <20081221184146.8E00B250012@cleopatra.tlv.redhat.com> <49621FA9.5080903@suse.de> <49633564.7070403@redhat.com> <20090106141151.GA3701@amt.cnet> <49636AE7.4090108@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Graf , "kvm@vger.kernel.org" , joerg.roedel@amd.com To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:43274 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbZAFQn2 (ORCPT ); Tue, 6 Jan 2009 11:43:28 -0500 Content-Disposition: inline In-Reply-To: <49636AE7.4090108@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jan 06, 2009 at 04:29:59PM +0200, Avi Kivity wrote: > Yes... > > Looks like kvm_unsync_page can be folded into mmu_need_write_protect > (after which we can drop lookup_page(), which is not a good API). But > that's after we solve the current problem. > > Looks like the addition of a second role for non-pge mode confuses the > mmu. After the second page is created, mmu_need_write_protect() will > return 1, but previously existing sptes can still be writable? > > Looks like we need to call rmap_write_protect() when the new page is > created. I'm not sure about the details, but I suspect that multiple shadows confuse NPT somehow. Alexander can you give this a try: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 36aa576..2c6579e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -363,7 +363,8 @@ void kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) } kvm_x86_ops->set_cr4(vcpu, cr4); vcpu->arch.cr4 = cr4; - vcpu->arch.mmu.base_role.cr4_pge = !!(cr4 & X86_CR4_PGE); + if (!tdp_enabled) + vcpu->arch.mmu.base_role.cr4_pge = !!(cr4 & X86_CR4_PGE); kvm_mmu_sync_global(vcpu); kvm_mmu_reset_context(vcpu); }