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 <rodrigo.vivi@intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240401175300.3823653-1-himal.prasad.ghimiray@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
(cherry picked from commit 34820967ae
)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
This commit is contained in:
committed by
Lucas De Marchi
parent
a8ad871547
commit
9cb46b31f3
@@ -227,7 +227,7 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
|
|||||||
if (vm->flags & XE_VM_FLAG_64K && level == 1)
|
if (vm->flags & XE_VM_FLAG_64K && level == 1)
|
||||||
flags = XE_PDE_64K;
|
flags = XE_PDE_64K;
|
||||||
|
|
||||||
entry = vm->pt_ops->pde_encode_bo(bo, map_ofs + (level - 1) *
|
entry = vm->pt_ops->pde_encode_bo(bo, map_ofs + (u64)(level - 1) *
|
||||||
XE_PAGE_SIZE, pat_index);
|
XE_PAGE_SIZE, pat_index);
|
||||||
xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE * level, u64,
|
xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE * level, u64,
|
||||||
entry | flags);
|
entry | flags);
|
||||||
@@ -235,7 +235,7 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
|
|||||||
|
|
||||||
/* Write PDE's that point to our BO. */
|
/* Write PDE's that point to our BO. */
|
||||||
for (i = 0; i < num_entries - num_level; i++) {
|
for (i = 0; i < num_entries - num_level; i++) {
|
||||||
entry = vm->pt_ops->pde_encode_bo(bo, i * XE_PAGE_SIZE,
|
entry = vm->pt_ops->pde_encode_bo(bo, (u64)i * XE_PAGE_SIZE,
|
||||||
pat_index);
|
pat_index);
|
||||||
|
|
||||||
xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE +
|
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,
|
|||||||
#define VM_SA_UPDATE_UNIT_SIZE (XE_PAGE_SIZE / NUM_VMUSA_UNIT_PER_PAGE)
|
#define VM_SA_UPDATE_UNIT_SIZE (XE_PAGE_SIZE / NUM_VMUSA_UNIT_PER_PAGE)
|
||||||
#define NUM_VMUSA_WRITES_PER_UNIT (VM_SA_UPDATE_UNIT_SIZE / sizeof(u64))
|
#define NUM_VMUSA_WRITES_PER_UNIT (VM_SA_UPDATE_UNIT_SIZE / sizeof(u64))
|
||||||
drm_suballoc_manager_init(&m->vm_update_sa,
|
drm_suballoc_manager_init(&m->vm_update_sa,
|
||||||
(map_ofs / XE_PAGE_SIZE - NUM_KERNEL_PDE) *
|
(size_t)(map_ofs / XE_PAGE_SIZE - NUM_KERNEL_PDE) *
|
||||||
NUM_VMUSA_UNIT_PER_PAGE, 0);
|
NUM_VMUSA_UNIT_PER_PAGE, 0);
|
||||||
|
|
||||||
m->pt_bo = bo;
|
m->pt_bo = bo;
|
||||||
@@ -490,7 +490,7 @@ static void emit_pte(struct xe_migrate *m,
|
|||||||
struct xe_vm *vm = m->q->vm;
|
struct xe_vm *vm = m->q->vm;
|
||||||
u16 pat_index;
|
u16 pat_index;
|
||||||
u32 ptes;
|
u32 ptes;
|
||||||
u64 ofs = at_pt * XE_PAGE_SIZE;
|
u64 ofs = (u64)at_pt * XE_PAGE_SIZE;
|
||||||
u64 cur_ofs;
|
u64 cur_ofs;
|
||||||
|
|
||||||
/* Indirect access needs compression enabled uncached PAT index */
|
/* Indirect access needs compression enabled uncached PAT index */
|
||||||
|
Reference in New Issue
Block a user