Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthew Brost" <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/xe: Do not clear SVM device memory allocations up front
Date: Tue, 29 Sep 2026 18:27:18 +0000	[thread overview]
Message-ID: <20260929182718.CA0AA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929181024.2743854-4-matthew.brost@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] xe/svm: oversized chunk lengths in migration cause kernel panic
--

commit ed6428a65926a64520b6fe556921289286c9c71f
Author: Matthew Brost <matthew.brost@intel.com>

    drm/xe: Do not clear SVM device memory allocations up front

The patch updates SVM device memory allocations to skip initial clearing
by using XE_BO_FLAG_SKIP_CLEAR. Instead, only sparse areas without CPU
source data are cleared explicitly during migration using the new
xe_svm_clear_vram() function.

> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
> index f39e647512ad9..1b4d1222fbb7e 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
[ ... ]
> @@ -586,6 +586,124 @@ static void xe_svm_copy_us_stats_incr(struct xe_gt *gt,
[ ... ]
> +static int xe_svm_clear_vram(struct page **pages, unsigned long npages,
> +			     struct dma_fence **fence,
> +			     struct dma_fence **deps)
> +{
[ ... ]
> +		/* Not contiguous with the pending clear, or chunk is full */
> +		if (count && (addr != vram_addr + count * PAGE_SIZE ||
> +			      count + nr > XE_MIGRATE_CHUNK_SIZE / PAGE_SIZE)) {
> +			err = xe_svm_clear_vram_chunk(vr, vram_addr, count,
> +						      fence, deps);
> +			if (err)
> +				return err;
> +			count = 0;
> +		}
> +
> +		if (!count)
> +			vram_addr = addr;
> +		count += nr;
> +		i += nr;

[Severity: High]
Does this logic allow oversized chunks to bypass the chunk size limit?

If a single device folio exceeds the 8MB limit (e.g., THP or 1GB huge pages)
and is the first page processed in a chunk (where count == 0), the check
is skipped.

This would cause the oversized nr to be added to count directly, which later
gets passed to xe_svm_clear_vram_chunk() and xe_migrate_clear_vram().

Could this trigger a kernel panic via an xe_assert() or cause hardware
corruption by emitting oversized memory copy commands that exceed max
parameters?

[ ... ]
> @@ -617,7 +746,6 @@ static int xe_svm_copy(struct page **pages,
>  		u64 __vram_addr;
>  		bool match = false, chunk, last;
>  
> -#define XE_MIGRATE_CHUNK_SIZE	SZ_8M
>  		chunk = (i - pos) == (XE_MIGRATE_CHUNK_SIZE / PAGE_SIZE);
>  		last = (i + 1) == npages;

[Severity: High]
Can i - pos entirely overshoot the exact equality check here and later
in the function?

Further down in xe_svm_copy(), the chunk flag is updated for large orders:

			if (pagemap_addr[i].order) {
				i += NR_PAGES(pagemap_addr[i].order) - 1;
				chunk = (i - pos) == (XE_MIGRATE_CHUNK_SIZE / PAGE_SIZE);
				last = (i + 1) == npages;
			}

If a large system folio's NR_PAGES (such as a 1GB huge page) is added to i,
could i - pos jump completely over the exact XE_MIGRATE_CHUNK_SIZE boundary,
causing chunk to evaluate to false?

This would bypass the chunk splitting, resulting in an oversized transfer length
passed to xe_migrate_to_vram() or xe_migrate_from_vram(), which could lead to
hardware command corruption and a GPU hang.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260929181024.2743854-1-matthew.brost@intel.com?part=3

  reply	other threads:[~2026-09-29 18:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 18:10 [PATCH 0/3] Elide clear on full SVM copies Matthew Brost
2026-09-29 18:10 ` [PATCH 1/3] drm/xe: Add XE_BO_FLAG_SKIP_CLEAR Matthew Brost
2026-09-29 18:10 ` [PATCH 2/3] drm/xe: Add xe_migrate_clear_vram Matthew Brost
2026-09-29 18:10 ` [PATCH 3/3] drm/xe: Do not clear SVM device memory allocations up front Matthew Brost
2026-09-29 18:27   ` sashiko-bot [this message]
2026-09-29 18:31     ` Matthew Brost
2026-09-29 20:16   ` Summers, Stuart
2026-09-29 21:14     ` Matthew Brost
2026-09-29 22:05       ` Summers, Stuart
2026-09-29 23:21         ` Matthew Brost
2026-09-29 18:18 ` ✓ CI.KUnit: success for Elide clear on full SVM copies Patchwork
2026-09-29 19:36 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-30  0:17 ` ✗ Xe.CI.FULL: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929182718.CA0AA1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox