The patch titled Subject: alloc_tag: avoid execmem_vmap() when !MMU has been added to the -mm mm-unstable branch. Its filename is alloc_tag-populate-memory-for-module-tags-as-needed-fix.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/alloc_tag-populate-memory-for-module-tags-as-needed-fix.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Suren Baghdasaryan <surenb@xxxxxxxxxx> Subject: alloc_tag: avoid execmem_vmap() when !MMU Date: Thu, 31 Oct 2024 16:36:11 -0700 With CONFIG_MMU=n __get_vm_area_node() is not available. Add CONFIG_MMU dependency for memory allocation tagging since it uses __get_vm_area_node() via execmem_vmap(). Link: https://lkml.kernel.org/r/20241031233611.3833002-1-surenb@xxxxxxxxxx Fixes: 57bc3834fb6f ("alloc_tag: populate memory for module tags as needed") Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> Reported-by: kernel test robot <lkp@xxxxxxxxx> Closes: https://lore.kernel.org/oe-kbuild-all/202410250808.dQGyYjlk-lkp@xxxxxxxxx/ Closes: https://lore.kernel.org/oe-lkp/202410251525.9f85854d-oliver.sang@xxxxxxxxx Closes: https://lore.kernel.org/oe-kbuild-all/202410261016.IO7C6Cml-lkp@xxxxxxxxx/ Closes: https://lore.kernel.org/oe-kbuild-all/202410270919.LebQlmxD-lkp@xxxxxxxxx/ Suggested-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Ard Biesheuvel <ardb@xxxxxxxxxx> Cc: Borislav Petkov (AMD) <bp@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> Cc: Daniel Gomez <da.gomez@xxxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Dennis Zhou <dennis@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Jonathan Corbet <corbet@xxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Kalesh Singh <kaleshsingh@xxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Kent Overstreet <kent.overstreet@xxxxxxxxx> Cc: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Cc: Luis Chamberlain <mcgrof@xxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: Paul E. McKenney <paulmck@xxxxxxxxxx> Cc: Petr Pavlu <petr.pavlu@xxxxxxxx> Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx> Cc: Sami Tolvanen <samitolvanen@xxxxxxxxxx> Cc: Sourav Panda <souravpanda@xxxxxxxxxx> Cc: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Thomas Huth <thuth@xxxxxxxxxx> Cc: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Xiongwei Song <xiongwei.song@xxxxxxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/execmem.h | 2 ++ lib/Kconfig.debug | 1 + mm/execmem.c | 32 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 16 deletions(-) --- a/include/linux/execmem.h~alloc_tag-populate-memory-for-module-tags-as-needed-fix +++ a/include/linux/execmem.h @@ -139,6 +139,7 @@ void *execmem_alloc(enum execmem_type ty */ void execmem_free(void *ptr); +#ifdef CONFIG_MMU /** * execmem_vmap - create virtual mapping for EXECMEM_MODULE_DATA memory * @size: size of the virtual mapping in bytes @@ -148,6 +149,7 @@ void execmem_free(void *ptr); * Return: the area descriptor on success or %NULL on failure. */ struct vm_struct *execmem_vmap(size_t size); +#endif /** * execmem_update_copy - copy an update to executable memory --- a/lib/Kconfig.debug~alloc_tag-populate-memory-for-module-tags-as-needed-fix +++ a/lib/Kconfig.debug @@ -993,6 +993,7 @@ config CODE_TAGGING config MEM_ALLOC_PROFILING bool "Enable memory allocation profiling" default n + depends on MMU depends on PROC_FS depends on !DEBUG_FORCE_WEAK_PER_CPU select CODE_TAGGING --- a/mm/execmem.c~alloc_tag-populate-memory-for-module-tags-as-needed-fix +++ a/mm/execmem.c @@ -64,6 +64,22 @@ static void *execmem_vmalloc(struct exec return p; } + +struct vm_struct *execmem_vmap(size_t size) +{ + struct execmem_range *range = &execmem_info->ranges[EXECMEM_MODULE_DATA]; + struct vm_struct *area; + + area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, + range->start, range->end, NUMA_NO_NODE, + GFP_KERNEL, __builtin_return_address(0)); + if (!area && range->fallback_start) + area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, + range->fallback_start, range->fallback_end, + NUMA_NO_NODE, GFP_KERNEL, __builtin_return_address(0)); + + return area; +} #else static void *execmem_vmalloc(struct execmem_range *range, size_t size, pgprot_t pgprot, unsigned long vm_flags) @@ -368,22 +384,6 @@ void execmem_free(void *ptr) vfree(ptr); } -struct vm_struct *execmem_vmap(size_t size) -{ - struct execmem_range *range = &execmem_info->ranges[EXECMEM_MODULE_DATA]; - struct vm_struct *area; - - area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, - range->start, range->end, NUMA_NO_NODE, - GFP_KERNEL, __builtin_return_address(0)); - if (!area && range->fallback_start) - area = __get_vm_area_node(size, range->alignment, PAGE_SHIFT, VM_ALLOC, - range->fallback_start, range->fallback_end, - NUMA_NO_NODE, GFP_KERNEL, __builtin_return_address(0)); - - return area; -} - void *execmem_update_copy(void *dst, const void *src, size_t size) { return text_poke_copy(dst, src, size); _ Patches currently in -mm which might be from surenb@xxxxxxxxxx are maple_tree-add-mas_for_each_rev-helper.patch alloc_tag-introduce-shutdown_mem_profiling-helper-function.patch alloc_tag-load-module-tags-into-separate-contiguous-memory.patch alloc_tag-populate-memory-for-module-tags-as-needed.patch alloc_tag-populate-memory-for-module-tags-as-needed-fix.patch alloc_tag-introduce-pgtag_ref_handle-to-abstract-page-tag-references.patch alloc_tag-support-for-page-allocation-tag-compression.patch mm-convert-mm_lock_seq-to-a-proper-seqcount.patch mm-introduce-mmap_lock_speculation_beginend.patch mm-codetag-uninline-and-move-pgalloc_tag_copy-and-pgalloc_tag_split.patch