提交 a05d80ee 编写于 作者: M Mika Kuoppala 提交者: Daniel Vetter

drm/i915/gtt: Check va range against vm size

Check the allocation area against the known end
of address space instead of against fixed value.

v2: Return ENODEV on internal bugs (Chris)
Signed-off-by: NMika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: NMichel Thierry <michel.thierry@intel.com>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 5b7e4c9c
...@@ -757,9 +757,6 @@ static int gen8_ppgtt_alloc_page_directories(struct i915_hw_ppgtt *ppgtt, ...@@ -757,9 +757,6 @@ static int gen8_ppgtt_alloc_page_directories(struct i915_hw_ppgtt *ppgtt,
WARN_ON(!bitmap_empty(new_pds, GEN8_LEGACY_PDPES)); WARN_ON(!bitmap_empty(new_pds, GEN8_LEGACY_PDPES));
/* FIXME: upper bound must not overflow 32 bits */
WARN_ON((start + length) > (1ULL << 32));
gen8_for_each_pdpe(pd, pdp, start, length, temp, pdpe) { gen8_for_each_pdpe(pd, pdp, start, length, temp, pdpe) {
if (pd) if (pd)
continue; continue;
...@@ -859,7 +856,10 @@ static int gen8_alloc_va_range(struct i915_address_space *vm, ...@@ -859,7 +856,10 @@ static int gen8_alloc_va_range(struct i915_address_space *vm,
* actually use the other side of the canonical address space. * actually use the other side of the canonical address space.
*/ */
if (WARN_ON(start + length < start)) if (WARN_ON(start + length < start))
return -ERANGE; return -ENODEV;
if (WARN_ON(start + length > ppgtt->base.total))
return -ENODEV;
ret = alloc_gen8_temp_bitmaps(&new_page_dirs, &new_page_tables); ret = alloc_gen8_temp_bitmaps(&new_page_dirs, &new_page_tables);
if (ret) if (ret)
...@@ -1304,7 +1304,7 @@ static void gen6_initialize_pt(struct i915_address_space *vm, ...@@ -1304,7 +1304,7 @@ static void gen6_initialize_pt(struct i915_address_space *vm,
} }
static int gen6_alloc_va_range(struct i915_address_space *vm, static int gen6_alloc_va_range(struct i915_address_space *vm,
uint64_t start, uint64_t length) uint64_t start_in, uint64_t length_in)
{ {
DECLARE_BITMAP(new_page_tables, I915_PDES); DECLARE_BITMAP(new_page_tables, I915_PDES);
struct drm_device *dev = vm->dev; struct drm_device *dev = vm->dev;
...@@ -1312,11 +1312,15 @@ static int gen6_alloc_va_range(struct i915_address_space *vm, ...@@ -1312,11 +1312,15 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
struct i915_hw_ppgtt *ppgtt = struct i915_hw_ppgtt *ppgtt =
container_of(vm, struct i915_hw_ppgtt, base); container_of(vm, struct i915_hw_ppgtt, base);
struct i915_page_table *pt; struct i915_page_table *pt;
const uint32_t start_save = start, length_save = length; uint32_t start, length, start_save, length_save;
uint32_t pde, temp; uint32_t pde, temp;
int ret; int ret;
WARN_ON(upper_32_bits(start)); if (WARN_ON(start_in + length_in > ppgtt->base.total))
return -ENODEV;
start = start_save = start_in;
length = length_save = length_in;
bitmap_zero(new_page_tables, I915_PDES); bitmap_zero(new_page_tables, I915_PDES);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册