From: Natalie Vock <nat@pixelcluster.dev>
To: "Christian König" <christian.koenig@amd.com>,
"Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Felix Kuehling" <Felix.Kuehling@amd.com>,
"Rajneesh Bhardwaj" <rajneesh.bhardwaj@amd.com>,
"Shashank Sharma" <shashank.sharma@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
kernel-dev@igalia.com
Subject: Re: [PATCH 3/4] drm/amdgpu: don't free mapping when amdgpu_vm_update_range fails
Date: Tue, 15 Sep 2026 10:53:43 +0200 [thread overview]
Message-ID: <acc1e3eb-264c-4591-9f66-5fe93b96f97f@pixelcluster.dev> (raw)
In-Reply-To: <9c507259-f65c-4f18-8fc7-8e03de0c4f87@amd.com>
On 9/15/26 10:33, Christian König wrote:
> On 9/14/26 22:25, Thadeu Lima de Souza Cascardo wrote:
>> If amdgpu_vm_update_range fails when called by amdgpu_vm_clear_freed,
>> the clearing of that mapping will not be attempted again. Later on, when
>> an IB tries to read that mapping, the read succeeds, leading to a
>> potential info leak, or even data corruption, if it attempts to write to
>> it.
>>
>> If the mapping is left in the freed list, then clearing will be
>> attempted again during amdgpu_cs_ioctl, which will either fail and not
>> submit the job or will succeed in clearing the mapping, preventing the
>> invalid access.
>
> Same as I replied to oushinnyo <oushinnyo@163.com>, absolutely clear NAK to that.
>
> amdgpu_vm_update_range() can only fail when the device is hot removed and we don't care about clearing page tables in that case.
Actually, how so? The SDMA update path has lots of allocations that
happen at random points throughout the update process (think the SDMA IB
being exhausted, then vm_funcs->update() will allocate a new one and can
fail on that, or various fence allocations. Some paths allocate from the
delayed IB pool which is just regular GFP_KERNEL, why couldn't these
allocations fail?
Aside from that, the more trivial failure path that I think Thadeu is
also talking about here is that amdgpu_vm_ptes_update will call
amdgpu_vm_pt_alloc (so that happens in the middle of VM updates) and
these allocations can fail. I'm not even sure if drm_exec can save this
one because we need to be ready to drop locks and retry.
I get that failing is unacceptable for the cases inside a pagefault
handler (though I'm not sure if anything of what I mentioned applies
here, pagefault VM updates are immediate so they get GFP_ATOMIC, but
maybe the pagefault handler could still allocate PTs?) but for anything
else, failure seems like a possibility and maybe we should think about
handling it in some way.
I'm not sure I see a problem in keeping BOs invalidated and backing off
later, since new submissions should be rejected unless the VM manages to
complete all updates successfully.
Best,
Natalie
>
> Regards,
> Christian.
>
>>
>> Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
>> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> index 09037df76400..5bde36754607 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> @@ -1594,16 +1594,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
>> while (!list_empty(&vm->freed)) {
>> mapping = list_first_entry(&vm->freed,
>> struct amdgpu_bo_va_mapping, list);
>> - list_del(&mapping->list);
>>
>> r = amdgpu_vm_update_range(adev, vm, false, false, true, false,
>> &sync, mapping->start, mapping->last,
>> 0, 0, 0, NULL, NULL, &f);
>> - amdgpu_vm_free_mapping(adev, vm, mapping, f);
>> if (r) {
>> dma_fence_put(f);
>> goto error_free;
>> }
>> + list_del(&mapping->list);
>> + amdgpu_vm_free_mapping(adev, vm, mapping, f);
>> }
>>
>> if (fence && f) {
>>
>
next prev parent reply other threads:[~2026-09-15 8:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 20:25 [PATCH 0/4] drm/amdgpu: fix bugs when amdgpu_vm_ptes_update fails Thadeu Lima de Souza Cascardo
2026-09-14 20:25 ` [PATCH 1/4] drm/amdgpu: make amdgpu_vm_sdma_commit handle NULL or empty job Thadeu Lima de Souza Cascardo
2026-09-14 20:25 ` [PATCH 2/4] drm/amdgpu: make amdgpu_vm_update_funcs commit return void Thadeu Lima de Souza Cascardo
2026-09-14 20:25 ` [PATCH 3/4] drm/amdgpu: don't free mapping when amdgpu_vm_update_range fails Thadeu Lima de Souza Cascardo
2026-09-14 20:43 ` sashiko-bot
2026-09-15 8:33 ` Christian König
2026-09-15 8:53 ` Natalie Vock [this message]
2026-09-15 10:37 ` Thadeu Lima de Souza Cascardo
2026-09-15 11:22 ` Christian König
2026-09-15 11:34 ` Thadeu Lima de Souza Cascardo
2026-09-15 13:56 ` Christian König
2026-09-23 13:56 ` Thadeu Lima de Souza Cascardo
2026-09-23 13:58 ` Christian König
2026-09-23 14:18 ` Thadeu Lima de Souza Cascardo
2026-09-23 14:51 ` Christian König
2026-09-14 20:25 ` [PATCH 4/4] drm/amdgpu: commit pending work when amdgpu_vm_ptes_update fails Thadeu Lima de Souza Cascardo
2026-09-14 20:42 ` 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=acc1e3eb-264c-4591-9f66-5fe93b96f97f@pixelcluster.dev \
--to=nat@pixelcluster.dev \
--cc=Felix.Kuehling@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=cascardo@igalia.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-dev@igalia.com \
--cc=rajneesh.bhardwaj@amd.com \
--cc=shashank.sharma@amd.com \
--cc=simona@ffwll.ch \
--cc=tvrtko.ursulin@igalia.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 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.