From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Subject: Re: [RFC PATCH] KVM: PPC: Book3S HV: add support for page faults in VM_IO|VM_PFNMAP vmas Date: Fri, 9 Feb 2018 08:14:19 +0100 Message-ID: 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: Benjamin Herrenschmidt , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Paul Mackerras Return-path: Received: from 8.mo7.mail-out.ovh.net ([46.105.77.114]:46452 "EHLO 8.mo7.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909AbeBIHOZ (ORCPT ); Fri, 9 Feb 2018 02:14:25 -0500 Received: from player697.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 3959A8DE12 for ; Fri, 9 Feb 2018 08:14:24 +0100 (CET) In-Reply-To: <1518128353.2312.217.camel@kernel.crashing.org> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 02/08/2018 11:19 PM, Benjamin Herrenschmidt wrote: > On Thu, 2018-02-08 at 17:03 +0100, Cédric Le Goater wrote: >> >> +/* >> + * Stolen from virt/kvm/kvm_main.c >> + */ > > Just export it. It's annoying that we can't just ues hva_to_pfn() ... yes. I might add a kvm_ prefix. I will check to see what is the best pratice. [ ... ] >> @@ -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. Thanks, C.