From: sashiko-bot@kernel.org
To: "Matthew Brost" <matthew.brost@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: Account for NULL pages in ttm_pool_backup
Date: Fri, 26 Jun 2026 08:00:10 +0000 [thread overview]
Message-ID: <20260626080011.070D01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626074653.1326683-1-matthew.brost@intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Missing HighMem check causes NULL pointer dereference in CPA subsystem on 32-bit x86.
- [High] Severe performance degradation and IPI storms due to unbatched TLB flushes.
Pre-existing issues:
- [High] Double dma_unmap_page() occurs if backup fails on the first page and is retried.
--
commit 45896340105924fcd05f25382e4001c011252d32
Author: Matthew Brost <matthew.brost@intel.com>
drm/ttm: Account for NULL pages in ttm_pool_backup
This commit fixes a NULL pointer dereference in ttm_pool_backup by
switching from the batched set_pages_array_wb() to set_pages_wb() after
validating that each page is not NULL.
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index 278bbe7a11add..2636bf1005925 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
[ ... ]
> + order = ttm_pool_page_order(pool, page);
> + num_pages = 1UL << order;
>
> +#ifdef CONFIG_X86
> + /* Anything returned to the system needs to be cached. */
> + if (tt->caching != ttm_cached)
> + set_pages_wb(page, 1 << order);
[Severity: High]
When shrinking GPU buffers under memory pressure on 32-bit x86 systems, can
this cause a NULL pointer dereference in the CPA subsystem?
The previous implementation using set_pages_array_wb() had an internal check
for HighMem pages. Since page_address(page) returns NULL for HighMem pages,
passing them directly to set_pages_wb() calls set_memory_wb(0, numpages),
which triggers a warning and -EFAULT in __cpa_process_fault().
Should there be a !PageHighMem(page) check here?
[Severity: High]
Additionally, does replacing the batched set_pages_array_wb() with per-chunk
set_pages_wb() calls inside this loop cause an IPI storm?
For highly fragmented buffer objects, calling set_pages_wb() on every
allocation chunk will trigger a cross-CPU IPI for TLB invalidation each time,
potentially leading to severe latency spikes or soft lockups.
> +#endif
> +
> + if (tt->dma_address)
> + ttm_pool_unmap(pool, tt->dma_address[i],
> + num_pages);
[Severity: High]
This is a pre-existing issue, but does this unmap lead to a double
dma_unmap_page() if the backup fails and is retried?
If ttm_backup_backup_page() returns ENOMEM for the first page, the loop
aborts and returns a negative error without setting TTM_TT_FLAG_BACKED_UP.
Because this loop has already unmapped the DMA addresses unconditionally
without clearing the pointers in the array, a subsequent retry from the
shrinker will execute this loop again, calling dma_unmap_page() on the same
IOVA addresses.
> + if (flags->purge) {
> + shrunken += num_pages;
> + page->private = 0;
> + __free_pages_gpu_account(page, order, false);
> + memset(tt->pages + i, 0,
> + num_pages * sizeof(*tt->pages));
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260626074653.1326683-1-matthew.brost@intel.com?part=1
next prev parent reply other threads:[~2026-06-26 8:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 7:46 [PATCH] drm/ttm: Account for NULL pages in ttm_pool_backup Matthew Brost
2026-06-26 8:00 ` sashiko-bot [this message]
2026-06-29 11:30 ` ✗ CI.checkpatch: warning for " Patchwork
2026-06-29 11:32 ` ✓ CI.KUnit: success " Patchwork
2026-06-29 12:12 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-29 14:01 ` ✗ 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=20260626080011.070D01F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.