Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D371B606A32D for ; Thu, 26 Nov 2026 07:52:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UgHMD95P Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5505010E379; Thu, 26 Nov 2026 07:52:31 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1815C10E73D for ; Thu, 26 Nov 2026 07:52:25 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id D25AE410DF; Thu, 26 Nov 2026 07:52:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 920F51F000ED; Thu, 26 Nov 2026 07:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795679544; bh=O1hjaO0t+IO9muHQIofFhJYFnSm0rORX5IomoPaGTJ0=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=UgHMD95PrU9nP/8c/UFuJ8Q/De5py+Z3nm2yrQl6oLrnk9iB93MIaVhFaxGuDOXHJ I4zrfgxMvn1Jr8vbc3vJsEwPh4Z0/PSrY0keppkIoq13ygm8IhJidCY++CvMv7Zqye ovN4yszd1v8cjYXQ5k4bmQA7iJ8KtGs4Ko4p//ZbUqR/7XB7P7bSVH6lTmTiNtYS1l HmN1Aht7h1MVrMBH8VNqlb6uRziuZGq9OJyP74qM1DKSYZcd9xrzT1/GwWp5OgZzAx 9Vh/87Uzr0gjmgz+MeQ5r7hHgv1ioTJSOYf88IBvdY/MLtsMJNMaMUCAtwnFXJiGT9 R389hh95H2dKA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/amdgpu: keep the address of cleared PDEs with translate further To: "Bob Zhou" , amd-gfx@lists.freedesktop.org In-Reply-To: <20261126073232.2108102-1-bobzhou2@amd.com> References: <20261126073232.2108102-1-bobzhou2@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 26 Nov 2026 07:52:24 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/amdgpu: cleared PDE addr passed as incr in amdgpu_vm_pt_clear() It also noticed 1 related pre-existing issue this patch does not introduce: - [Critical] drm/amdgpu: unchecked update() return in amdgpu_vm_pte_update_flags() [1] -- commit 989da6857bfdb3b7b6591cb250770217b86c1b11 Author: Bob Zhou drm/amdgpu: keep the address of cleared PDEs with translate further This commit passes an address pointer into amdgpu_vm_pt_clear_flags() so that callers receive the PDE address generated by amdgpu_gmc_get_vm_pde() when clearing page directories. > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/= amd/amdgpu/amdgpu_vm_pt.c > index a6d389c08524f..6aabd9f5291c2 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c [ ... ] > @@ -395,7 +393,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, st= ruct amdgpu_vm *vm, > struct amdgpu_bo *ancestor =3D &vmbo->bo; > struct amdgpu_bo *bo =3D &vmbo->bo; > unsigned int entries; > - uint64_t flags; > + uint64_t value =3D 0, flags; > int r, idx; > =20 > /* Figure out our place in the hierarchy */ > @@ -430,8 +428,9 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, st= ruct amdgpu_vm *vm, > if (r) > goto exit; > =20 > - flags =3D amdgpu_vm_pt_clear_flags(adev, vm, level); > - r =3D vm->update_funcs->update(¶ms, vmbo, 0, 0, entries, 0, flags); > + flags =3D amdgpu_vm_pt_clear_flags(adev, vm, level, &value); > + r =3D vm->update_funcs->update(¶ms, vmbo, 0, 0, entries, value, > + flags); > if (r) > goto exit; > =20 [Severity: High] Does this pass value as the incr argument instead of the addr argument to vm->update_funcs->update()? drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h:struct amdgpu_vm_update_fun= cs { ... int (*update)(struct amdgpu_vm_update_params *p, struct amdgpu_bo_vm *bo, uint64_t pe, uint64_t addr, unsigned count, uint32_t incr, uint64_t flags); ... } Because addr is left at 0 and value is passed as incr, entry 0 of a cleared PDB0 on GMC v9 with translate_further enabled is still written with address 0, and subsequent entries increment by 0x1000 per entry (leaving bit 12 clear on all even entries) instead of writing value to every entry, causing GPU VM faults during page table walks. Should value be passed as the fourth argument (addr) and 0 as the sixth argument (incr)? > @@ -724,7 +723,8 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_= vm_update_params *params, > =20 > } else if (!(flags & AMDGPU_PTE_VALID) && > !(flags & AMDGPU_PTE_PRT_FLAG(params->adev))) { > - flags |=3D amdgpu_vm_pt_clear_flags(adev, params->vm, level); > + flags |=3D amdgpu_vm_pt_clear_flags(adev, params->vm, level, > + &addr); > } > =20 > /* [Severity: Critical] This problem wasn't introduced by this patch, but can amdgpu_vm_pte_update_flags() cause a NULL pointer dereference on params->job [1] by ignoring the return value of params->vm->update_funcs->update()? drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c:amdgpu_vm_sdma_update() { ... if (ndw < 32) { r =3D amdgpu_vm_sdma_commit(p, NULL); if (r) return r; r =3D amdgpu_vm_sdma_alloc_job(p, count, AMDGPU_KERNEL_JOB_ID_VM_UPDATE); if (r) return r; } ... pte =3D (uint64_t *)&(p->job->ibs->ptr[p->num_dw_left]); ... } When amdgpu_vm_sdma_commit() runs during amdgpu_vm_sdma_update() and the subsequent amdgpu_vm_sdma_alloc_job() fails, p->job is left NULL. Because amdgpu_vm_pte_update_flags() returns void and discards the error, the loop in amdgpu_vm_ptes_update() continues and the next call to amdgpu_vm_sdma_update() or amdgpu_vm_sdma_commit() dereferences the NULL p->job pointer. [1] https://sashiko.dev/#/bug/linux-1897ae3a-7a03-49b7-b2ae-54c63b21478f --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261126073232.2108= 102-1-bobzhou2@amd.com?part=3D1