[PATCH 2/4] rust: mm: Add task_size() method to Mm

Alvin Sun
2026-04-17T01:11:36Z

Add a task_size() method to the Mm struct to expose the process
virtual address space size. This is used by the Tyr driver's VmLayout
to determine the user VA range when VmUserSize::Auto is specified.

Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
---
rust/kernel/mm.rs | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/rust/kernel/mm.rs b/rust/kernel/mm.rs
index 4764d7b68f2a7..c6ba4da52688b 100644
--- a/rust/kernel/mm.rs
+++ b/rust/kernel/mm.rs
@@ -149,6 +149,13 @@ pub fn mmget_not_zero(&self) -> Option<ARef<MmWithUser>> {
None
}
}
+
+ /// Returns task size for this mm_struct.
+ #[inline]
+ pub fn task_size(&self) -> u64 {
+ // SAFETY: self.as_raw() is a valid pointer to an mm_struct.
+ unsafe { (*self.as_raw()).__bindgen_anon_1.task_size as u64 }
+ }
}

// These methods require `mm_users` to be non-zero.

--
2.43.0