From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 83C8A1DFFB for ; Sun, 2 Aug 2026 16:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785687019; cv=none; b=Oe5aG3h09s8ki3bKKdbLSfvygf79MjG1ouWQI1Mz3RHTd34qkQq5cREB9OtNGe27tzAX5AMHP4yvN6HSPKGeR8UznxyXgFAQiwmnNybrYLHU5Xnum9Rokxy3mCXmtBOJMpSJkLa2WRtaHs99YyKfl8szMdHmn7iGTexYOUFXkEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785687019; c=relaxed/simple; bh=jUWQIvJK7VAr1n6xk7hSi9PosWwRPGEd7tTx/Ring9I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n52XAvLyBLXYokaQNYht9frndFyWza9wUScI/4l5NZ3AYofUjPlSOGl4sTpSW+gaC0SjRxlakF9NgeXBm3VHSrJllAYMC3masPENQm624Si2J1tlzRpG58Ca35rFWW0SMq1MBhjb4LwBiOzj1jkurJHY10d7/6yQxwLIBVPhjZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SCjHLJsC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SCjHLJsC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83B9D1F000E9; Sun, 2 Aug 2026 16:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785687018; bh=4UiUtk8mYd6dVW+H2bsjpuN7YlklJl1Nd89zFSg72gE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=SCjHLJsCHOkzsb/sh+/2f2cbgdmYzXwBRjx+yaRvSBi6iVrSvyPdXynMwbkfQZQFM i7Z7p2d3kuNnDnQiJdn54xbZVuoLOYoaEmwUgdTdJ24a7IJG7pa5qrVQVaiivj+rQs 9gqj8Elx8j+ub3Muw2P13O5bWrcn4HFE9119e+Vuk1aXW+zNta9Xo4BUOxByu9jDQi wgS5bp3vzp5gu0NqevcL1TYxe25wbx3FSnMltW5M/WcJpnMsh7F0/ntsmT8C4Antl6 8+cDwHhV2dB82x6d8amsE2fY/esZpPqAZJaaas7FzEDE0p0mhj+SFpzZ+U3hHFRN/J 95+ZwaneG3q/Q== Date: Sun, 2 Aug 2026 19:10:08 +0300 From: Mike Rapoport To: Brendan Jackman Cc: Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , David Hildenbrand , Vlastimil Babka , Wei Xu , Johannes Weiner , Zi Yan , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, Sumit Garg , Will Deacon , rientjes@google.com, "Kalyazin, Nikita" , patrick.roy@linux.dev, "Itazuri, Takahiro" , Andy Lutomirski , David Kaplan , Thomas Gleixner , Yosry Ahmed , Patrick Bellasi , Reiji Watanabe , Sean Christopherson , Nikita Kalyazin Subject: Re: [PATCH v3 03/26] mm: introduce AS_NO_DIRECT_MAP Message-ID: References: <20260726-page_alloc-unmapped-v3-0-6f5729aa9832@google.com> <20260726-page_alloc-unmapped-v3-3-6f5729aa9832@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260726-page_alloc-unmapped-v3-3-6f5729aa9832@google.com> On Sun, Jul 26, 2026 at 10:22:36PM +0000, Brendan Jackman wrote: > From: Patrick Roy > > Add AS_NO_DIRECT_MAP for mappings where direct map entries of folios are > set to not present. Currently, mappings that match this description are > secretmem mappings (memfd_secret()). Later, some guest_memfd > configurations will also fall into this category. > > Reject this new type of mappings in all locations that currently reject > secretmem mappings, on the assumption that if secretmem mappings are > rejected somewhere, it is precisely because of an inability to deal with > folios without direct map entries, and then make memfd_secret() use > AS_NO_DIRECT_MAP on its address_space to drop its special > vma_is_secretmem()/secretmem_mapping() checks. > > Use a new flag instead of overloading AS_INACCESSIBLE (which is already > set by guest_memfd) because not all guest_memfd mappings will end up > being direct map removed (e.g. in pKVM setups, parts of guest_memfd that > can be mapped to userspace should also be GUP-able, and generally not > have restrictions on who can access it). > > Signed-off-by: Patrick Roy > Signed-off-by: Nikita Kalyazin > [Moved zapping to page cache; removed review tags] > Signed-off-by: Brendan Jackman > --- > include/linux/secretmem.h | 18 -------- > mm/secretmem.c | 46 +++----------------- Lovely :) For the secretmem bits Reviewed-by: Mike Rapoport (Microsoft) > 8 files changed, 128 insertions(+), 87 deletions(-) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index 4e8b2b29f6d3e..011f6e34859cc 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -15,6 +15,7 @@ > #include > #include /* for in_interrupt() */ > #include > +#include > > struct folio_batch; > > @@ -210,6 +211,7 @@ enum mapping_flags { > AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9, > AS_KERNEL_FILE = 10, /* mapping for a fake kernel file that shouldn't > account usage to user cgroups */ > + AS_NO_DIRECT_MAP = 11, /* Folios in the mapping are not in the direct map */ > /* Bits 16-25 are used for FOLIO_ORDER */ > AS_FOLIO_ORDER_BITS = 5, > AS_FOLIO_ORDER_MIN = 16, > @@ -345,6 +347,9 @@ static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct addres > return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); > } > > +static inline unsigned int > +mapping_max_folio_order(const struct address_space *mapping); > + > static inline gfp_t mapping_gfp_mask(const struct address_space *mapping) > { > return mapping->gfp_mask; > @@ -366,6 +371,24 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) > m->gfp_mask = mask; > } > > +static inline void mapping_set_no_direct_map(struct address_space *mapping) > +{ > + WARN_ON(!can_set_direct_map()); > + /* folio_zap_direct_map() doesn't support large folios. */ > + WARN_ON(mapping_max_folio_order(mapping)); Can't we use VM_WARN_ON() here? > + set_bit(AS_NO_DIRECT_MAP, &mapping->flags); > +} ... > +#else > +static inline int prep_add_unmapped_folio(struct address_space *mapping, struct folio *folio) > +{ > + VM_WARN_ON(mapping_no_direct_map(mapping)); > + return 0; > +} > + > +static inline void prep_remove_unmapped_folio(struct address_space *mapping, > + struct folio *folio) > +{ > + VM_WARN_ON(mapping_no_direct_map(mapping)); > +} > + > +static inline void prep_remove_unmapped_batch(struct address_space *mapping, > + struct folio_batch *fbatch) > +{ > + VM_WARN_ON(mapping_no_direct_map(mapping)); > +} Heh, that's a lot of WARNings :) But I can see why you want them :) > +#endif -- Sincerely yours, Mike.