From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [patch 2/3] KVM: dont require read-only host ptes Date: Tue, 5 Oct 2010 10:47:20 -0300 Message-ID: <20101005134720.GA28632@amt.cnet> References: <20101005115458.792126399@redhat.com> <20101005121555.827500635@redhat.com> <20101005134301.GQ11145@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, aarcange@redhat.com, kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:23711 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753245Ab0JEQ7n (ORCPT ); Tue, 5 Oct 2010 12:59:43 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o95GxhvG029940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Oct 2010 12:59:43 -0400 Content-Disposition: inline In-Reply-To: <20101005134301.GQ11145@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Oct 05, 2010 at 03:43:01PM +0200, Gleb Natapov wrote: > > --- kvm.orig/arch/x86/kvm/mmu.c > > +++ kvm/arch/x86/kvm/mmu.c > > @@ -2273,6 +2273,7 @@ static int nonpaging_map(struct kvm_vcpu > > { > > int r; > > int level; > > + int writable; > > pfn_t pfn; > > unsigned long mmu_seq; > > > > @@ -2289,10 +2290,10 @@ static int nonpaging_map(struct kvm_vcpu > > > > mmu_seq = vcpu->kvm->mmu_notifier_seq; > > smp_rmb(); > > - pfn = gfn_to_pfn(vcpu->kvm, gfn); > > + pfn = gfn_to_pfn(vcpu->kvm, gfn, &writable); > > > > /* mmio */ > > - if (is_error_pfn(pfn)) > > + if (is_error_pfn(pfn) || !writable) > > return kvm_handle_bad_page(vcpu->kvm, gfn, pfn); > > > > spin_lock(&vcpu->kvm->mmu_lock); > > @@ -2581,6 +2582,8 @@ static int tdp_page_fault(struct kvm_vcp > > pfn_t pfn; > > int r; > > int level; > > + int writable; > > + int write = error_code & PFERR_WRITE_MASK; > > gfn_t gfn = gpa >> PAGE_SHIFT; > > unsigned long mmu_seq; > > > > @@ -2597,15 +2600,14 @@ static int tdp_page_fault(struct kvm_vcp > > > > mmu_seq = vcpu->kvm->mmu_notifier_seq; > > smp_rmb(); > > - pfn = gfn_to_pfn(vcpu->kvm, gfn); > > - if (is_error_pfn(pfn)) > > + pfn = gfn_to_pfn(vcpu->kvm, gfn, &writable); > > + if (is_error_pfn(pfn) || !writable) > Why would we fail read only access to read only memory? Shouldn't we > check access type here? > > -- > Gleb. Next patch does that.