From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 4/5] KVM: MMU: move adjusting softmmu pte access to FNAME(page_fault) Date: Wed, 21 Nov 2012 07:28:00 +0800 Message-ID: <50AC1200.8070402@linux.vnet.ibm.com> References: <5097AC70.1080904@linux.vnet.ibm.com> <5097AD17.4010001@linux.vnet.ibm.com> <20121120222749.GC31427@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , LKML , KVM To: Marcelo Tosatti Return-path: In-Reply-To: <20121120222749.GC31427@amt.cnet> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 11/21/2012 06:27 AM, Marcelo Tosatti wrote: >> @@ -544,6 +544,21 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr, u32 error_code, >> return 0; >> } >> >> + if (write_fault && !(walker.pte_access & ACC_WRITE_MASK) && >> + !is_write_protection(vcpu) && !user_fault) { >> + walker.pte_access |= ACC_WRITE_MASK; >> + walker.pte_access &= ~ACC_USER_MASK; >> + >> + /* >> + * If we converted a user page to a kernel page, >> + * so that the kernel can write to it when cr0.wp=0, >> + * then we should prevent the kernel from executing it >> + * if SMEP is enabled. >> + */ >> + if (kvm_read_cr4_bits(vcpu, X86_CR4_SMEP)) >> + walker.pte_access &= ~ACC_EXEC_MASK; >> + } >> + > > What about sync_page path? The sync_page and other prefetch paths only do read-prefetch, means they call set_spte with write_fault = 0.