From mboxrd@z Thu Jan 1 00:00:00 1970 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 AB471606A32E for ; Sun, 29 Nov 2026 11:56:33 +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=RP60wHB1 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04CA210E7F2; Sun, 29 Nov 2026 11:56:28 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AE4B10E7F2 for ; Sun, 29 Nov 2026 11:56:22 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 2DB5060D7C; Sun, 29 Nov 2026 11:56:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98C6C1F00896; Sun, 29 Nov 2026 11:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795953380; bh=MWTmRIqyxkIpUBTPYAk43V3YR64YPdOeRhjGfb4iF5Y=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RP60wHB16YCy41UTuTRBrnZNAGnItAlp1xu/+dsWrAdcexa73sTf6zMqn6D32GyvK 0fINTmHnH7QPOGTDYGA0qM7CLYKf98ohcO4ujmf4RSlJJH77fWPv4HKMvkhX4f4pDD pRfzfgq4KHJwuTsBeWKTB8DJn8b4QSbKPbqNWfhLLRg9FQF717uLAiQ2U68nlsinPO 62URZ3g6JhnaacxQ5nEDNKJP7VauuF5rkjDO1qzrgD3h/KGx9OjdE7QFSqe/C0V3IQ yE5nvV4eMMEsBYTh2c2+hKYgyGWWB2/2R/tHKa/rayWkFLFaHxgfmQywsQ4DeNvKlv RTRMY88+f9x/w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 11/14] accel/thames: Install memory mappings populated and dirty To: "Tomeu Vizoso" Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org In-Reply-To: <20261129-thames-v4-11-003b1e3365bf@tomeuvizoso.net> References: <20261129-thames-v4-0-003b1e3365bf@tomeuvizoso.net> <20261129-thames-v4-11-003b1e3365bf@tomeuvizoso.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 11:56:20 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" 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: - [Medium] accel/thames: unzapped partial PFN mapping on error in thames_gem_shmem_mmap() -- commit 4ae1719a36f423f47f5340a069ad63c6b97c835f Author: Tomeu Vizoso accel/thames: Install memory mappings populated and dirty This commit replaces drm_gem_shmem_object_mmap() with a custom mmap handler that populates page-backed buffers upfront using remap_pfn_range() with dirty and writable PTEs. > diff --git a/drivers/accel/thames/thames_gem.c b/drivers/accel/thames/tha= mes_gem.c > index 3c2846bb5297d..930444a732e78 100644 > --- a/drivers/accel/thames/thames_gem.c > +++ b/drivers/accel/thames/thames_gem.c > @@ -834,6 +834,50 @@ static void thames_gem_shmem_bo_free(struct drm_gem_= object *obj) > drm_gem_shmem_free(&bo->shmem); > } > =20 > +/* > + * Every page installed now, dirty and writable: they are pinned for the > + * object's life, and the helper would take two faults on each. > + */ > +static int thames_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_a= rea_struct *vma) > +{ > + struct thames_gem_object *bo =3D to_thames_bo(obj); > + unsigned long addr =3D vma->vm_start; > + struct scatterlist *sg; > + pgprot_t prot; > + unsigned int i; > + int ret; > + > + if (vma_is_cow_mapping(vma)) > + return -EINVAL; > + > + vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); > + > + prot =3D vm_get_page_prot(vma->vm_flags); > + if (vma->vm_flags & VM_WRITE) > + prot =3D pte_pgprot(pte_mkdirty(pte_mkwrite_novma(pfn_pte(0, prot)))); > + vma->vm_page_prot =3D prot; > + > + for_each_sgtable_sg(bo->shmem.sgt, sg, i) { > + unsigned long len =3D min_t(unsigned long, sg->length, vma->vm_end - a= ddr); > + > + ret =3D remap_pfn_range(vma, addr, page_to_pfn(sg_page(sg)), len, prot= ); > + if (ret) > + return ret; [Severity: Medium] If remap_pfn_range() fails after earlier scatterlist segments have already been mapped, does returning without zapping [vma->vm_start, addr) leave stale writable PTEs live while the GEM object is freed? remap_pfn_range_notrack() only zaps the single [addr, addr + len) range that failed, and VM_PFNMAP mappings do not hold page references. On error, drm_gem_mmap_obj() and drm_gem_mmap() drop their references to obj before __mmap_new_file_vma() calls unmap_region(). If another thread has closed the GEM handle concurrently, drm_gem_object_put() frees the backing shmem pages while other threads sharing vma->vm_mm can still write to [vma->vm_start, addr). Calling zap_vma_ptes(vma, vma->vm_start, addr - vma->vm_start) before returning on error would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-thames-v4-= 0-003b1e3365bf@tomeuvizoso.net?part=3D11