[Intel-gfx] [PATCH] drm/i915: Sanity check the vma->node prior to binding into the GTT

Chris Wilson chris at chris-wilson.co.uk
Fri Feb 24 21:16:37 UTC 2017


We rely on the VMA being allocated inside the drm_mm and for its alloted
node being large enough to accommodate all the vma->pages.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Matthew Auld <matthew.william.auld at gmail.com>
---
 drivers/gpu/drm/i915/i915_vma.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index a7180d73be43..68a51f8ff1d1 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -327,6 +327,9 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
 	u32 vma_flags;
 	int ret;
 
+	GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
+	GEM_BUG_ON(vma->size > vma->node.size);
+
 	if (GEM_WARN_ON(flags == 0))
 		return -EINVAL;
 
-- 
2.11.0



More information about the Intel-gfx mailing list