Now that we support wrap-static-fns we no longer need the custom helper. Signed-off-by: Alistair Francis <alistair@xxxxxxxxxxxxx> Tested-by: Dirk Behme <dirk.behme@xxxxxxxxxxxx> --- rust/bindgen_static_functions | 3 +++ rust/helpers/helpers.c | 6 ++---- rust/helpers/uaccess.c | 15 --------------- rust/kernel/uaccess.rs | 5 +++-- 4 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 rust/helpers/uaccess.c diff --git a/rust/bindgen_static_functions b/rust/bindgen_static_functions index 8bc291a7a799..ec48ad2e8c78 100644 --- a/rust/bindgen_static_functions +++ b/rust/bindgen_static_functions @@ -27,3 +27,6 @@ --allowlist-function get_task_struct --allowlist-function put_task_struct + +--allowlist-function copy_from_user +--allowlist-function copy_to_user diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index 2731ddf736dd..eae067fe2528 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions - * cannot be called either. This file explicitly creates functions ("helpers") - * that wrap those so that they can be called from Rust. + * Non-trivial C macros cannot be used in Rust. This file explicitly creates + * functions ("helpers") that wrap those so that they can be called from Rust. * * Sorted alphabetically. */ @@ -21,7 +20,6 @@ #include "slab.c" #include "spinlock.c" #include "task.c" -#include "uaccess.c" #include "vmalloc.c" #include "wait.c" #include "workqueue.c" diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c deleted file mode 100644 index f49076f813cd..000000000000 --- a/rust/helpers/uaccess.c +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include <linux/uaccess.h> - -unsigned long rust_helper_copy_from_user(void *to, const void __user *from, - unsigned long n) -{ - return copy_from_user(to, from, n); -} - -unsigned long rust_helper_copy_to_user(void __user *to, const void *from, - unsigned long n) -{ - return copy_to_user(to, from, n); -} diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs index cc044924867b..d8f75de93073 100644 --- a/rust/kernel/uaccess.rs +++ b/rust/kernel/uaccess.rs @@ -226,7 +226,8 @@ pub fn read_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> Result { } // SAFETY: `out_ptr` points into a mutable slice of length `len`, so we may write // that many bytes to it. - let res = unsafe { bindings::copy_from_user(out_ptr, self.ptr as *const c_void, len) }; + let res = + unsafe { bindings::copy_from_user(out_ptr, self.ptr as *const c_void, len as u64) }; if res != 0 { return Err(EFAULT); } @@ -330,7 +331,7 @@ pub fn write_slice(&mut self, data: &[u8]) -> Result { } // SAFETY: `data_ptr` points into an immutable slice of length `len`, so we may read // that many bytes from it. - let res = unsafe { bindings::copy_to_user(self.ptr as *mut c_void, data_ptr, len) }; + let res = unsafe { bindings::copy_to_user(self.ptr as *mut c_void, data_ptr, len as u64) }; if res != 0 { return Err(EFAULT); } -- 2.47.1