From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/5] drm/i915: harden allocation paths in allocate_va_range
Date: Mon, 18 Apr 2016 16:13:27 +0300 [thread overview]
Message-ID: <1460985207.6027.5.camel@linux.intel.com> (raw)
In-Reply-To: <1460476663-24890-2-git-send-email-matthew.auld@intel.com>
On ti, 2016-04-12 at 16:57 +0100, Matthew Auld wrote:
> For the gen6/gen8_allocate_va_range functions remove the WARN_ON range
> sanity checks in favour of simply hardening the allocation paths. This
> also fixes the inconsistency in which we don't always handle the
> potential overflow in our checks.
>
Not sure this is the right thing to do. I think I do prefer erroring
out on invalid arguments as we're talking of internal programmer
interface.
Regards, Joonas
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem_gtt.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 5ed713d..fa583d5 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -1220,15 +1220,6 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm,
> uint32_t pdpes = I915_PDPES_PER_PDP(dev);
> int ret;
>
> - /* Wrap is never okay since we can only represent 48b, and we don't
> - * actually use the other side of the canonical address space.
> - */
> - if (WARN_ON(start + length < start))
> - return -ENODEV;
> -
> - if (WARN_ON(start + length > vm->total))
> - return -ENODEV;
> -
> ret = alloc_gen8_temp_bitmaps(&new_page_dirs, &new_page_tables, pdpes);
> if (ret)
> return ret;
> @@ -1370,6 +1361,8 @@ static int gen8_alloc_va_range(struct i915_address_space *vm,
> {
> struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
>
> + length = min_t(uint64_t, length, vm->total);
> +
> if (USES_FULL_48BIT_PPGTT(vm->dev))
> return gen8_alloc_va_range_4lvl(vm, &ppgtt->pml4, start, length);
> else
> @@ -1860,11 +1853,9 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
> uint32_t pde, temp;
> int ret;
>
> - if (WARN_ON(start_in + length_in > ppgtt->base.total))
> - return -ENODEV;
> -
> start = start_save = start_in;
> - length = length_save = length_in;
> + length = length_save = length_in = min_t(uint64_t, length_in,
> + ppgtt->base.total);
>
> bitmap_zero(new_page_tables, I915_PDES);
>
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-04-18 13:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-12 15:57 [PATCH 1/5] drm/i915: use dev_priv directly in gen8_ppgtt_notify_vgt Matthew Auld
2016-04-12 15:57 ` [PATCH 2/5] drm/i915: harden allocation paths in allocate_va_range Matthew Auld
2016-04-18 13:13 ` Joonas Lahtinen [this message]
2016-04-12 15:57 ` [PATCH 3/5] drm/i915: bail in alloc_pdp when !FULL_48BIT_PPGTT Matthew Auld
2016-04-18 13:19 ` Joonas Lahtinen
2016-04-12 15:57 ` [PATCH 4/5] drm/i915: call kunmap_px on pt_vaddr Matthew Auld
2016-04-18 13:26 ` Joonas Lahtinen
2016-04-19 14:28 ` Mika Kuoppala
2016-04-12 15:57 ` [PATCH 5/5] drm/i915: Propagate error from drm_gem_object_init() Matthew Auld
2016-04-19 11:45 ` Joonas Lahtinen
2016-04-13 14:39 ` ✗ Fi.CI.BAT: failure for series starting with [1/5] drm/i915: use dev_priv directly in gen8_ppgtt_notify_vgt Patchwork
2016-04-18 12:51 ` [PATCH 1/5] " Joonas Lahtinen
2016-04-18 13:11 ` Chris Wilson
2016-04-18 13:28 ` Joonas Lahtinen
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=1460985207.6027.5.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
/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.