From: Matthew Auld <matthew.auld@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
intel-xe@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com
Subject: Re: [PATCH] drm/xe: Handle NULL TTM case in xe_bo_move
Date: Wed, 17 Sep 2025 11:01:04 +0100 [thread overview]
Message-ID: <43b64396-710d-47db-82dc-328c5169fb76@intel.com> (raw)
In-Reply-To: <20250916220604.83613-2-jonathan.cavitt@intel.com>
On 16/09/2025 23:06, Jonathan Cavitt wrote:
> It is possible for xe_bo_move to pass a NULL TTM pointer to
> xe_tt_map_sg, which would result in a NULL pointer dereference.
> Whether or not this issue realistically occurs, it would be good
> to add an error handler to guard agains this.
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> ---
> drivers/gpu/drm/xe/xe_bo.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 8422f3cab113..bfeae8fd1650 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -834,7 +834,9 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
> (!ttm && ttm_bo->type == ttm_bo_type_device);
>
> if (new_mem->mem_type == XE_PL_TT) {
> - ret = xe_tt_map_sg(xe, ttm);
> + ret = -ENOENT;
> + if (ttm)
When the destination mem_type (new_mem) needs a ttm_tt, like with PL_TT,
ttm must ensure there is a both a tt attached and that it is populated
with pages before calling into the driver bo_move(). See
ttm_bo_handle_move_mem() and the new_use_tt check. If there is no tt or
it is not populated at this point then that would be a major bug since
there would be no system memory pages to move to.
If we turn this into a normal error condition and return here the worry
is that we might then hide this bug instead of crashing early and loudly
here with NPD.
> + ret = xe_tt_map_sg(xe, ttm);
> if (ret)
> goto out;
> }
prev parent reply other threads:[~2025-09-17 10:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 22:06 [PATCH] drm/xe: Handle NULL TTM case in xe_bo_move Jonathan Cavitt
2025-09-16 22:13 ` ✓ CI.KUnit: success for " Patchwork
2025-09-16 22:49 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-17 2:41 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-17 10:01 ` Matthew Auld [this message]
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=43b64396-710d-47db-82dc-328c5169fb76@intel.com \
--to=matthew.auld@intel.com \
--cc=alex.zuo@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jonathan.cavitt@intel.com \
--cc=saurabhg.gupta@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