File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,13 @@ int xe_gt_tlb_invalidation_ggtt(struct xe_gt *gt)
322322 return 0 ;
323323}
324324
325+ /*
326+ * Ensure that roundup_pow_of_two(length) doesn't overflow.
327+ * Note that roundup_pow_of_two() operates on unsigned long,
328+ * not on u64.
329+ */
330+ #define MAX_RANGE_TLB_INVALIDATION_LENGTH (rounddown_pow_of_two(ULONG_MAX))
331+
325332/**
326333 * xe_gt_tlb_invalidation_range - Issue a TLB invalidation on this GT for an
327334 * address range
@@ -346,6 +353,7 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
346353 struct xe_device * xe = gt_to_xe (gt );
347354#define MAX_TLB_INVALIDATION_LEN 7
348355 u32 action [MAX_TLB_INVALIDATION_LEN ];
356+ u64 length = end - start ;
349357 int len = 0 ;
350358
351359 xe_gt_assert (gt , fence );
@@ -358,11 +366,11 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
358366
359367 action [len ++ ] = XE_GUC_ACTION_TLB_INVALIDATION ;
360368 action [len ++ ] = 0 ; /* seqno, replaced in send_tlb_invalidation */
361- if (!xe -> info .has_range_tlb_invalidation ) {
369+ if (!xe -> info .has_range_tlb_invalidation ||
370+ length > MAX_RANGE_TLB_INVALIDATION_LENGTH ) {
362371 action [len ++ ] = MAKE_INVAL_OP (XE_GUC_TLB_INVAL_FULL );
363372 } else {
364373 u64 orig_start = start ;
365- u64 length = end - start ;
366374 u64 align ;
367375
368376 if (length < SZ_4K )
You can’t perform that action at this time.
0 commit comments