On Thu, Nov 06, 2025 at 02:54:33PM +0000, Lorenzo Stoakes wrote:
Note that there is no guarantee that every flag and associated mnemonic will diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 8a9894aefbca..a420dcf9ffbb 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1147,6 +1147,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_MAYSHARE)] = "ms", [ilog2(VM_GROWSDOWN)] = "gd", [ilog2(VM_PFNMAP)] = "pf",
[ilog2(VM_LOCKED)] = "lo", [ilog2(VM_IO)] = "io", [ilog2(VM_SEQ_READ)] = "sr",[ilog2(VM_MAYBE_GUARD)] = "gu",diff --git a/include/linux/mm.h b/include/linux/mm.h index 6e5ca5287e21..2a5516bff75a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -271,6 +271,8 @@ extern struct rw_semaphore nommu_region_sem; extern unsigned int kobjsize(const void *objp); #endif
+#define VM_MAYBE_GUARD_BIT 11
/*
- vm_flags in vm_area_struct, see mm_types.h.
- When changing, update also include/trace/events/mmflags.h
@@ -296,6 +298,7 @@ extern unsigned int kobjsize(const void *objp); #define VM_UFFD_MISSING 0 #endif /* CONFIG_MMU */ #define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */ +#define VM_MAYBE_GUARD BIT(VM_MAYBE_GUARD_BIT) /* The VMA maybe contains guard regions. */
Don't we also need an adjustment on the rust side for this BIT()? Like we for f04aad36a07c ("mm/ksm: fix flag-dropping behavior in ksm_madvise").
That's a bit unhelpful if rust can't cope with extremely basic assignments like that and we just have to know to add helpers :/
We do BIT() stuff for e.g. VM_HIGH_ARCH_n, VM_UFFD_MINOR_BIT, VM_ALLOW_ANY_UNCACHED_BIT, VM_DROPPABLE_BIT and VM_SEALED_BIT too and no such helpers there, So not sure if this is required?
Alice - why is it these 'non-trivial' defines were fine but VM_MERGEABLE was problematic? That seems strange.
I see [0], so let me build rust here and see if it moans, if it moans I'll add it.
I built with CONFIG_RUST=y and everything compiles ok so seems rust is fine with it?
Strange that we need it for some things but not others though?