summaryrefslogtreecommitdiff
path: root/rust/helpers
diff options
context:
space:
mode:
authorShivam Kalra <shivamkalra98@zohomail.in>2026-05-23 00:24:32 +0530
committerMiguel Ojeda <ojeda@kernel.org>2026-05-27 20:01:04 +0200
commit880fa3a1e5c493d0deafe9153f8c2bed427b9428 (patch)
treefce5cbfa6ecb4bcb3829e0efa8c97660b306f769 /rust/helpers
parent4a44b17406cb5a93f90af3df9392b3a45eb336fb (diff)
downloadlinux-stable-880fa3a1e5c493d0deafe9153f8c2bed427b9428.tar.gz
linux-stable-880fa3a1e5c493d0deafe9153f8c2bed427b9428.zip
rust: helpers: add is_vmalloc_addr wrapper for NOMMU builds
Commit 47ac2a4b5cd8 ("rust: kvec: implement shrink_to for KVVec") introduced a call to bindings::is_vmalloc_addr(). However, this fails to compile on architectures where CONFIG_MMU is disabled, resulting in the following build error: error[E0425]: cannot find function `is_vmalloc_addr` in crate `bindings` --> rust/kernel/alloc/kvec.rs:781:32 | 781 | if !unsafe { bindings::is_vmalloc_addr(self.ptr.as_ptr().cast()) } { | ^^^^^^^^^^^^^^^ not found in `bindings` When CONFIG_MMU is not set, is_vmalloc_addr() is defined as a static inline function in <linux/mm.h> that unconditionally returns false. Because bindgen skips static inline functions when generating bindings, the symbol is completely missing from the Rust bindings crate. Fix this by providing a C helper wrapper, rust_helper_is_vmalloc_addr(), in rust/helpers/vmalloc.c. This ensures the function is reliably exposed to Rust regardless of the MMU configuration. On NOMMU builds, this allows KVVec::shrink_to() to successfully compile and correctly route all allocations through the kmalloc realloc path. Fixes: 47ac2a4b5cd8 ("rust: kvec: implement shrink_to for KVVec") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202605220811.LRplxeBR-lkp@intel.com/ Signed-off-by: Shivam Kalra <shivamkalra98@zohomail.in> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260523-is-vmalloc-addr-build-fix-v1-1-73c919440c41@zohomail.in [ Pasted exact compiler output and expanded it. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/helpers')
-rw-r--r--rust/helpers/vmalloc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/helpers/vmalloc.c b/rust/helpers/vmalloc.c
index 326b030487a2..6aed13292313 100644
--- a/rust/helpers/vmalloc.c
+++ b/rust/helpers/vmalloc.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/mm.h>
#include <linux/vmalloc.h>
__rust_helper void *__must_check __realloc_size(2)
@@ -8,3 +9,8 @@ rust_helper_vrealloc_node_align(const void *p, size_t size, unsigned long align,
{
return vrealloc_node_align(p, size, align, flags, node);
}
+
+__rust_helper bool rust_helper_is_vmalloc_addr(const void *x)
+{
+ return is_vmalloc_addr(x);
+}