|
Revision tags: v6.15, v6.15-rc7, v6.15-rc6, v6.15-rc5, v6.15-rc4, v6.15-rc3, v6.15-rc2, v6.15-rc1, v6.14, v6.14-rc7, v6.14-rc6 |
|
| #
dbd5058b |
| 08-Mar-2025 |
Benno Lossin <[email protected]> |
rust: make pin-init its own crate
Rename relative paths inside of the crate to still refer to the same items, also rename paths inside of the kernel crate and adjust the build system to build the cr
rust: make pin-init its own crate
Rename relative paths inside of the crate to still refer to the same items, also rename paths inside of the kernel crate and adjust the build system to build the crate.
[ Remove the `expect` (and thus the `lint_reasons` feature) since the tree now uses `quote!` from `rust/macros/export.rs`. Remove the `TokenStream` import removal, since it is now used as well.
In addition, temporarily (i.e. just for this commit) use an `--extern force:alloc` to prevent an unknown `new_uninit` error in the `rustdoc` target. For context, please see a similar case in:
https://lore.kernel.org/lkml/[email protected]/
And adjusted the message above. - Miguel ]
Signed-off-by: Benno Lossin <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Tested-by: Andreas Hindborg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
9d29c682 |
| 08-Mar-2025 |
Benno Lossin <[email protected]> |
rust: pin-init: move impl `Zeroable` for `Opaque` and `Option<KBox<T>>` into the kernel crate
In order to make pin-init a standalone crate, move kernel-specific code directly into the kernel crate.
rust: pin-init: move impl `Zeroable` for `Opaque` and `Option<KBox<T>>` into the kernel crate
In order to make pin-init a standalone crate, move kernel-specific code directly into the kernel crate. Since `Opaque<T>` and `KBox<T>` are part of the kernel, move their `Zeroable` implementation into the kernel crate.
Signed-off-by: Benno Lossin <[email protected]> Tested-by: Andreas Hindborg <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
ab2ebb7b |
| 05-Mar-2025 |
Dirk Behme <[email protected]> |
rust: types: add intra-doc links for `Opaque<T>`
We use intra-doc links wherever possible. Thus add a couple missing ones for `Opaque<T>`.
Signed-off-by: Dirk Behme <[email protected]> Review
rust: types: add intra-doc links for `Opaque<T>`
We use intra-doc links wherever possible. Thus add a couple missing ones for `Opaque<T>`.
Signed-off-by: Dirk Behme <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
|
Revision tags: v6.14-rc5, v6.14-rc4, v6.14-rc3, v6.14-rc2 |
|
| #
cd1ed11a |
| 07-Feb-2025 |
Borys Tyran <[email protected]> |
rust: improve lifetimes markup
Improve lifetimes markup; e.g. from:
/// ... 'a ...
to:
/// ... `'a` ...
This will make lifetimes display as code span with Markdown and make it more consi
rust: improve lifetimes markup
Improve lifetimes markup; e.g. from:
/// ... 'a ...
to:
/// ... `'a` ...
This will make lifetimes display as code span with Markdown and make it more consistent with rest of the docs.
Link: https://github.com/Rust-for-Linux/linux/issues/1138 Signed-off-by: Borys Tyran <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded and changed Closes tag to Link. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
|
Revision tags: v6.14-rc1, v6.13, v6.13-rc7, v6.13-rc6, v6.13-rc5, v6.13-rc4, v6.13-rc3, v6.13-rc2, v6.13-rc1 |
|
| #
c27e705c |
| 20-Nov-2024 |
Alice Ryhl <[email protected]> |
rust: kernel: add improved version of `ForeignOwnable::borrow_mut`
Previously, the `ForeignOwnable` trait had a method called `borrow_mut` that was intended to provide mutable access to the inner va
rust: kernel: add improved version of `ForeignOwnable::borrow_mut`
Previously, the `ForeignOwnable` trait had a method called `borrow_mut` that was intended to provide mutable access to the inner value. However, the method accidentally made it possible to change the address of the object being modified, which usually isn't what we want. (And when we want that, it can be done by calling `from_foreign` and `into_foreign`, like how the old `borrow_mut` was implemented.)
In this patch, we introduce an alternate definition of `borrow_mut` that solves the previous problem. Conceptually, given a pointer type `P` that implements `ForeignOwnable`, the `borrow_mut` method gives you the same kind of access as an `&mut P` would, except that it does not let you change the pointer `P` itself.
This is analogous to how the existing `borrow` method provides the same kind of access to the inner value as an `&P`.
Note that for types like `Arc`, having an `&mut Arc<T>` only gives you immutable access to the inner `T`. This is because mutable references assume exclusive access, but there might be other handles to the same reference counted value, so the access isn't exclusive. The `Arc` type implements this by making `borrow_mut` return the same type as `borrow`.
Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Updated to `crate::ffi::`. Reworded title slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
c6b97538 |
| 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: kernel: reorder `ForeignOwnable` items
`{into,from}_foreign` before `borrow` is slightly more logical.
This removes an inconsistency with `kbox.rs` which already uses this ordering.
Reviewed
rust: kernel: reorder `ForeignOwnable` items
`{into,from}_foreign` before `borrow` is slightly more logical.
This removes an inconsistency with `kbox.rs` which already uses this ordering.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded title slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
14686571 |
| 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: kernel: change `ForeignOwnable` pointer to mut
It is slightly more convenient to operate on mut pointers, and this also properly conveys the desired ownership semantics of the trait.
Reviewed
rust: kernel: change `ForeignOwnable` pointer to mut
It is slightly more convenient to operate on mut pointers, and this also properly conveys the desired ownership semantics of the trait.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded title slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
aa991a2a |
| 20-Nov-2024 |
Tamir Duberstein <[email protected]> |
rust: types: avoid `as` casts
Replace `as` casts with `cast{,_mut}` calls which are a bit safer.
In one instance, remove an unnecessary `as` cast without replacement.
Reviewed-by: Alice Ryhl <alic
rust: types: avoid `as` casts
Replace `as` casts with `cast{,_mut}` calls which are a bit safer.
In one instance, remove an unnecessary `as` cast without replacement.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
2d3bf6ff |
| 19-Dec-2024 |
Danilo Krummrich <[email protected]> |
rust: types: add `Opaque::pin_init`
Analogous to `Opaque::new` add `Opaque::pin_init`, which instead of a value `T` takes a `PinInit<T>` and returns a `PinInit<Opaque<T>>`.
Reviewed-by: Alice Ryhl
rust: types: add `Opaque::pin_init`
Analogous to `Opaque::new` add `Opaque::pin_init`, which instead of a value `T` takes a `PinInit<T>` and returns a `PinInit<Opaque<T>>`.
Reviewed-by: Alice Ryhl <[email protected]> Suggested-by: Alice Ryhl <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Tested-by: Dirk Behme <[email protected]> Tested-by: Fabien Parent <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
|
Revision tags: v6.12, v6.12-rc7, v6.12-rc6, v6.12-rc5, v6.12-rc4, v6.12-rc3, v6.12-rc2, v6.12-rc1, v6.11 |
|
| #
d072acda |
| 13-Sep-2024 |
Gary Guo <[email protected]> |
rust: use custom FFI integer types
Currently FFI integer types are defined in libcore. This commit creates the `ffi` crate and asks bindgen to use that crate for FFI integer types instead of `core::
rust: use custom FFI integer types
Currently FFI integer types are defined in libcore. This commit creates the `ffi` crate and asks bindgen to use that crate for FFI integer types instead of `core::ffi`.
This commit is preparatory and no type changes are made in this commit yet.
Signed-off-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Added `rustdoc`, `rusttest` and KUnit tests support. Rebased on top of `rust-next` (e.g. migrated more `core::ffi` cases). Reworded crate docs slightly and formatted. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
718c4069 |
| 02-Oct-2024 |
Dirk Behme <[email protected]> |
rust: types: extend `Opaque` documentation
Update the `Opaque` documentation and add an example as proposed by Miguel Ojeda in [1]. The documentation update is mainly taken from Benno Lossin's descr
rust: types: extend `Opaque` documentation
Update the `Opaque` documentation and add an example as proposed by Miguel Ojeda in [1]. The documentation update is mainly taken from Benno Lossin's description [2].
Cc: Nell Shamrell-Harrington <[email protected]> Suggested-by: Miguel Ojeda <[email protected]> Link: https://rust-for-linux.zulipchat.com/#narrow/stream/291565/topic/x/near/467478085 [1] Link: https://rust-for-linux.zulipchat.com/#narrow/stream/291565/topic/x/near/470498289 [2] Co-developed-by: Benno Lossin <[email protected]> Signed-off-by: Benno Lossin <[email protected]> Signed-off-by: Dirk Behme <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Used `expect`. Rewrapped docs. Added intra-doc link. Formatted example. Reworded to fix tag typo/order. Fixed `&mut` formatting as discussed. Added Benno's SOB and CDB as discussed. Shortened links. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
58eff8e8 |
| 04-Oct-2024 |
Danilo Krummrich <[email protected]> |
rust: treewide: switch to the kernel `Vec` type
Now that we got the kernel `Vec` in place, convert all existing `Vec` users to make use of it.
Reviewed-by: Alice Ryhl <[email protected]> Reviewe
rust: treewide: switch to the kernel `Vec` type
Now that we got the kernel `Vec` in place, convert all existing `Vec` users to make use of it.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Converted `kasan_test_rust.rs` too, as discussed. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
e8c6ccdb |
| 04-Oct-2024 |
Danilo Krummrich <[email protected]> |
rust: alloc: remove extension of std's `Box`
Now that all existing `Box` users were moved to the kernel `Box` type, remove the `BoxExt` extension and all other related extensions.
Reviewed-by: Alic
rust: alloc: remove extension of std's `Box`
Now that all existing `Box` users were moved to the kernel `Box` type, remove the `BoxExt` extension and all other related extensions.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
ce1c54fd |
| 18-Sep-2024 |
Aliet Exposito Garcia <[email protected]> |
rust: kernel: move `FromBytes` and `AsBytes` traits to a new `transmute` module
Refactor the `FromBytes` and `AsBytes` traits from `types.rs` into a new `transmute.rs` module:
- Add `rust/kernel/t
rust: kernel: move `FromBytes` and `AsBytes` traits to a new `transmute` module
Refactor the `FromBytes` and `AsBytes` traits from `types.rs` into a new `transmute.rs` module:
- Add `rust/kernel/transmute.rs` with the definitions of `FromBytes` and `AsBytes`.
- Remove the same trait definitions from `rust/kernel/types.rs`.
- Update `rust/kernel/uaccess.rs` to import `AsBytes` and `FromBytes` from `transmute.rs`.
The traits and their implementations remain unchanged.
Suggested-by: Benno Lossin <[email protected]> Link: https://github.com/Rust-for-Linux/linux/issues/1117 Signed-off-by: Aliet Exposito Garcia <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Rebased on top of the lints series and slightly reworded. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
a69dc41a |
| 01-Oct-2024 |
Alice Ryhl <[email protected]> |
rust: types: add Opaque::try_ffi_init
This will be used by the miscdevice abstractions, as the C function `misc_register` is fallible.
Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by:
rust: types: add Opaque::try_ffi_init
This will be used by the miscdevice abstractions, as the C function `misc_register` is fallible.
Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
|
Revision tags: v6.11-rc7 |
|
| #
3fcc2339 |
| 04-Sep-2024 |
Miguel Ojeda <[email protected]> |
rust: enable `clippy::ignored_unit_patterns` lint
In Rust 1.73.0, Clippy introduced the `ignored_unit_patterns` lint [1]:
> Matching with `()` explicitly instead of `_` outlines the fact that > the
rust: enable `clippy::ignored_unit_patterns` lint
In Rust 1.73.0, Clippy introduced the `ignored_unit_patterns` lint [1]:
> Matching with `()` explicitly instead of `_` outlines the fact that > the pattern contains no data. Also it would detect a type change > that `_` would ignore.
There is only a single case that requires a change:
error: matching over `()` is more explicit --> rust/kernel/types.rs:176:45 | 176 | ScopeGuard::new_with_data((), move |_| cleanup()) | ^ help: use `()` instead of `_`: `()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns = note: requested on the command line with `-D clippy::ignored-unit-patterns`
Thus clean it up and enable the lint -- no functional change intended.
Link: https://rust-lang.github.io/rust-clippy/master/index.html#/ignored_unit_patterns [1] Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Tested-by: Gary Guo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
db4f72c9 |
| 04-Sep-2024 |
Miguel Ojeda <[email protected]> |
rust: enable `clippy::undocumented_unsafe_blocks` lint
Checking that we are not missing any `// SAFETY` comments in our `unsafe` blocks is something we have wanted to do for a long time, as well as
rust: enable `clippy::undocumented_unsafe_blocks` lint
Checking that we are not missing any `// SAFETY` comments in our `unsafe` blocks is something we have wanted to do for a long time, as well as cleaning up the remaining cases that were not documented [1].
Back when Rust for Linux started, this was something that could have been done via a script, like Rust's `tidy`. Soon after, in Rust 1.58.0, Clippy implemented the `undocumented_unsafe_blocks` lint [2].
Even though the lint has a few false positives, e.g. in some cases where attributes appear between the comment and the `unsafe` block [3], there are workarounds and the lint seems quite usable already.
Thus enable the lint now.
We still have a few cases to clean up, so just allow those for the moment by writing a `TODO` comment -- some of those may be good candidates for new contributors.
Link: https://github.com/Rust-for-Linux/linux/issues/351 [1] Link: https://rust-lang.github.io/rust-clippy/master/#/undocumented_unsafe_blocks [2] Link: https://github.com/rust-lang/rust-clippy/issues/13189 [3] Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Tested-by: Gary Guo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
567cdff5 |
| 04-Sep-2024 |
Miguel Ojeda <[email protected]> |
rust: types: avoid repetition in `{As,From}Bytes` impls
In order to provide `// SAFETY` comments for every `unsafe impl`, we would need to repeat them, which is not very useful and would be harder t
rust: types: avoid repetition in `{As,From}Bytes` impls
In order to provide `// SAFETY` comments for every `unsafe impl`, we would need to repeat them, which is not very useful and would be harder to read.
We could perhaps allow the lint (ideally within a small module), but we can take the chance to avoid the repetition of the `impl`s themselves too by using a small local macro, like in other places where we have had to do this sort of thing.
Thus add the straightforward `impl_{from,as}bytes!` macros and use them to implement `FromBytes`.
This, in turn, will allow us in the next patch to place a `// SAFETY` comment that defers to the actual invocation of the macro.
Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Tested-by: Gary Guo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
d4073170 |
| 18-Sep-2024 |
Nell Shamrell-Harrington <[email protected]> |
rust: types: add examples for the `Either` type
We aim to have examples in all Rust types, thus add basic ones for the `Either` type.
Suggested-by: Miguel Ojeda <[email protected]> Signed-off-by: Ne
rust: types: add examples for the `Either` type
We aim to have examples in all Rust types, thus add basic ones for the `Either` type.
Suggested-by: Miguel Ojeda <[email protected]> Signed-off-by: Nell Shamrell-Harrington <[email protected]> Tested-by: Dirk Behme <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://rust-for-linux.zulipchat.com/#narrow/stream/291565/topic/x/near/467478085 Link: https://lore.kernel.org/r/[email protected] [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
e7572e5d |
| 15-Sep-2024 |
Alice Ryhl <[email protected]> |
rust: types: add `NotThreadSafe`
This introduces a new marker type for types that shouldn't be thread safe. By adding a field of this type to a struct, it becomes non-Send and non-Sync, which means
rust: types: add `NotThreadSafe`
This introduces a new marker type for types that shouldn't be thread safe. By adding a field of this type to a struct, it becomes non-Send and non-Sync, which means that it cannot be accessed in any way from threads other than the one it was created on.
This is useful for APIs that require globals such as `current` to remain constant while the value exists.
We update two existing users in the Kernel to use this helper:
* `Task::current()` - moving the return type of this value to a different thread would not be safe as you can no longer be guaranteed that the `current` pointer remains valid. * Lock guards. Mutexes and spinlocks should be unlocked on the same thread as where they were locked, so we enforce this using the Send trait.
There are also additional users in later patches of this patchset. See [1] and [2] for the discussion that led to the introduction of this patch.
Link: https://lore.kernel.org/all/nFDPJFnzE9Q5cqY7FwSMByRH2OAn_BpI4H53NQfWIlN6I2qfmAqnkp2wRqn0XjMO65OyZY4h6P4K2nAGKJpAOSzksYXaiAK_FoH_8QbgBI4=@proton.me/ [1] Link: https://lore.kernel.org/all/nFDPJFnzE9Q5cqY7FwSMByRH2OAn_BpI4H53NQfWIlN6I2qfmAqnkp2wRqn0XjMO65OyZY4h6P4K2nAGKJpAOSzksYXaiAK_FoH_8QbgBI4=@proton.me/ [2] Suggested-by: Benno Lossin <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Björn Roy Baron <[email protected]> Reviewed-by: Gary Guo <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
show more ...
|
|
Revision tags: v6.11-rc6, v6.11-rc5 |
|
| #
96fff2dc |
| 21-Aug-2024 |
Kartik Prajapati <[email protected]> |
rust: types: add `ARef::into_raw`
Add a method for `ARef` that is analogous to `Arc::into_raw`. It is the inverse operation of `ARef::from_raw`, and allows you to convert the `ARef` back into a raw
rust: types: add `ARef::into_raw`
Add a method for `ARef` that is analogous to `Arc::into_raw`. It is the inverse operation of `ARef::from_raw`, and allows you to convert the `ARef` back into a raw pointer while retaining ownership of the refcount.
This new function will be used by [1] for converting the type in an `ARef` using `ARef::from_raw(ARef::into_raw(me).cast())`. Alice has also needed the same function for other use-cases in the past, but [1] is the first to go upstream.
This was implemented independently by Kartik and Alice. The two versions were merged by Alice, so all mistakes are Alice's.
Link: https://lore.kernel.org/r/[email protected] [1] Link: https://github.com/Rust-for-Linux/linux/issues/1044 Signed-off-by: Kartik Prajapati <[email protected]> Co-developed-by: Alice Ryhl <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> [ Reworded to correct the author reference and changed tag to Link since it is not a bug. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
|
Revision tags: v6.11-rc4, v6.11-rc3, v6.11-rc2 |
|
| #
7adcdd57 |
| 30-Jul-2024 |
Benno Lossin <[email protected]> |
rust: types: improve `ForeignOwnable` documentation
There are no guarantees for the pointer returned by `into_foreign`. This is simply because there is no safety documentation stating any guarantees
rust: types: improve `ForeignOwnable` documentation
There are no guarantees for the pointer returned by `into_foreign`. This is simply because there is no safety documentation stating any guarantees. Therefore dereferencing and all other operations for that pointer are not allowed in a general context (i.e. when the concrete type implementing the trait is not known). This might be confusing, therefore add normal documentation to state that there are no guarantees given for the pointer.
Signed-off-by: Benno Lossin <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
6c2d0ad5 |
| 30-Jul-2024 |
Alice Ryhl <[email protected]> |
rust: implement ForeignOwnable for Pin<Box<T>>
We already implement ForeignOwnable for Box<T>, but it may be useful to store pinned data in a ForeignOwnable container. This patch makes that possible
rust: implement ForeignOwnable for Pin<Box<T>>
We already implement ForeignOwnable for Box<T>, but it may be useful to store pinned data in a ForeignOwnable container. This patch makes that possible.
This will be used together with upcoming miscdev abstractions, which Binder will use when binderfs is disabled.
Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
|
Revision tags: v6.11-rc1, v6.10, v6.10-rc7, v6.10-rc6, v6.10-rc5, v6.10-rc4, v6.10-rc3, v6.10-rc2 |
|
| #
b33bf37a |
| 28-May-2024 |
Alice Ryhl <[email protected]> |
rust: uaccess: add typed accessors for userspace pointers
Add safe methods for reading and writing Rust values to and from userspace pointers.
The C methods for copying to/from userspace use a func
rust: uaccess: add typed accessors for userspace pointers
Add safe methods for reading and writing Rust values to and from userspace pointers.
The C methods for copying to/from userspace use a function called `check_object_size` to verify that the kernel pointer is not dangling. However, this check is skipped when the length is a compile-time constant, with the assumption that such cases trivially have a correct kernel pointer.
In this patch, we apply the same optimization to the typed accessors. For both methods, the size of the operation is known at compile time to be size_of of the type being read or written. Since the C side doesn't provide a variant that skips only this check, we create custom helpers for this purpose.
The majority of reads and writes to userspace pointers in the Rust Binder driver uses these accessor methods. Benchmarking has found that skipping the `check_object_size` check makes a big difference for the cases being skipped here. (And that the check doesn't make a difference for the cases that use the raw read/write methods.)
This code is based on something that was originally written by Wedson on the old rust branch. It was modified by Alice to skip the `check_object_size` check, and to update various comments, including the notes about kernel pointers in `WritableToBytes`.
Co-developed-by: Wedson Almeida Filho <[email protected]> Signed-off-by: Wedson Almeida Filho <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Reviewed-by: Gary Guo <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Wrapped docs to 100 and added a few intra-doc links. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
|
Revision tags: v6.10-rc1, v6.9, v6.9-rc7, v6.9-rc6, v6.9-rc5, v6.9-rc4, v6.9-rc3 |
|
| #
be2ca1e0 |
| 01-Apr-2024 |
Boqun Feng <[email protected]> |
rust: types: Make Opaque::get const
To support a potential usage:
static foo: Opaque<Foo> = ..; // Or defined in an extern block.
...
fn bar() { let ptr = foo.get(); }
`O
rust: types: Make Opaque::get const
To support a potential usage:
static foo: Opaque<Foo> = ..; // Or defined in an extern block.
...
fn bar() { let ptr = foo.get(); }
`Opaque::get` need to be `const`, otherwise compiler will complain because calls on statics are limited to const functions.
Also `Opaque::get` should be naturally `const` since it's a composition of two `const` functions: `UnsafeCell::get` and `ptr::cast`.
Signed-off-by: Boqun Feng <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Wedson Almeida Filho <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|