From mboxrd@z Thu Jan 1 00:00:00 1970 From: Izik Eidus Subject: Re: [PATCH 2/3] kvm: add SPTE_HOST_WRITEABLE flag to the shadow ptes. Date: Thu, 09 Apr 2009 15:58:41 +0300 Message-ID: <49DDF101.4010005@redhat.com> 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> <20090409095949.GB31724@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx2.redhat.com ([66.187.237.31]:48625 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761281AbZDIM7g (ORCPT ); Thu, 9 Apr 2009 08:59:36 -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 n39CxZnP008260 for ; Thu, 9 Apr 2009 08:59:35 -0400 In-Reply-To: <20090409095949.GB31724@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: Marcelo Tosatti wrote: > 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. > Yes, you are right wont work too effective ;-) Anyway i will repost it as soon as we decide about PATCH 1/ 3 (the #IFDEF thing) Thank Marcelo :-)