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 @@ -310,6 +310,13 @@ int xe_gt_tlb_invalidation_ggtt(struct xe_gt *gt)
310310 return 0 ;
311311}
312312
313+ /*
314+ * Ensure that roundup_pow_of_two(length) doesn't overflow.
315+ * Note that roundup_pow_of_two() operates on unsigned long,
316+ * not on u64.
317+ */
318+ #define MAX_RANGE_TLB_INVALIDATION_LENGTH (rounddown_pow_of_two(ULONG_MAX))
319+
313320/**
314321 * xe_gt_tlb_invalidation_range - Issue a TLB invalidation on this GT for an
315322 * address range
@@ -334,6 +341,7 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
334341 struct xe_device * xe = gt_to_xe (gt );
335342#define MAX_TLB_INVALIDATION_LEN 7
336343 u32 action [MAX_TLB_INVALIDATION_LEN ];
344+ u64 length = end - start ;
337345 int len = 0 ;
338346
339347 xe_gt_assert (gt , fence );
@@ -346,11 +354,11 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
346354
347355 action [len ++ ] = XE_GUC_ACTION_TLB_INVALIDATION ;
348356 action [len ++ ] = 0 ; /* seqno, replaced in send_tlb_invalidation */
349- if (!xe -> info .has_range_tlb_invalidation ) {
357+ if (!xe -> info .has_range_tlb_invalidation ||
358+ length > MAX_RANGE_TLB_INVALIDATION_LENGTH ) {
350359 action [len ++ ] = MAKE_INVAL_OP (XE_GUC_TLB_INVAL_FULL );
351360 } else {
352361 u64 orig_start = start ;
353- u64 length = end - start ;
354362 u64 align ;
355363
356364 if (length < SZ_4K )
You can’t perform that action at this time.
0 commit comments