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 7E03C60A2600 for ; Wed, 18 Nov 2026 14:52:39 +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=dmMB1JqZ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0810810FD56; Wed, 18 Nov 2026 14:52:34 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7365010FD56; Wed, 18 Nov 2026 14:52:27 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 968F662290; Wed, 18 Nov 2026 14:52:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A35461F000C4; Wed, 18 Nov 2026 14:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795013546; bh=u4fw6wH7cRG89Xgv9DmNPTYzRhO7v7keamB5liM55x0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=dmMB1JqZH1zCDAONsrZJ5AXpbtBhioXa5f2XoqUI4Tl4ece9yzguQMNNy7LcKcbU/ SFXKxhz60iY7aZB/cKWhVkx2kI3mvr9wpdq5vhKxwcGSYKWzyPIkU95mFq6dr4X2C5 8tVA+8eO+zY1sJU/8a3biSSof6aItdm5RnJ++Q3LbsjRB+MXCn4VBH0ycBgldRitLK TGKrEbeTSrAOAqVWJtDMKtfqbC7gQt794hyCBK6KLy4pjGdTSqKxfTn6assRS7ijQh IeipmuUfsmYzdar26x9qGw0mPzJfuqLKDdQ7mu2oIcFU5WCAbmwqAccEBhhK5qzqky CIG+yJLR4jpPQ== Date: Wed, 18 Nov 2026 16:52:10 +0200 From: Mike Rapoport To: Tal Zussman Cc: Andrew Morton , Peter Xu , James Houghton , Andrea Arcangeli , Suren Baghdasaryan , Balbir Singh , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pedro Falcato , David Hildenbrand , Michal Hocko , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Andrei Vagin , Muhammad Usama Anjum , Stephen Rothwell , Arnd Bergmann , Zi Yan , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Kiryl Shutsemau , Muchun Song , Oscar Salvador , =?utf-8?Q?Miko=C5=82aj?= Lenczewski , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Lyude Paul , Danilo Krummrich , Felix Kuehling , Jason Gunthorpe , Leon Romanovsky , dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: Re: [PATCH v3 8/9] mm/migrate_device: do not migrate a uffd-protected zero page Message-ID: References: <20261117-uffd-state-fixes-v3-0-b617009d1a4a@columbia.edu> <20261117-uffd-state-fixes-v3-8-b617009d1a4a@columbia.edu> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261117-uffd-state-fixes-v3-8-b617009d1a4a@columbia.edu> 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: , Sender: "amd-gfx" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On Tue, Nov 17, 2026 at 11:28:48PM -0500, Tal Zussman wrote: > Device migration replaces a PTE that maps the zero page with a new PTE > that is built only from the VMA flags, so its userfaultfd WP or RWP > protection is lost. The same applies to the huge zero PMD. Writes and > accesses to the page are then no longer reported to userfaultfd. > > To fix it, do not migrate a uffd-protected zero page. Skip it during > collection, and check again under the page table lock before inserting, > as another thread can protect the page after it was collected. > > The alternative would be to carry the uffd state over to the new entry, > but a uffd-protected zero page in a range that a driver migrates should > be rare. > > While at it, read the PMD once with pmdp_get() in > migrate_vma_collect_huge_pmd(). > > Fixes: 292924b26024 ("userfaultfd: wp: apply _PAGE_UFFD_WP bit") > Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages") > Cc: Thomas Hellström > Cc: Lyude Paul > Cc: Danilo Krummrich > Cc: Felix Kuehling > Cc: Jason Gunthorpe > Cc: Leon Romanovsky > Cc: dri-devel@lists.freedesktop.org > Cc: intel-xe@lists.freedesktop.org > Cc: nouveau@lists.freedesktop.org > Cc: amd-gfx@lists.freedesktop.org > Reviewed-by: Alistair Popple > Signed-off-by: Tal Zussman Acked-by: Mike Rapoport (Microsoft) > --- > include/linux/userfaultfd_k.h | 24 ++++++++++++++++++++++++ > mm/migrate_device.c | 34 ++++++++++++++++++++++++++-------- > 2 files changed, 50 insertions(+), 8 deletions(-) -- Sincerely yours, Mike.