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 @@ -322,6 +322,13 @@ int xe_gt_tlb_invalidation_ggtt(struct xe_gt *gt)
322
322
return 0 ;
323
323
}
324
324
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
+
325
332
/**
326
333
* xe_gt_tlb_invalidation_range - Issue a TLB invalidation on this GT for an
327
334
* address range
@@ -346,6 +353,7 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
346
353
struct xe_device * xe = gt_to_xe (gt );
347
354
#define MAX_TLB_INVALIDATION_LEN 7
348
355
u32 action [MAX_TLB_INVALIDATION_LEN ];
356
+ u64 length = end - start ;
349
357
int len = 0 ;
350
358
351
359
xe_gt_assert (gt , fence );
@@ -358,11 +366,11 @@ int xe_gt_tlb_invalidation_range(struct xe_gt *gt,
358
366
359
367
action [len ++ ] = XE_GUC_ACTION_TLB_INVALIDATION ;
360
368
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 ) {
362
371
action [len ++ ] = MAKE_INVAL_OP (XE_GUC_TLB_INVAL_FULL );
363
372
} else {
364
373
u64 orig_start = start ;
365
- u64 length = end - start ;
366
374
u64 align ;
367
375
368
376
if (length < SZ_4K )
You can’t perform that action at this time.
0 commit comments