public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Ben Widawsky <benjamin.widawsky@intel.com>,
	Intel GFX <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 5/6] [v3] drm/i915: Use the new vm [un]bind functions
Date: Wed, 18 Sep 2013 09:11:56 -0700	[thread overview]
Message-ID: <20130918161156.GA9111@bwidawsk.net> (raw)
In-Reply-To: <20130918155901.GA2858@nuc-i3427.alporthouse.com>

On Wed, Sep 18, 2013 at 04:59:01PM +0100, Chris Wilson wrote:
> On Wed, Sep 18, 2013 at 08:48:45AM -0700, Ben Widawsky wrote:
> > On Wed, Sep 18, 2013 at 03:53:37PM +0100, Chris Wilson wrote:
> > > On Wed, Sep 18, 2013 at 07:47:45AM -0700, Ben Widawsky wrote:
> > > > On Wed, Sep 18, 2013 at 09:30:17AM +0100, Chris Wilson wrote:
> > > > > On Tue, Sep 17, 2013 at 05:02:03PM -0700, Ben Widawsky wrote:
> > > > > > > The code does
> > > > > > > 
> > > > > > > 	exec_start = i915_gem_obj_offset(batch_obj, vm) +
> > > > > > > 			args->batch_start_offset;
> > > > > > > 	exec_len = args->batch_len;
> > > > > > > 	...
> > > > > > > 	ret = ring->dispatch_execbuffer(ring,
> > > > > > > 					exec_start, exec_len,
> > > > > > > 					flags);
> > > > > > > 	if (ret)
> > > > > > > 		goto err;
> > > > > > > 
> > > > > > > So we lookup the address of the batch buffer in the wrong vm for
> > > > > > > I915_DISPATCH_SECURE.
> > > > > > > -Chris
> > > > > > > 
> > > > > > 
> > > > > > But this is very easily solved, no?
> > > > > > 
> > > > > > http://cgit.freedesktop.org/~bwidawsk/drm-intel/tree/drivers/gpu/drm/i915/i915_gem_execbuffer.c?h=ppgtt#n1083
> > > > > 
> > > > > No, just because the batch once had a ggtt entry doesn't mean the CS is
> > > > > going to use the ggtt for this execution...
> > > > > -Chris
> > > > > 
> > > > > -- 
> > > > > Chris Wilson, Intel Open Source Technology Centre
> > > > 
> > > > I guess your use of the term, "CS" here is a bit confusing to me, since
> > > > in my head the CS better do whatever we tell it to do.
> > > 
> > > Exactly, we tell the CS to use the ggtt for the SECURE batch (at least
> > > on some generations).
> > >  
> > > > If you're trying to say, "just because batch_obj has a ggtt binding;
> > > > that doesn't necessarily mean it's the one to use at dispatch." I think
> > > > that statement is true, but it's still pretty simple to solve, just use
> > > > the I915_DISPATCH_SECURE flag to check instead of
> > > > obj->has_global_gtt_mapping. Right?
> > > 
> > > Yes. With the same caveat that it may change.
> > 
> > What may change? Dispatch secure always means use the GGTT offset, does
> > it not? Or do you think we'll want privileged batches running from the
> > PPGTT? If the latter is true, why ever use GGTT?
> 
> The security bit is already independent from the use-ppgtt bit. With
> Haswell it should be possible to execute a privileged batch buffer from
> a ppgtt address, right? In which case we would not need to allocate a
> GGTT entry.
>  

Right, that was my point. But I *still* fail to see how your earlier
request does anything to help this along. The decision can still easily
be made at any given time with the I915_DISPATCH_SECURE flag, and per
platform driver policy. Say, if you wanted HSW to always run privileged
batches out of PPGTT. OTOH, if we need to pass a flag down to specify
which address space to execute the batch out of, maybe some more hoops
need to be jumped through. I don't see a reason to do this however, and
if we want to support IVB, we have to support GGTT execution anyway - so
I'm not really sure of a benefit to building in support for PPGTT
privileged execution.


> > > > I'm really sorry about being so dense here.
> > > > 
> > > > As a side note, I tried really hard to think of how we could end up with
> > > > a ggtt mapping for batch_obj, and not want to use that one. I'm not
> > > > actually sure it's possible, but I can't prove it as such, so I'm
> > > > willing to assume it is possible. Excluding SNB, so few objects actually
> > > > will get a ggtt mapping, I don't believe any of them should be reused
> > > > for a batch BO - however, IGT can probably make it happen.
> > > 
> > > It's trivial for a batch to end up with a ggtt entry - userspace can
> > > just access it through the GTT. Or any bo prior to reusing it as a
> > > batch.
> > > -Chris
> > 
> > Trivial, perhaps on the gtt mapping. It's not really relevant, but is
> > any userspace currently doing that? As for BO reuse, that's a separate
> > problem - are we handing back BOs with their mappings intact? That seems
> > like a security problem.
> 
> *Userspace* caches its bo with the mappings intact.
> -Chris

Yes, this seems like a potential (albeit small) problem to me if we (the
kernel) arbitrarily upgrade BOs to a GGTT mapping. I guess everything
running privileged is trusted though, so we don't need to worry about
the unintentional global BOs being snooped. It does sort of seem to
circumvent real PPGTT to some extent though if the global mappings
linger.

Let me state that at this point of the thread, I am lost. Do you still
want the original change you asked for? I still don't understand, or see
a reason for not just quirking away with a quick check (which I'll state
again doesn't even matter until patches which haven't yet been written
are posted) - but I clearly haven't been able to convince you; and
nobody else is stepping in.

-- 
Ben Widawsky, Intel Open Source Technology Center

  reply	other threads:[~2013-09-18 16:12 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-14 22:03 [PATCH 1/6] drm/i915: trace vm eviction instead of everything Ben Widawsky
2013-09-14 22:03 ` [PATCH 2/6] drm/i915: Provide a cheap ggtt vma lookup Ben Widawsky
2013-09-14 22:03 ` [PATCH 3/6] drm/i915: Convert active API to VMA Ben Widawsky
2013-09-14 22:03 ` [PATCH 4/6] drm/i915: Add bind/unbind object functions to VM Ben Widawsky
2013-09-16  9:25   ` Chris Wilson
2013-09-16 18:23     ` Ben Widawsky
2013-09-16 22:05       ` Daniel Vetter
2013-09-16 22:18         ` Chris Wilson
2013-09-16 22:20           ` Daniel Vetter
2013-09-16 22:13       ` Chris Wilson
2013-09-17  5:44         ` Ben Widawsky
2013-09-17  7:49           ` Chris Wilson
2013-09-17 17:00             ` [PATCH 4/6] [v5] " Ben Widawsky
2013-09-14 22:03 ` [PATCH 5/6] drm/i915: Use the new vm [un]bind functions Ben Widawsky
2013-09-16  7:37   ` Chris Wilson
2013-09-16 18:31     ` Ben Widawsky
2013-09-17 17:01     ` [PATCH 5/6] [v3] " Ben Widawsky
2013-09-17 20:55       ` Chris Wilson
2013-09-17 23:14         ` Ben Widawsky
2013-09-17 23:33           ` Chris Wilson
2013-09-17 23:48             ` Ben Widawsky
2013-09-17 23:57               ` Chris Wilson
2013-09-18  0:02                 ` Ben Widawsky
2013-09-18  8:30                   ` Chris Wilson
2013-09-18 14:47                     ` Ben Widawsky
2013-09-18 14:53                       ` Chris Wilson
2013-09-18 15:48                         ` Ben Widawsky
2013-09-18 15:59                           ` Chris Wilson
2013-09-18 16:11                             ` Ben Widawsky [this message]
2013-09-18 16:15                               ` Chris Wilson
2013-09-18 16:20                                 ` Daniel Vetter
2013-09-18 16:37                                   ` Ben Widawsky
2013-09-19  0:12                                 ` [PATCH] [v4] " Ben Widawsky
2013-09-19  9:13                                   ` Chris Wilson
2013-09-19 14:15                                     ` [PATCH] [v5] " Ben Widawsky
2013-09-19 14:26                                       ` Chris Wilson
2013-09-19 14:41                                         ` [PATCH] [v6] " Ben Widawsky
2013-09-19 14:45                                           ` [PATCH] [v7] " Ben Widawsky
2013-09-20  4:06                                             ` [PATCH] " Ben Widawsky
2013-09-20 10:43                                               ` Chris Wilson
2013-09-20 13:24                                                 ` Daniel Vetter
2013-09-20 13:26                                                   ` Daniel Vetter
2013-09-20 13:29                                                   ` Chris Wilson
2013-09-20 20:44                                                 ` Ben Widawsky
2013-09-20 20:55                                                   ` Chris Wilson
2013-09-20 21:08                                                     ` Ben Widawsky
2013-09-20 21:22                                                     ` Daniel Vetter
2013-09-22 18:46                                                 ` [PATCH] [v9] " Ben Widawsky
2013-09-23  8:39                                                   ` Chris Wilson
2013-09-23 22:00                                                     ` Ben Widawsky
2013-09-23 22:10                                                       ` Chris Wilson
2013-09-19 14:47                                           ` [PATCH] [v6] " Chris Wilson
2013-09-19 17:41                                             ` Ben Widawsky
2013-09-19 18:36                                               ` Daniel Vetter
2013-09-14 22:03 ` [PATCH 6/6] drm/i915: eliminate vm->insert_entries() Ben Widawsky

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=20130918161156.GA9111@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=benjamin.widawsky@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox