From: sashiko-bot@kernel.org
To: "David Zhang" <yidong.zhang@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH V3 14/19] accel/amdxdna: Move HMM invalidate wait into common GEM code
Date: Thu, 08 Oct 2026 03:56:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-163595@kernel.org> (raw)
In-Reply-To: <20261008032348.2044667-15-yidong.zhang@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] amdxdna: hardware DMA into freed memory due to interruptible wait in hmm_invalidate
--
commit c5bcbac3bd594f37cab09ce7ecaa29fea4a1e25a
Author: David Zhang <yidong.zhang@amd.com>
accel/amdxdna: Move HMM invalidate wait into common GEM code
This commit moves the HMM invalidate wait for user mappings into the common
GEM code within amdxdna_hmm_invalidate(). Devices that don't attach fences
to user BOs will return from the wait immediately.
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index f4832337ec31d..eebd93b6f2c31 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
[ ... ]
> @@ -249,8 +251,12 @@ static bool amdxdna_hmm_invalidate(struct mmu_interval_notifier *mni,
> mmu_interval_set_seq(&mapp->notifier, cur_seq);
> up_write(&xdna->notifier_lock);
>
> - if (xdna->dev_info->ops->hmm_invalidate)
> - xdna->dev_info->ops->hmm_invalidate(abo, cur_seq);
> + ret = dma_resv_wait_timeout(to_gobj(abo)->resv, DMA_RESV_USAGE_BOOKKEEP,
> + true, MAX_SCHEDULE_TIMEOUT);
> + if (!ret)
> + XDNA_ERR(xdna, "Failed to wait for bo, ret %ld", ret);
> + else if (ret == -ERESTARTSYS)
> + XDNA_DBG(xdna, "Wait for bo interrupted by signal");
>
> if (range->event == MMU_NOTIFY_UNMAP) {
> down_write(&xdna->notifier_lock);
[Severity: High]
Does this interruptible wait allow hardware to DMA into freed memory?
amdxdna_hmm_invalidate() is called by the OS memory subsystem when unmapping
or reclaiming memory. The driver is expected to wait for the hardware to
finish accessing the pages before returning true.
However, dma_resv_wait_timeout() is called with intr=true, which makes the
wait interruptible by signals. If the process receives a signal, the wait
aborts early and returns -ERESTARTSYS. The callback logs a debug message
but then proceeds to return true, which tells the OS that the device is no
longer accessing the memory.
Since the hardware job is still executing when the OS frees the physical
pages, can this lead to memory corruption when the hardware DMAs into those
pages?
Should this wait use intr=false to be uninterruptible in this context?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008032348.2044667-1-yidong.zhang@amd.com?part=14
next prev parent reply other threads:[~2026-10-08 3:56 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 3:23 [PATCH V3 00/19] accel/amdxdna: Kernel submission and PM for AIE4 David Zhang
2026-10-08 3:23 ` [PATCH V3 01/19] accel/amdxdna: Rename NPU3 firmware files David Zhang
2026-10-08 16:23 ` Lizhi Hou
2026-10-08 3:23 ` [PATCH V3 02/19] accel/amdxdna: Remove mmap for doorbell David Zhang
2026-10-08 3:23 ` [PATCH V3 03/19] accel/amdxdna: Add CERT firmware version support David Zhang
2026-10-08 17:12 ` Lizhi Hou
2026-10-08 17:26 ` Zhang, Yidong (David)
2026-10-08 3:23 ` [PATCH V3 04/19] accel/amdxdna: Upgrade firmware version to 6.0 David Zhang
2026-10-08 17:15 ` Lizhi Hou
2026-10-08 3:23 ` [PATCH V3 05/19] accel/amdxdna: Add NPU3 classic device support David Zhang
2026-10-08 3:44 ` sashiko-bot
2026-10-08 17:25 ` Zhang, Yidong (David)
2026-10-08 3:23 ` [PATCH V3 06/19] accel/amdxdna: Add AIE version query to aie4_get_info David Zhang
2026-10-08 3:23 ` [PATCH V3 07/19] accel/amdxdna: Add get and set power_mode for AIE4 David Zhang
2026-10-08 3:23 ` [PATCH V3 08/19] accel/amdxdna: Add clock, DPM frequency, and resource info queries " David Zhang
2026-10-08 3:48 ` sashiko-bot
2026-10-08 3:23 ` [PATCH V3 09/19] accel/amdxdna: Add context switch hysteresis with debugfs control David Zhang
2026-10-08 3:23 ` [PATCH V3 10/19] accel/amdxdna: Refactor AIE4 hardware initialization sequence David Zhang
2026-10-08 3:23 ` [PATCH V3 11/19] accel/amdxdna: Decouple AIE4 doorbell and MSI-X notify transport hooks David Zhang
2026-10-08 3:51 ` sashiko-bot
2026-10-08 3:23 ` [PATCH V3 12/19] accel/amdxdna: Implement AIE4 kernel queue lifecycle and memory layout David Zhang
2026-10-08 3:59 ` sashiko-bot
2026-10-08 3:23 ` [PATCH V3 13/19] accel/amdxdna: Prepare for AIE4 command submission David Zhang
2026-10-08 4:04 ` sashiko-bot
2026-10-08 3:23 ` [PATCH V3 14/19] accel/amdxdna: Move HMM invalidate wait into common GEM code David Zhang
2026-10-08 3:56 ` sashiko-bot [this message]
2026-10-08 3:23 ` [PATCH V3 15/19] accel/amdxdna: Make populate_range common for AIE2 and AIE4 David Zhang
2026-10-08 3:23 ` [PATCH V3 16/19] accel/amdxdna: Implement AIE4 command packet building and submission David Zhang
2026-10-08 4:10 ` sashiko-bot
2026-10-08 3:23 ` [PATCH V3 17/19] accel/amdxdna: Enable AIE4 firmware logging to DRAM David Zhang
2026-10-08 3:23 ` [PATCH V3 18/19] accel/amdxdna: Implement AIE4 suspend and resume David Zhang
2026-10-08 4:10 ` sashiko-bot
2026-10-08 3:23 ` [PATCH V3 19/19] accel/amdxdna: Implement runtime suspend and resume support David Zhang
2026-10-08 4:22 ` sashiko-bot
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=sashiko-outbox-163595@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yidong.zhang@amd.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