Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3193614pxb; Fri, 12 Feb 2021 11:33:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3fkpPNbsooPwBjncqHceH/FlFTca3PrMSYiYrlGtJtXRUqkO6MBwu4BYAx0ekneFXH0xc X-Received: by 2002:aa7:dd4b:: with SMTP id o11mr4941251edw.303.1613158386896; Fri, 12 Feb 2021 11:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613158386; cv=none; d=google.com; s=arc-20160816; b=vb3HKKubM8PFB6WRqvT0QPPmxn6Ox79eWUb4fRu4MeJCGnvRHYwgcd2/ovxCz7zLlt 8ms4AN2wc3X5vf2NgVPwbJH5I4K29Oar0j7raKGvBLwLEkwj6YZ3xyZ3IO6He2wacwZP hHz7NFUq7ufumvo7w5C3Q+AGAWlcB+vNNvIFs92OERj63SB07eni8+M2CxE0/T9kXUsp tQuKnClFchigGRj6vRO/tDbZC6ONsOqRQHXKK6zswf8Leov4ymM7t7Ar2psE3lZSvzzj uRFhb36bLPisd7ZGXI8b6BKkewmlOwaiqApyQ8XP+jD/vlZw01Xi8sWgsAh4hlm4nFXA lLwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=raUaHGVETzgwtOYJENwGXkg1sLEzgrj+DX5uJcQ/C60=; b=Kr386bp1yIZT43gMDAMvGkoHWZzSY/a58RakD7M3I3cJRonz1DqXFEdc47Em5ccXeh 9sMs3yUMwTIdJjeGoJHCBdCbP4vorylclXWmiwQRTTEEBB+47DDMGMXHBYGEb+01Zb6o HwZE8ctUOuX13BlqKU7ygp6emly9hyghgvPWXeGn0hOvUMfnQZyAoA/CotVxrKfpqIeq POQjsApBW/zspUnO/8X2kPcd7oPXhUG5KCKfAs3OivzPkda52i+Vp7CW5E6twEtz2AU6 r6JVBuYmMX6MyhuAwpbTZ0cHZ8AwJ14TpD4wDdiqUOhiFILrd2zhmS+j2AIH7wvUhhDo EJOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GuPZhEcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si7513452eje.254.2021.02.12.11.32.42; Fri, 12 Feb 2021 11:33:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GuPZhEcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231292AbhBLTbs (ORCPT + 99 others); Fri, 12 Feb 2021 14:31:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25166 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231660AbhBLTbp (ORCPT ); Fri, 12 Feb 2021 14:31:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613158219; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=raUaHGVETzgwtOYJENwGXkg1sLEzgrj+DX5uJcQ/C60=; b=GuPZhEcTEK4vPl33BopRXmlKMXacc4CpcJX2zZB9knQA69J8SOUimxFbCYxIg/aljE4ULG PXt4l/yay1Q6v6QhGSWKqSS4Jat1haLq07OMwHmmPcIVdaABgrpFQmlaHw+em33VknvZ6I l7XL4XC6vf7A+U0AS9SRU9/2FVQAb/Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-on4ZkOB1Pku6iRFeythbPg-1; Fri, 12 Feb 2021 14:30:16 -0500 X-MC-Unique: on4ZkOB1Pku6iRFeythbPg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D68ED51B8; Fri, 12 Feb 2021 19:30:14 +0000 (UTC) Received: from omen.home.shazbot.org (ovpn-112-255.phx2.redhat.com [10.3.112.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 784585C3E0; Fri, 12 Feb 2021 19:30:11 +0000 (UTC) Date: Fri, 12 Feb 2021 12:30:11 -0700 From: Alex Williamson To: Jason Gunthorpe Cc: Daniel Vetter , , , , , Subject: Re: [PATCH] vfio/type1: Use follow_pte() Message-ID: <20210212123011.1ed7b062@omen.home.shazbot.org> In-Reply-To: <20210212190851.GT4247@nvidia.com> References: <161315649533.7249.11715726297751446001.stgit@gimli.home> <20210212190851.GT4247@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 Feb 2021 15:08:51 -0400 Jason Gunthorpe wrote: > On Fri, Feb 12, 2021 at 12:01:50PM -0700, Alex Williamson wrote: > > follow_pfn() doesn't make sure that we're using the correct page > > protections, get the pte with follow_pte() so that we can test > > protections and get the pfn from the pte. > > > > Fixes: 5cbf3264bc71 ("vfio/type1: Fix VA->PA translation for PFNMAP VMAs in vaddr_get_pfn()") > > Signed-off-by: Alex Williamson > > --- > > drivers/vfio/vfio_iommu_type1.c | 14 ++++++++++++-- > > 1 file changed, 12 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > > index ec9fd95a138b..90715413c3d9 100644 > > --- a/drivers/vfio/vfio_iommu_type1.c > > +++ b/drivers/vfio/vfio_iommu_type1.c > > @@ -463,9 +463,11 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm, > > unsigned long vaddr, unsigned long *pfn, > > bool write_fault) > > { > > + pte_t *ptep; > > + spinlock_t *ptl; > > int ret; > > > > - ret = follow_pfn(vma, vaddr, pfn); > > + ret = follow_pte(vma->vm_mm, vaddr, NULL, &ptep, NULL, &ptl); > > if (ret) { > > bool unlocked = false; > > > > @@ -479,9 +481,17 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm, > > if (ret) > > return ret; > > > > - ret = follow_pfn(vma, vaddr, pfn); > > + ret = follow_pte(vma->vm_mm, vaddr, NULL, &ptep, NULL, &ptl); > > commit 9fd6dad1261a541b3f5fa7dc5b152222306e6702 in linux-next is what > export's follow_pte and it uses a different signature: > > +int follow_pte(struct mm_struct *mm, unsigned long address, > + pte_t **ptepp, spinlock_t **ptlp) Thanks, I stole it off the mailing list and hadn't noticed the change. > Recommend you send this patch for rc1 once the right stuff lands in > Linus's tree > > Otherwise it looks OK > > Reviewed-by: Jason Gunthorpe Thanks! Alex