From: Daniel Vetter Subject: Re: [PATCH] drm/ttm: Refuse to fault (prime-) imported pages Date: Tue, 7 Jan 2014 10:14:57 +0100 Message-ID: <20140107091457.GG4770@phenom.ffwll.local> References: <1388744537-6631-1-git-send-email-thellstrom@vmware.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 94D54FA580 for ; Tue, 7 Jan 2014 01:13:42 -0800 (PST) Received: by mail-ee0-f53.google.com with SMTP id b57so8360542eek.12 for ; Tue, 07 Jan 2014 01:13:41 -0800 (PST) Content-Disposition: inline In-Reply-To: <1388744537-6631-1-git-send-email-thellstrom@vmware.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: Thomas Hellstrom Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Fri, Jan 03, 2014 at 11:22:17AM +0100, Thomas Hellstrom wrote: > This is illegal for at least two reasons: > > 1) While it may work on some platforms / iommus, obtaining page pointers from > mapped sg-lists is illegal, since the DMA API allows page pointer information > to be destroyed in the sg mapping process. > > 2) TTM has no way of determining the linear kernel map caching state of the > underlying pages. PTEs with conflicting caching state pointing to the same > pfn is not allowed. > > TTM operations touching pages of imported sg-tables should be redirected through > the proper dma-buf operations. > > Signed-off-by: Thomas Hellstrom Shouldn't we do something similar in the kmap helpers ttm_bo_util.c like ttm_bo_kmap and ttm_bo_move_memcpy? Maybe just a BUG to catch driver bugs. Otherwise this sounds like the right thing to do, so Acked. -Daniel > --- > drivers/gpu/drm/ttm/ttm_bo_vm.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c > index cdda784..12d7f53 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c > @@ -132,6 +132,15 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) > return VM_FAULT_NOPAGE; > } > > + /* > + * Refuse to fault imported pages. This should be handled > + * (if at all) by redirecting mmap to the exporter. > + */ > + if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { > + retval = VM_FAULT_SIGBUS; > + goto out_unlock; > + } > + > if (bdev->driver->fault_reserve_notify) { > ret = bdev->driver->fault_reserve_notify(bo); > switch (ret) { > -- > 1.7.10.4 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch