From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 2/3] kvm: add SPTE_HOST_WRITEABLE flag to the shadow ptes. Date: Thu, 9 Apr 2009 06:59:49 -0300 Message-ID: <20090409095949.GB31724@amt.cnet> References: <1238457604-7637-1-git-send-email-ieidus@redhat.com> <1238457604-7637-2-git-send-email-ieidus@redhat.com> <1238457604-7637-3-git-send-email-ieidus@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Izik Eidus Return-path: Received: from mx2.redhat.com ([66.187.237.31]:57625 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764797AbZDIJ76 (ORCPT ); Thu, 9 Apr 2009 05:59:58 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n399xwUE032353 for ; Thu, 9 Apr 2009 05:59:58 -0400 Content-Disposition: inline In-Reply-To: <1238457604-7637-3-git-send-email-ieidus@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Mar 31, 2009 at 03:00:03AM +0300, Izik Eidus wrote: > this flag notify that the host physical page we are pointing to from > the spte is write protected, and therefore we cant change its access > to be write unless we run get_user_pages(write = 1). > > (this is needed for change_pte support in kvm) > > Signed-off-by: Izik Eidus > @@ -547,6 +551,7 @@ static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu, > static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) > { > int i, offset, nr_present; > + bool reset_host_protection = 1; > > offset = nr_present = 0; > > @@ -584,9 +589,14 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) > > nr_present++; > pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte); > + if (!(sp->spt[i] & SPTE_HOST_WRITEABLE)) { > + pte_access &= ~PT_WRITABLE_MASK; > + reset_host_protection = 0; > + } else reset_host_protection = 1; Otherwise you clear SPTE_HOST_WRITEABLE for all sptes once you find a single one thats unset. Also mind the tabs.