Skip to content

Commit 9cb46b3

Browse files
hghimiralucasdemarchi
authored andcommitted
drm/xe/xe_migrate: Cast to output precision before multiplying operands
Addressing potential overflow in result of multiplication of two lower precision (u32) operands before widening it to higher precision (u64). -v2 Fix commit message and description. (Rodrigo) Cc: Rodrigo Vivi <[email protected]> Signed-off-by: Himal Prasad Ghimiray <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]> (cherry picked from commit 3482096) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent a8ad871 commit 9cb46b3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,15 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
227227
if (vm->flags & XE_VM_FLAG_64K && level == 1)
228228
flags = XE_PDE_64K;
229229

230-
entry = vm->pt_ops->pde_encode_bo(bo, map_ofs + (level - 1) *
230+
entry = vm->pt_ops->pde_encode_bo(bo, map_ofs + (u64)(level - 1) *
231231
XE_PAGE_SIZE, pat_index);
232232
xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE * level, u64,
233233
entry | flags);
234234
}
235235

236236
/* Write PDE's that point to our BO. */
237237
for (i = 0; i < num_entries - num_level; i++) {
238-
entry = vm->pt_ops->pde_encode_bo(bo, i * XE_PAGE_SIZE,
238+
entry = vm->pt_ops->pde_encode_bo(bo, (u64)i * XE_PAGE_SIZE,
239239
pat_index);
240240

241241
xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE +
@@ -291,7 +291,7 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
291291
#define VM_SA_UPDATE_UNIT_SIZE (XE_PAGE_SIZE / NUM_VMUSA_UNIT_PER_PAGE)
292292
#define NUM_VMUSA_WRITES_PER_UNIT (VM_SA_UPDATE_UNIT_SIZE / sizeof(u64))
293293
drm_suballoc_manager_init(&m->vm_update_sa,
294-
(map_ofs / XE_PAGE_SIZE - NUM_KERNEL_PDE) *
294+
(size_t)(map_ofs / XE_PAGE_SIZE - NUM_KERNEL_PDE) *
295295
NUM_VMUSA_UNIT_PER_PAGE, 0);
296296

297297
m->pt_bo = bo;
@@ -490,7 +490,7 @@ static void emit_pte(struct xe_migrate *m,
490490
struct xe_vm *vm = m->q->vm;
491491
u16 pat_index;
492492
u32 ptes;
493-
u64 ofs = at_pt * XE_PAGE_SIZE;
493+
u64 ofs = (u64)at_pt * XE_PAGE_SIZE;
494494
u64 cur_ofs;
495495

496496
/* Indirect access needs compression enabled uncached PAT index */

0 commit comments

Comments
 (0)