From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795953381; b=ew3J4kPMw56ZTlpivpsEVOtFEL+feBbqA8Rv0fpAntkMlrF8/LRBYFFFnSHHuNm0nrr5 gjf3zTcIay4IcyCaHrN7WZwtRrpzAkI2Ztre07iIM/hKImA9Lvu+KKXLKiT5nWjwnGbFj m6ctzQwNuNe8pJmXI9f9A6htg+fofZyBp1nVfKiEpTzhAvq5QOY/xrEbgtjaX4yq4Nlx2 xIczvzMt7ASKuMcwUEWhgUpPhA58FCcMxYbfnCuQP9mP9pP4BrfjEq7rxYXZkRPwsEITD O18Zp9g01Vus9rF62z6oLyl0uls8ak+3wuBjNSnNEdrZNPlXnKhFoPB7yGE6mli5Uuw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795953381; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=MWTmRIqyxkIpUBTPYAk43V3YR64YPdOeRhjGfb4iF5Y=; b=DPxsJPotQIU6e35GLIViu2dc7GBOnEUMcRDs+HqQBucGtVphqKcXgt0TAADCiCZdRchN sjFeU3Y80R2sR+iyHB/N9S1dCCwit2Pbt0es1Mk/FsotU8Hi/LITG5q+jzMdnHGOqhnUD DRZ0fdUsbHtjk1qt/HuKGKlOETWb9DPCMksPK64/kvY2jvhTYORFZBCRyqZ9CKb/+QNVL mDCSISoqpOW7iIxOK8eWkaRFbpPsI6eo5VnCWvACRtzX9WYqg/DtrDgCfa5f78qMLHEvO m2v0j2gIHHdYzdbcxqun48ErW4po9mxkIdofRYMgO8STRyuQmiN/Kig9GwiF3ngyB6w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RP60wHB1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F409606A330 for ; Sun, 29 Nov 2026 11:56:21 +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: 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 Reply-To: sashiko-reviews@lists.linux.dev 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-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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