From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: Intel GFX <intel-gfx@lists.freedesktop.org>,
Ben Widawsky <benjamin.widawsky@intel.com>
Subject: Re: [PATCH 04/12] drm/i915: Don't unconditionally try to deref aliasing ppgtt
Date: Mon, 25 Nov 2013 21:08:50 +0200 [thread overview]
Message-ID: <20131125190850.GS10036@intel.com> (raw)
In-Reply-To: <20131125181028.GB8797@bwidawsk.net>
On Mon, Nov 25, 2013 at 10:10:28AM -0800, Ben Widawsky wrote:
> On Mon, Nov 25, 2013 at 06:06:18PM +0000, Chris Wilson wrote:
> > On Mon, Nov 25, 2013 at 09:54:35AM -0800, Ben Widawsky wrote:
> > > Since the beginning, the functions which try to properly reference the
> > > aliasing PPGTT have deferences a potentially null aliasing_ppgtt member.
> > > Since the accessors are meant to be global, this will not do.
> > >
> > > Introduced originally in:
> > > commit a70a3148b0c61cb7c588ea650db785b261b378a3
> > > Author: Ben Widawsky <ben@bwidawsk.net>
> > > Date: Wed Jul 31 16:59:56 2013 -0700
> > >
> > > drm/i915: Make proper functions for VMs
> > >
> > > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> > > ---
> > > drivers/gpu/drm/i915/i915_gem.c | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > > index 40d9dcf..bc5c865 100644
> > > --- a/drivers/gpu/drm/i915/i915_gem.c
> > > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > > @@ -4971,7 +4971,8 @@ unsigned long i915_gem_obj_offset(struct drm_i915_gem_object *o,
> > > struct drm_i915_private *dev_priv = o->base.dev->dev_private;
> > > struct i915_vma *vma;
> > >
> > > - if (vm == &dev_priv->mm.aliasing_ppgtt->base)
> > > + if (!dev_priv->mm.aliasing_ppgtt ||
> > > + vm == &dev_priv->mm.aliasing_ppgtt->base)
> >
> > Where's the dereference? gcc is smarter than your average bear.
> > -Chris
>
> I had assumed: dev_priv->mm.aliasing_ppgtt->base in cases when
> aliasing_ppgtt was NULL. Given that I never actually hit this, I agree
> GCC must be doing something.
Sounds like another discussion on the implementation of offsetof().
>
> Is such behavior documented somewhere? (forgive the lazy)
IIRC the C standard does say that for &*foo it's as if both & and *
weren't there (and IIRC the same for &foo[x]), but doesn't really
say that kind of thing for &foo->bar. I guess it's a gray area,
and just happens work that way on certain compilers.
In this particular case I think there's one slight issue. If
aliasing_pggtt == NULL, and someone passes in vm == NULL by
accident, then it'll take the branch and use ggtt because
&aliasing_ppgtt->base will be NULL too (due to base being at
offset 0 in the struct). Now, I don't know if a NULL
vm could survive this far into the code, but it it can, then it
might make debugging a bit more "fun".
As a side note, we actually depend on such things in the mode
setting code. Ie. &((struct intel_crtc*)NULL)->base must be
NULL, otherwise interesting bugs would happen.
--
Ville Syrjälä
Intel OTC
next prev parent reply other threads:[~2013-11-25 19:08 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-25 17:54 [PATCH 00/12] PPGTT pre-work Ben Widawsky
2013-11-25 17:54 ` [PATCH 01/12] drm/i915: Fix BDW PPGTT error path Ben Widawsky
2013-11-25 20:11 ` Chris Wilson
2013-11-25 17:54 ` [PATCH 02/12] drm/i915: Provide PDP updates via MMIO Ben Widawsky
2013-11-25 18:00 ` Ben Widawsky
2013-11-25 18:18 ` Chris Wilson
2013-11-25 18:28 ` Ben Widawsky
2013-11-25 18:44 ` Chris Wilson
2013-11-25 18:49 ` Ben Widawsky
2013-11-26 9:05 ` Daniel Vetter
2013-11-25 17:54 ` [PATCH 03/12] drm/i915: Add a few missed bits to the mm Ben Widawsky
2013-11-25 17:54 ` [PATCH 04/12] drm/i915: Don't unconditionally try to deref aliasing ppgtt Ben Widawsky
2013-11-25 18:06 ` Chris Wilson
2013-11-25 18:10 ` Ben Widawsky
2013-11-25 19:08 ` Ville Syrjälä [this message]
2013-11-26 9:09 ` Daniel Vetter
2013-11-25 17:54 ` [PATCH 05/12] drm/i915: Disallow dynamic ppgtt param modification Ben Widawsky
2013-11-25 18:50 ` Chris Wilson
2013-11-25 17:54 ` [PATCH 06/12] drm/i915: Demote drop_caches_set print Ben Widawsky
2013-11-25 18:08 ` Chris Wilson
2013-11-25 17:54 ` [PATCH 07/12] drm/i915: Removed unused vm args Ben Widawsky
2013-11-25 17:54 ` [PATCH 08/12] drm/i915: Remove defunct ctx switch comments Ben Widawsky
2013-11-25 17:54 ` [PATCH 09/12] drm/i915: Missed dropped VMA conversion Ben Widawsky
2013-11-25 17:54 ` [PATCH 10/12] drm/i915: Allow ggtt lookups to not WARN Ben Widawsky
2013-11-26 9:16 ` Daniel Vetter
2013-11-25 17:54 ` [PATCH 11/12] drm/i915: Takedown drm_mm on failed gtt setup Ben Widawsky
2013-11-26 9:21 ` Daniel Vetter
2013-11-25 17:54 ` [PATCH 12/12] drm/i915: Move the gtt mm takedown to cleanup 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=20131125190850.GS10036@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=ben@bwidawsk.net \
--cc=benjamin.widawsky@intel.com \
--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