Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Brzezinka" <sebastian.brzezinka@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915/selftests: Fix unlocked mm.stolen in reset selftest
Date: Thu, 17 Sep 2026 11:51:04 +0000	[thread overview]
Message-ID: <20260917115105.124B81F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917113717.2852-1-sebastian.brzezinka@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm/i915/selftests: Hardware-reserved stolen memory is poisoned, causing crash
- [Low] drm/i915/selftests: TOCTOU race in GPU reset stolen memory test
--

commit 855f7a70fdf31c1c3dd9401d2d9ed883c5184a38
Author: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
Subject: drm/i915/selftests: Fix unlocked mm.stolen in reset selftest

This patch extends the stolen_lock coverage in the reset selftest to include
the poison and verify writes, not just the lookup. It also introduces a
stolen_page_unused() helper to perform the lookup.

Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/work_items/16841

> diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
> index 2cfc23c58e909..77af788314ffd 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_reset.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
[ ... ]
> @@ -95,10 +105,10 @@ __igt_reset_stolen(struct intel_gt *gt,
>  				      ggtt->error_capture.start,
>  				      PAGE_SIZE);
>  
> -		if (!__drm_mm_interval_first(&gt->i915->mm.stolen,
> -					     page << PAGE_SHIFT,
> -					     ((page + 1) << PAGE_SHIFT) - 1))
> +		mutex_lock(&gt->i915->mm.stolen_lock);
> +		if (stolen_page_unused(gt, page))
>  			memset_io(s, STACK_MAGIC, PAGE_SIZE);
> +		mutex_unlock(&gt->i915->mm.stolen_lock);

[Severity: High]
Since __igt_reset_stolen() loops over the full resource_size(&gt->i915->dsm.stolen):

	num_pages = resource_size(dsm) >> PAGE_SHIFT;
	...
	for (page = 0; page < num_pages; page++) {

will this code overwrite hardware-reserved memory regions (like WOPCM or GuC
firmware) at the top of stolen memory?

The drm_mm allocator only covers the unreserved usable_size, so queries to the
reserved region using stolen_page_unused() will return true. Writing STACK_MAGIC
to these hardware-reserved pages could destroy hardware state before triggering
a GPU reset, potentially leading to a GPU hang or system crash.

This regression appears to have been unmasked by fixing the previously
always-false !__drm_mm_interval_first() check.

[Severity: Low]
Does dropping the lock here and re-acquiring it later for the verification pass
create a race condition?

If a concurrent thread allocates, writes to, and frees a page in stolen memory
between this baseline CRC pass and the later verification pass, could the test
incorrectly attribute the modification to the GPU reset and fail spuriously?

>  
>  		in = (void __force *)s;
>  		if (i915_memcpy_from_wc(tmp, in, PAGE_SIZE))
[ ... ]
> @@ -143,16 +153,15 @@ __igt_reset_stolen(struct intel_gt *gt,
>  			in = tmp;
>  		x = crc32_le(0, in, PAGE_SIZE);
>  
> -		if (x != crc[page] &&
> -		    !__drm_mm_interval_first(&gt->i915->mm.stolen,
> -					     page << PAGE_SHIFT,
> -					     ((page + 1) << PAGE_SHIFT) - 1)) {
> +		mutex_lock(&gt->i915->mm.stolen_lock);
> +		if (x != crc[page] && stolen_page_unused(gt, page)) {

[Severity: Low]
Because the lock was dropped during the reset window, can this check guarantee
that the page remained unused throughout the entire reset window?

It appears this only checks if the page is currently unused and modified at
this specific moment, missing any concurrent use while the lock was not held.

>  			pr_debug("unused stolen page %pa modified by GPU reset\n",
>  				 &page);
>  			if (count++ == 0)
>  				igt_hexdump(in, PAGE_SIZE);
>  			max = page;
>  		}
> +		mutex_unlock(&gt->i915->mm.stolen_lock);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917113717.2852-1-sebastian.brzezinka@intel.com?part=1

  reply	other threads:[~2026-09-17 11:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 11:37 [PATCH v2] drm/i915/selftests: Fix unlocked mm.stolen in reset selftest Sebastian Brzezinka
2026-09-17 11:51 ` sashiko-bot [this message]
2026-09-17 12:49 ` ✗ i915.CI.BAT: failure for drm/i915/selftests: Fix unlocked mm.stolen in reset selftest (rev4) 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=20260917115105.124B81F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sebastian.brzezinka@intel.com \
    /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