Re: [PATCH v4 2/3] rust: uaccess: add method to get UserPtr from u64

From: Gary Guo

Date: Sat Nov 21 2026 - 11:21:42 EST


On Wed Oct 21, 2026 at 1:06 AM BST, Deborah Brouwer wrote:
> Currently a UserPtr can be created from a usize integer representing a
> userspace address. To create a UserPtr from a u64 integer, the u64 must
> be cast to usize. On 32-bit systems, this cast will discard the upper 32
> bits of the address.
>
> Provide a new method to create a UserPtr from a u64 integer. This avoids
> the caller having to cast before creating a UserPtr and also clarifies
> that the truncation is intended. This is equivalent to the C-side
> macro u64_to_user_ptr() that provides typechecking and casting to a __user
> pointer.
>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> ---
> rust/kernel/uaccess.rs | 9 +++++++++
> 1 file changed, 9 insertions(+)