From mboxrd@z Thu Jan 1 00:00:00 1970 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. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Herrenschmidt Subject: Re: [RFC PATCH] KVM: PPC: Book3S HV: add support for page faults in VM_IO|VM_PFNMAP vmas Date: Sat, 10 Feb 2018 08:54:49 +1100 Message-ID: <1518213289.2312.242.camel@kernel.crashing.org> References: <20180208160303.19016-1-clg@kaod.org> <1518128353.2312.217.camel@kernel.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit To: =?ISO-8859-1?Q?C=E9dric?= Le Goater , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Paul Mackerras Return-path: Received: from gate.crashing.org ([63.228.1.57]:41617 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752930AbeBIVzT (ORCPT ); Fri, 9 Feb 2018 16:55:19 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 2018-02-09 at 08:14 +0100, Cédric Le Goater wrote: > > > @@ -402,8 +450,15 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, > > > vma = find_vma(current->mm, hva); > > > if (vma && vma->vm_start <= hva && hva < vma->vm_end && > > > (vma->vm_flags & VM_PFNMAP)) { > > > - pfn = vma->vm_pgoff + > > > - ((hva - vma->vm_start) >> PAGE_SHIFT); > > > + if (vma->vm_flags & (VM_IO | VM_PFNMAP)) { > > > + ret = hva_to_pfn_remapped(vma, hva, writing, > > > + &pfn); > > > + if (ret == -EAGAIN) > > > + return RESUME_GUEST; > > > + } else { > > > + pfn = vma->vm_pgoff + > > > + ((hva - vma->vm_start) >> PAGE_SHIFT); > > > + } > > > > I don't think the else case is useful. If fact you are checking > > VM_PFNMAP twice... > > yes. I am not sure what the VM_PFNMAP case does. The code comes > 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.