From: Thomas Hellstrom <thellstrom@vmware.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: Refuse to fault (prime-) imported pages
Date: Tue, 07 Jan 2014 10:45:26 +0100 [thread overview]
Message-ID: <52CBCCB6.8020202@vmware.com> (raw)
In-Reply-To: <20140107091457.GG4770@phenom.ffwll.local>
On 01/07/2014 10:14 AM, Daniel Vetter wrote:
> 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 <thellstrom@vmware.com>
> 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
Indeed, although I think that TTM should by default reroute the
ttm_bo_kmap operations through the
correct dma-buf ops. Haven't gotten around to do that yet.
/Thomas
>> ---
>> 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
>> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/dri-devel&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=l5Ago9ekmVFZ3c4M6eauqrJWGwjf6fTb%2BP3CxbBFkVM%3D%0A&m=3HWzF0bywXXmhWUQ1pCmbecMKkpEmnzo1A%2FnuPHbTX8%3D%0A&s=7209cea9c0020dea424c53ca15e12218f0370076ed1105a55775ea3d39a2b267
prev parent reply other threads:[~2014-01-07 9:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-03 10:22 [PATCH] drm/ttm: Refuse to fault (prime-) imported pages Thomas Hellstrom
2014-01-07 9:14 ` Daniel Vetter
2014-01-07 9:45 ` Thomas Hellstrom [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52CBCCB6.8020202@vmware.com \
--to=thellstrom@vmware.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.