File tree 1 file changed +10
-2
lines changed
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)
310
310
return 0 ;
311
311
}
312
312
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
+
313
320
/**
314
321
* xe_gt_tlb_invalidation_range - Issue a TLB invalidation on this GT for an
315
322
* address range
@@ -334,6 +341,7 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
334
341
struct xe_device * xe = gt_to_xe (gt );
335
342
#define MAX_TLB_INVALIDATION_LEN 7
336
343
u32 action [MAX_TLB_INVALIDATION_LEN ];
344
+ u64 length = end - start ;
337
345
int len = 0 ;
338
346
339
347
xe_gt_assert (gt , fence );
@@ -346,11 +354,11 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
346
354
347
355
action [len ++ ] = XE_GUC_ACTION_TLB_INVALIDATION ;
348
356
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 ) {
350
359
action [len ++ ] = MAKE_INVAL_OP (XE_GUC_TLB_INVAL_FULL );
351
360
} else {
352
361
u64 orig_start = start ;
353
- u64 length = end - start ;
354
362
u64 align ;
355
363
356
364
if (length < SZ_4K )
You can’t perform that action at this time.
0 commit comments