From: Benjamin Herrenschmidt Date: Fri, 09 Feb 2018 21:54:49 +0000 Subject: Re: [RFC PATCH] KVM: PPC: Book3S HV: add support for page faults in VM_IO|VM_PFNMAP vmas Message-Id: <1518213289.2312.242.camel@kernel.crashing.org> List-Id: References: <20180208160303.19016-1-clg@kaod.org> <1518128353.2312.217.camel@kernel.crashing.org> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: =?ISO-8859-1?Q?C=E9dric?= Le Goater , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Paul Mackerras On Fri, 2018-02-09 at 08:14 +0100, C=C3=A9dric Le Goater wrote: > > > @@ -402,8 +450,15 @@ int kvmppc_book3s_radix_page_fault(struct kvm_ru= n *run, struct kvm_vcpu *vcpu, > > > vma =3D find_vma(current->mm, hva); > > > if (vma && vma->vm_start <=3D hva && hva < vma->vm_e= nd && > > > (vma->vm_flags & VM_PFNMAP)) { > > > - pfn =3D vma->vm_pgoff + > > > - ((hva - vma->vm_start) >> PAGE_SHIFT); > > > + if (vma->vm_flags & (VM_IO | VM_PFNMAP)) { > > > + ret =3D hva_to_pfn_remapped(vma, hva,= writing, > > > + &pfn); > > > + if (ret =3D -EAGAIN) > > > + return RESUME_GUEST; > > > + } else { > > > + pfn =3D vma->vm_pgoff + > > > + ((hva - vma->vm_start) >> PAG= E_SHIFT); > > > + } > >=20 > > I don't think the else case is useful. If fact you are checking > > VM_PFNMAP twice... >=20 > yes. I am not sure what the VM_PFNMAP case does. The code comes=20 > from kvmppc_book3s_hv_page_fault() I suppose. You just need to reproduce the bottom of hva_to_pfn. I don't think that PFNMAP case in Paul's code is quite right anyway, the generic code will just go read the PTE which is the right thing to do. Cheers, Ben.