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 1/5] accel/amdxdna: refuse an I/O memory mapping of an imported BO
Date: Wed, 19 Aug 2026 13:39:10 -0700 [thread overview]
Message-ID: <3d677570-2204-016c-efde-779b07e76538@amd.com> (raw)
In-Reply-To: <20260817230707.356828-2-taimuraz@kaitmazov.com>
On 8/17/26 16:07, Taimuraz Kaitmazov wrote:
> amdxdna_gem_vmap() flattens the iosys_map drm_gem_vmap() fills in down to
> the void * in abo->mem.kva, and iosys_map is discriminated by is_iomem, so
> an exporter answering with an I/O mapping leaves a void __iomem pointer
> there, which amdxdna_cmd_set_error() memsets and memcpys through.
>
> amdxdna_drm_va_tbl takes a dmabuf_fd, so such a BO can be any exporter's
> buffer. amdgpu cannot reach this: its .pin forces GTT for a non peer to
> peer attachment like ours. An exporter on drm_gem_prime_dmabuf_ops has
> no .pin, and drm_gem_ttm_vmap() answers iomem for a VRAM resident
> object, so an NPU paired with nouveau or radeon does.
>
> Drop such a mapping and answer NULL. Checking here rather than in the
> .vmap callback leaves that callback's iosys_map contract intact for a
> caller equipped to read I/O memory, and covers everything that takes a
> plain kernel address through this helper. vmw_gem_vmap() refuses the
> same case; unlike that one this path is reachable from an unprivileged
> ioctl, so it neither warns nor logs at error level.
>
> Signed-off-by: Taimuraz Kaitmazov <taimuraz@kaitmazov.com>
> ---
> drivers/accel/amdxdna/amdxdna_gem.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index cca84fa07e9d..f88b5349cd4b 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -209,10 +209,15 @@ void *amdxdna_gem_vmap(struct amdxdna_gem_obj *abo)
>
> if (!abo->mem.kva) {
> ret = drm_gem_vmap(to_gobj(abo), &map);
> - if (ret)
> + if (ret) {
> XDNA_ERR(abo->client->xdna, "Vmap bo failed, ret %d", ret);
> - else
> + } else if (map.is_iomem) {
> + /* Callers use the result as an ordinary kernel address. */
> + XDNA_DBG(abo->client->xdna, "Vmap bo returned I/O memory");
> + drm_gem_vunmap(to_gobj(abo), &map);
> + } else {
> abo->mem.kva = map.vaddr;
> + }
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
> }
> return abo->mem.kva;
> }
next prev parent reply other threads:[~2026-08-19 20:39 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 ` [PATCH v4 0/5] accel/amdxdna: SYNC_BO correctness fixes Lizhi Hou
[not found] ` <20260817230707.356828-2-taimuraz@kaitmazov.com>
2026-08-19 20:39 ` Lizhi Hou [this message]
[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=3d677570-2204-016c-efde-779b07e76538@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