mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Taimuraz Kaitmazov <taimuraz@kaitmazov.com>, <mamin506@gmail.com>,
	<ogabbay@kernel.org>
Cc: <christian.koenig@amd.com>, <sumit.semwal@linaro.org>,
	<alexdeucher@gmail.com>, <max.zhen@amd.com>,
	<sonal.santan@amd.com>, <dri-devel@lists.freedesktop.org>,
	<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
	<linaro-mm-sig@lists.linaro.org>
Subject: Re: [PATCH v4 0/5] accel/amdxdna: SYNC_BO correctness fixes
Date: Wed, 19 Aug 2026 09:30:29 -0700	[thread overview]
Message-ID: <74575f6e-8284-882b-2a53-f804f92b439f@amd.com> (raw)
In-Reply-To: <1bd1644d-bc8a-45b7-af72-af64bc35ccb6@kaitmazov.com>


On 8/18/26 14:40, Taimuraz Kaitmazov wrote:
> Patch 1 needs a prerequisite. It makes amdxdna_gem_vmap() answer NULL 
> on an iomem exporter, and the eight amdxdna_cmd_get_payload() callers 
> in aie2_message.c check neither the pointer nor the length it leaves 
> unwritten there. A command BO can be an import, so patch 1 alone turns 
> a silent __iomem write into a NULL deref with an uninitialised length.
> https://lore.kernel.org/all/20260818002459.377641-1-taimuraz@kaitmazov.com/ 
>

amdxdna_cmd_get_op() is always called before amdxdna_cmd_get_payload() 
for the same BO, and since amdxdna_gem_vmap() caches its results, the 
vmap inside get_payload() is currently guaranteed to succeed. The patch 
is therefore defensive rather than fixing a currently reachable crash.

Lizhi

>
> fixes the callers. Happy to respin on top if you prefer them together.
>
> Taimuraz
>
> On 8/18/26 02:07, Taimuraz Kaitmazov wrote:
>> Five fixes in and around amdxdna_drm_sync_bo_ioctl().
>>
>> Patch 1 refuses an I/O memory mapping the driver would otherwise 
>> store as
>> if it were an ordinary kernel address. Patch 2 checks the device-BO 
>> range
>> for overflow. Patch 4 refuses a flush of an imported BO, which is why
>> patch 3 comes first: the ioctl answers a rejected flush with drm_WARN(),
>> so without it an ordinary sync on an imported BO splats. Patch 5 stops
>> the ioctl reporting failure for a flush that succeeded.
>>
>> v3's zero-length patch has left this series. On hardware it turns out to
>> be a page fault in drm_clflush_virt_range() rather than the tidy-up its
>> commit message described, so it is a -fixes patch now, sent 
>> separately as
>> "accel/amdxdna: return early from a zero-length flush" with Fixes: and
>> Cc: stable. Patch 4 here needs its hunk, so this series wants that one
>> first.
>>
>> Changes in v4:
>>    - patch 1: the is_iomem check moved from the .vmap callback into
>>      amdxdna_gem_vmap(), per Lizhi, and it logs at debug level rather 
>> than
>>      error, since an unprivileged caller can repeat it.
>>    - new patch 3: an unprivileged SYNC_BO with an out-of-range offset
>>      already reaches that drm_WARN() today. Sashiko's review of v3 3/3
>>      flagged the same thing.
>>    - new patch 4: refuses the flush for every imported BO, as asked.
>>    - new patch 5: the debug-BO sync I mentioned on the v2 thread. 
>> Only a BO
>>      attached with ATTACH_DEBUG_BO has an assigned hwctx, so every other
>>      FROM_DEVICE sync ends in -EINVAL with its flush already done. The
>>      -EINVAL reproduces on a Strix Point NPU.
>>
>> On patch 4, one consequence worth deciding before it lands. A heap BO is
>> created through amdxdna_drm_create_share_bo(), so a device running on
>> carveout memory reaches its heap through a cbuf, is_import_bo() is 
>> true of
>> it, and SYNC_BO on every AMDXDNA_BO_DEV now answers -EOPNOTSUPP. Today
>> that path flushes nothing anyway -- amdxdna_cbuf_map() fills in only the
>> DMA address and length, so drm_clflush_sg() walks zero pages -- so the
>> change is silent no-op to hard error, and XRT's dbg_buffer::sync() 
>> reaches
>> it without Debug.force_driver_sync. If you would rather keep our own
>> exporters working, I have the variant keyed on the exporter's ops, which
>> confines the refusal to foreign buffers. Say which you prefer.
>>
>> v3: 
>> https://lore.kernel.org/all/20260813164700.43960-1-taimuraz@kaitmazov.com/
>>
>> Built on drm-misc-next, each commit on its own: x86_64 with
>> DRM_ACCEL_AMDXDNA=m, clang 22.1.8, no warnings. Patch 5's reproducer was
>> run against 7.1.8's in-tree driver, where that call is unchanged.
>>
>> Taimuraz Kaitmazov (5):
>>    accel/amdxdna: refuse an I/O memory mapping of an imported BO
>>    accel/amdxdna: check the sync range for overflow on a device BO
>>    accel/amdxdna: do not warn when a sync request is rejected
>>    accel/amdxdna: refuse to flush an imported BO
>>    accel/amdxdna: do not fail a sync for a BO with no debug context
>>
>>   drivers/accel/amdxdna/amdxdna_ctx.c |  3 ++-
>>   drivers/accel/amdxdna/amdxdna_gem.c | 27 +++++++++++++++++++--------
>>   2 files changed, 21 insertions(+), 9 deletions(-)
>>
>
>

       reply	other threads:[~2026-08-19 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260817230707.356828-1-taimuraz@kaitmazov.com>
     [not found] ` <1bd1644d-bc8a-45b7-af72-af64bc35ccb6@kaitmazov.com>
2026-08-19 16:30   ` Lizhi Hou [this message]
     [not found] ` <20260817230707.356828-2-taimuraz@kaitmazov.com>
2026-08-19 20:39   ` [PATCH v4 1/5] accel/amdxdna: refuse an I/O memory mapping of an imported BO Lizhi Hou
     [not found] ` <20260817230707.356828-3-taimuraz@kaitmazov.com>
2026-08-19 20:49   ` [PATCH v4 2/5] accel/amdxdna: check the sync range for overflow on a device BO Lizhi Hou
     [not found] ` <20260817230707.356828-4-taimuraz@kaitmazov.com>
2026-08-19 20:57   ` [PATCH v4 3/5] accel/amdxdna: do not warn when a sync request is rejected Lizhi Hou
     [not found] ` <20260817230707.356828-5-taimuraz@kaitmazov.com>
2026-08-19 21:00   ` [PATCH v4 4/5] accel/amdxdna: refuse to flush an imported BO Lizhi Hou
     [not found] ` <20260817230707.356828-6-taimuraz@kaitmazov.com>
2026-08-19 21:05   ` [PATCH v4 5/5] accel/amdxdna: do not fail a sync for a BO with no debug context Lizhi Hou

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=74575f6e-8284-882b-2a53-f804f92b439f@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=alexdeucher@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mamin506@gmail.com \
    --cc=max.zhen@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=sonal.santan@amd.com \
    --cc=sumit.semwal@linaro.org \
    --cc=taimuraz@kaitmazov.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

all inboxes | Powered by JetHome®