From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/3] add SPTE_HOST_WRITEABLE flag to the shadow ptes Date: Mon, 14 Sep 2009 08:18:56 +0300 Message-ID: <4AADD240.3000608@redhat.com> References: <1252600738-9456-1-git-send-email-ieidus@redhat.com> <1252600738-9456-2-git-send-email-ieidus@redhat.com> <1252600738-9456-3-git-send-email-ieidus@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, aarcange@redhat.com To: Izik Eidus Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4886 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019AbZINFS7 (ORCPT ); Mon, 14 Sep 2009 01:18:59 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8E5J3wV016285 for ; Mon, 14 Sep 2009 01:19:03 -0400 In-Reply-To: <1252600738-9456-3-git-send-email-ieidus@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/10/2009 07:38 PM, 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) > > > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index 62d2f86..a7151b8 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -156,6 +156,8 @@ module_param(oos_shadow, bool, 0644); > #define CREATE_TRACE_POINTS > #include "mmutrace.h" > > +#define SPTE_HOST_WRITEABLE (1ULL<< PT_FIRST_AVAIL_BITS_SHIFT) > + > Luckilly, this bit is available on EPT too. > #define SHADOW_PT_INDEX(addr, level) PT64_I > @@ -595,9 +600,16 @@ 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; > pte_access uses ACC_ masks, not PT_ masks. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.