From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: KVM: MMU: only write protect mappings at pagetable level Date: Wed, 22 Dec 2010 11:06:50 -0200 Message-ID: <20101222130650.GA9510@amt.cnet> References: <20101222110157.GA4266@amt.cnet> <4D11DBEB.8050008@redhat.com> <20101222111259.GA4778@amt.cnet> <4D11F69F.8030101@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:12776 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752845Ab0LVNoW (ORCPT ); Wed, 22 Dec 2010 08:44:22 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBMDiLaw004038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 Dec 2010 08:44:22 -0500 Content-Disposition: inline In-Reply-To: <4D11F69F.8030101@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Dec 22, 2010 at 03:01:19PM +0200, Avi Kivity wrote: > On 12/22/2010 01:12 PM, Marcelo Tosatti wrote: > >On Wed, Dec 22, 2010 at 01:07:23PM +0200, Avi Kivity wrote: > >> On 12/22/2010 01:01 PM, Marcelo Tosatti wrote: > >> >If a pagetable contains a writeable large spte, all of its sptes will be > >> > >> non-writeable > >> > >> >write protected, including non-leaf ones, leading to endless pagefaults. > >> > > >> >Do not write protect pages above PT_PAGE_TABLE_LEVEL, as the spte fault > >> >paths assume non-leaf sptes are writable. > >> > > >> >Signed-off-by: Marcelo Tosatti > >> > > >> >diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > >> >index c3853d5..c716ff8 100644 > >> >--- a/arch/x86/kvm/mmu.c > >> >+++ b/arch/x86/kvm/mmu.c > >> >@@ -3442,6 +3442,9 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot) > >> > if (!test_bit(slot, sp->slot_bitmap)) > >> > continue; > >> > > >> >+ if (sp->role.level != PT_PAGE_TABLE_LEVEL) > >> >+ continue; > >> >+ > >> > pt = sp->spt; > >> > for (i = 0; i< PT64_ENT_PER_PAGE; ++i) > >> > /* avoid RMW */ > >> > >> But what about large leaf sptes? Don't we want to write protect, or > >> perhaps drop them? > >> > >> I think write-protecting leaf sptes and ignoring nonleaf sptes should work. > > > >When dirty logging is enabled large sptes are nuked and creation of new > >ones is not allowed. So i don't see the need? > > Where does this nuking happen? > > All I see is the call to kvm_mmu_slot_remove_write_access(). set_memory_region: /* destroy any largepage mappings for dirty tracking */ if (old.npages) flush_shadow = 1;