From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41F2B3EBF00 for ; Fri, 13 Feb 2026 16:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770998946; cv=none; b=KoSsc9IcXw0JaBzF0qOXI2J2X2I9W6R/EhVHxMJfp21HWdmipnrn2PyQFFaRhuXrluo+ceojNUuUJPrfNurGoVcDuNphZ4qd59OTH8e21AR43oMhMzlPn1jG1w3fCZ1ajVHoJ2b29mRLN6ry5ruKSkBBsZSIHgsUcC3FpE4BFiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770998946; c=relaxed/simple; bh=Ls6DLuPppt++OUuRQ6xwFCkMXMyMu5nd6Xeei1Fy3MA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AHZ3LF+45oIQTEvqne/CcQ+b+sucOq71Wh/eN4GHqKmjdvHMQj+oioDPUUTEoFHuedWmoNUY1BpWyqWyQJWuiOKOC7E4JONPLDPPfRqc0x6fKhv4GtAxJ9G5mHOEwT6IyMrTDDprBr5XPtiX1o/ILRLfb+qiR4UACLTBmdxcwd4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=hMu75Rel; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hMu75Rel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=+MW+1p3xe29QSUgIu2RYNKe1kB/sRfBR1x8LhxaKz1E=; b=hMu75RelIkxHK6uOuV1YKqU7dN DnEIQr3TdF0Qw6OviHEVcDcQgkOdlFky1tkWi+OqmgSEqJ7Ul+IcY7GO3sDhU9XlhIDyLr888dZuv KmpivRSm9r3sM3fs95HTzU++TMUJRjoyql+l8pnNvagzNd+OnDuhp/bm75Gytz315QCrpRDwAHi8Z O2WjuLsDQho3HjbKiOeShR9r3P9HJFlkL9T9TC8bZ94O8PzWbHoKGZLQ2nXEVAssqxi76uxXlEY3z T9c7LEQKLndWNZ6qJ0LrtDatUfS4wUExsC7G+b1Jvf4l0wTwAcjJduSMpUfIWYIhq5/vu+Zj75K/t I/X3PA3A==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vqviz-0000000FxKr-2YBG; Fri, 13 Feb 2026 16:08:57 +0000 Date: Fri, 13 Feb 2026 16:08:57 +0000 From: Matthew Wilcox To: Sumit Garg Cc: op-tee@lists.trustedfirmware.org, jens.wiklander@linaro.org, vbabka@suse.cz, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Sumit Garg , Marco Felsch , Sven =?iso-8859-1?Q?P=FCschel?= Subject: Re: [RFT PATCH] tee: shm: Remove refcounting of kernel pages Message-ID: References: <20260213113317.1728769-1-sumit.garg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260213113317.1728769-1-sumit.garg@kernel.org> On Fri, Feb 13, 2026 at 05:03:17PM +0530, Sumit Garg wrote: > From: Sumit Garg Um, this patch is exactly the patch I sent. You're stealing my authorship! This patch should have my From: and Signed-off-by: lines. Your role in this is "handling and transporting the patch" (see Documentation/process/submitting-patches.rst). By all means take credit for writing the commit message. > Earlier TEE subsystem assumed to refcount all the memory pages to be > shared with TEE implementation to be refcounted. However, the slab > allocations within the kernel don't allow refcounting kernel pages. > > It is rather better to trust the kernel clients to not free pages while > being shared with TEE implementation. Hence, remove refcounting of kernel > pages from register_shm_helper() API. > > Fixes: b9c0e49abfca ("mm: decline to manipulate the refcount on a slab page") > Reported-by: Marco Felsch > Reported-by: Sven Püschel > Suggested-by: Matthew Wilcox > Signed-off-by: Sumit Garg > --- > drivers/tee/tee_shm.c | 29 +---------------------------- > 1 file changed, 1 insertion(+), 28 deletions(-) > > diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c > index 4a47de4bb2e5..54e2ba3afb25 100644 > --- a/drivers/tee/tee_shm.c > +++ b/drivers/tee/tee_shm.c > @@ -23,29 +23,11 @@ struct tee_shm_dma_mem { > struct page *page; > }; > > -static void shm_put_kernel_pages(struct page **pages, size_t page_count) > -{ > - size_t n; > - > - for (n = 0; n < page_count; n++) > - put_page(pages[n]); > -} > - > -static void shm_get_kernel_pages(struct page **pages, size_t page_count) > -{ > - size_t n; > - > - for (n = 0; n < page_count; n++) > - get_page(pages[n]); > -} > - > static void release_registered_pages(struct tee_shm *shm) > { > if (shm->pages) { > if (shm->flags & TEE_SHM_USER_MAPPED) > unpin_user_pages(shm->pages, shm->num_pages); > - else > - shm_put_kernel_pages(shm->pages, shm->num_pages); > > kfree(shm->pages); > } > @@ -477,13 +459,6 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags, > goto err_put_shm_pages; > } > > - /* > - * iov_iter_extract_kvec_pages does not get reference on the pages, > - * get a reference on them. > - */ > - if (iov_iter_is_kvec(iter)) > - shm_get_kernel_pages(shm->pages, num_pages); > - > shm->offset = off; > shm->size = len; > shm->num_pages = num_pages; > @@ -497,10 +472,8 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags, > > return shm; > err_put_shm_pages: > - if (!iov_iter_is_kvec(iter)) > + if (iter_is_uvec(iter)) > unpin_user_pages(shm->pages, shm->num_pages); > - else > - shm_put_kernel_pages(shm->pages, shm->num_pages); > err_free_shm_pages: > kfree(shm->pages); > err_free_shm: > -- > 2.51.0 >