linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Boyer <jwboyer@fedoraproject.org>
To: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Dave Airlie <airlied@linux.ie>,
	ben@bwidawsk.net,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	"Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Michel Thierry <michel.thierry@intel.com>
Subject: Re: [PATCH] drm/i915: Add checks to i915_bind_vma
Date: Thu, 23 Apr 2015 09:14:30 -0400	[thread overview]
Message-ID: <CA+5PVA72UewpbXbevOheiuZwhiK0kbokUet+2kWPS=L6yX4d9w@mail.gmail.com> (raw)
In-Reply-To: <1429721111-22845-1-git-send-email-mika.kuoppala@intel.com>

On Wed, Apr 22, 2015 at 12:45 PM, Mika Kuoppala
<mika.kuoppala@linux.intel.com> wrote:
> The current aliasing ppgtt implementation allocates
> the page table structures on driver initialization
> for the entire vm address space. Earlier the page tables
> were allocated as array of struct pages, but introduction
> of dynamic allocation of page structures changed the page
> tables to be inside a page directory.
>
> We have a detailed bug report where traversing of tables and
> deferencing page_table[pte]->page oopses. This indicates that
> our pre allocation of page tables has failed or that we get
> corrupt vma which does not fit inside the vm area and throws
> pte > 511.
>
> Add more checks to catch the latter. Warn and bail out if
> we get vma which is out of bounds for binding.
>
> v2: Check vma node early (Chris)
>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Michel Thierry <michel.thierry@intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 0239fbf..2ffa8f6 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2746,6 +2746,13 @@ i915_get_ggtt_vma_pages(struct i915_vma *vma)
>  int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
>                   u32 flags)
>  {
> +
> +       if (WARN_ON(!drm_mm_node_allocated(&vma->node)))
> +               return -EINVAL;
> +
> +       if (WARN_ON(vma->node.start > vma->vm->total - vma->node.size))
> +               return -EINVAL;
> +

Do you really need a full backtrace in these cases?  From an end user
perspective, they're going to get a popup saying they have a kernel
problem or an automated tool will file a bug for them and they will
have no idea what any of this means.

I understand the need for the check, but could it be done in a way
that doesn't splat an oops on a user's system?  The i915 driver has
tons of these kinds of WARN_ONs already and they don't seem to be
helping anything overall...

josh

>         if (i915_is_ggtt(vma->vm)) {
>                 int ret = i915_get_ggtt_vma_pages(vma);
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

      reply	other threads:[~2015-04-23 13:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 23:36 NULL ptr dereference in current i915 driver Linus Torvalds
2015-04-22 16:11 ` Michel Thierry
2015-04-22 16:45 ` [PATCH] drm/i915: Add checks to i915_bind_vma Mika Kuoppala
2015-04-23 13:14   ` Josh Boyer [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='CA+5PVA72UewpbXbevOheiuZwhiK0kbokUet+2kWPS=L6yX4d9w@mail.gmail.com' \
    --to=jwboyer@fedoraproject.org \
    --cc=airlied@linux.ie \
    --cc=ben@bwidawsk.net \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michel.thierry@intel.com \
    --cc=mika.kuoppala@linux.intel.com \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).