e8fa0481 | 13-Jul-2025 |
Miguel Ojeda <ojeda@kernel.org> |
Merge tag 'pin-init-v6.17' of https://github.com/Rust-for-Linux/linux into rust-next
Pull pin-init updates from Benno Lossin: "Added:
- 'impl<T, E> [Pin]Init<T, E> for Result<T, E>', so results
Merge tag 'pin-init-v6.17' of https://github.com/Rust-for-Linux/linux into rust-next
Pull pin-init updates from Benno Lossin: "Added:
- 'impl<T, E> [Pin]Init<T, E> for Result<T, E>', so results are now (pin-)initializers.
- 'Zeroable::init_zeroed()' delegating to 'init_zeroed()'.
- New 'zeroed()', a safe version of 'mem::zeroed()' and also provide it via 'Zeroable::zeroed()'.
- Implement 'Zeroable' for 'Option<&T>' and 'Option<&mut T>'.
- Implement 'Zeroable' for 'Option<[unsafe] [extern "abi"] fn(...args...) -> ret>' for '"Rust"' and '"C"' ABIs and up to 20 arguments.
Changed:
- Blanket impls of 'Init' and 'PinInit' from 'impl<T, E> [Pin]Init<T, E> for T' to 'impl<T> [Pin]Init<T> for T'.
- Renamed 'zeroed()' to 'init_zeroed()'.
Upstream dev news:
- More CI improvements to deny warnings, use '--all-targets'. Also check the synchronization status of the two '-next' branches in upstream and the kernel."
Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
* tag 'pin-init-v6.17' of https://github.com/Rust-for-Linux/linux: rust: pin-init: examples, tests: use `ignore` instead of conditionally compiling tests rust: init: remove doctest's `Error::from_errno` workaround rust: init: re-enable doctests rust: pin-init: implement `ZeroableOption` for function pointers with up to 20 arguments rust: pin-init: change `impl Zeroable for Option<NonNull<T>>` to `ZeroableOption for NonNull<T>` rust: pin-init: implement `ZeroableOption` for `&T` and `&mut T` rust: pin-init: add `zeroed()` & `Zeroable::zeroed()` functions rust: pin-init: add `Zeroable::init_zeroed` rust: pin-init: rename `zeroed` to `init_zeroed` rust: pin-init: feature-gate the `stack_init_reuse` test on the `std` feature rust: pin-init: examples: pthread_mutex: disable the main test for miri rust: pin-init: examples, tests: add conditional compilation in order to compile under any feature combination rust: pin-init: change blanket impls for `[Pin]Init` and add one for `Result<T, E>` rust: pin-init: improve safety documentation for `impl<T> [Pin]Init<T> for T`
show more ...
|
fc3870dc | 05-Jun-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: examples, tests: use `ignore` instead of conditionally compiling tests
Change `#[cfg(cond)]` to `#[cfg_attr(not(cond), ignore)]` on tests.
Ignoring tests instead of disabling them s
rust: pin-init: examples, tests: use `ignore` instead of conditionally compiling tests
Change `#[cfg(cond)]` to `#[cfg_attr(not(cond), ignore)]` on tests.
Ignoring tests instead of disabling them still makes them appear in the test list, but with `ignored`. It also still compiles the code in those cases.
Some tests still need to be ignore, because they use types that are not present when the condition is false. For example the condition is `feature = std` and then it uses `std::thread::Thread`.
Suggested-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/all/aDC9y829vZZBzZ2p@google.com Link: https://github.com/Rust-for-Linux/pin-init/pull/58/commits/b004dd8e64d4cbe219a4eff0d25f0a5f5bc750ca Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com> Link: https://lore.kernel.org/all/20250605155258.573391-1-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
ec87ec35 | 23-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: implement `ZeroableOption` for function pointers with up to 20 arguments
`Option<[unsafe] [extern "abi"] fn(...args...) -> ret>` is documented [1] to also have the `None` variant equ
rust: pin-init: implement `ZeroableOption` for function pointers with up to 20 arguments
`Option<[unsafe] [extern "abi"] fn(...args...) -> ret>` is documented [1] to also have the `None` variant equal all zeroes.
Link: https://doc.rust-lang.org/stable/std/option/index.html#representation [1] Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/b6c1ab4fb3699765f81ae512ecac5a2f032d8d51 Link: https://lore.kernel.org/all/20250523145125.523275-7-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
9f473538 | 23-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: change `impl Zeroable for Option<NonNull<T>>` to `ZeroableOption for NonNull<T>`
This brings it in line with references. It too is listed in [1].
Link: https://doc.rust-lang.org/sta
rust: pin-init: change `impl Zeroable for Option<NonNull<T>>` to `ZeroableOption for NonNull<T>`
This brings it in line with references. It too is listed in [1].
Link: https://doc.rust-lang.org/stable/std/option/index.html#representation Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/8e52bf56ddc2190ce901d2f7c008ab8a64f653a9 Link: https://lore.kernel.org/all/20250523145125.523275-6-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
e93a2386 | 23-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: implement `ZeroableOption` for `&T` and `&mut T`
`Option<&T>` and `Option<&mut T>` are documented [1] to have the `None` variant be all zeroes.
Link: https://doc.rust-lang.org/stabl
rust: pin-init: implement `ZeroableOption` for `&T` and `&mut T`
`Option<&T>` and `Option<&mut T>` are documented [1] to have the `None` variant be all zeroes.
Link: https://doc.rust-lang.org/stable/std/option/index.html#representation [1] Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/5ef1638c79e019d3dc0c62db5905601644c2e60a Link: https://lore.kernel.org/all/20250523145125.523275-5-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
d67b3701 | 23-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: add `zeroed()` & `Zeroable::zeroed()` functions
`zeroed()` returns a zeroed out value of a sized type implementing `Zeroable`.
The function is added as a free standing function, in
rust: pin-init: add `zeroed()` & `Zeroable::zeroed()` functions
`zeroed()` returns a zeroed out value of a sized type implementing `Zeroable`.
The function is added as a free standing function, in addition to an associated function on `Zeroable`, because then it can be marked `const` (functions in traits can't be const at the moment).
Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/809e4ec160579c1601dce5d78b432a5b6c8e4e40 Link: https://lore.kernel.org/all/20250523145125.523275-4-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
c47024ba | 23-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: add `Zeroable::init_zeroed`
The trait function delegates to the already existing `init_zeroed` function that returns a zeroing initializer for `Self`.
The syntax `..Zeroable::init_z
rust: pin-init: add `Zeroable::init_zeroed`
The trait function delegates to the already existing `init_zeroed` function that returns a zeroing initializer for `Self`.
The syntax `..Zeroable::init_zeroed()` is already used by the initialization macros to initialize all fields that are not mentioned in the initializer with zero. Therefore it is expected that the function also exists on the trait.
Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/a424a6c9af5a4418a8e5e986a3db26a4432e2f1a Link: https://lore.kernel.org/all/20250523145125.523275-3-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
101b7cf0 | 23-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: rename `zeroed` to `init_zeroed`
The name `zeroed` is a much better fit for a function that returns the type by-value.
Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commi
rust: pin-init: rename `zeroed` to `init_zeroed`
The name `zeroed` is a much better fit for a function that returns the type by-value.
Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/7dbe38682c9725405bab91dcabe9c4d8893d2f5e [ also rename uses in `rust/kernel/init.rs` - Benno] Link: https://lore.kernel.org/all/20250523145125.523275-2-lossin@kernel.org [ Fix wrong replacement of `mem::zeroed` in the definition of `trait Zeroable`. - Benno ] [ Also change occurrences of `zeroed` in `configfs.rs` - Benno ] Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
b3b4f760 | 09-Jun-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: feature-gate the `stack_init_reuse` test on the `std` feature
When trying to run `cargo check --all-targets --no-default-features`, an error is reported by the test, as it cannot fin
rust: pin-init: feature-gate the `stack_init_reuse` test on the `std` feature
When trying to run `cargo check --all-targets --no-default-features`, an error is reported by the test, as it cannot find the `std` crate. This is to be expected, since the `--no-default-features` flag enables the `no-std` behavior of the crate. Thus exclude the test in that scenario.
Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits/2813729ccacdedee9dbfcab1ed285b8721a0391b Link: https://lore.kernel.org/all/20250523125424.192843-4-lossin@kernel.org [ Changed my author email address to @kernel.org. - Benno ] Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
2408678d | 23-May-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: examples: pthread_mutex: disable the main test for miri
`miri` takes a long time to execute the test, so disable it.
Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits
rust: pin-init: examples: pthread_mutex: disable the main test for miri
`miri` takes a long time to execute the test, so disable it.
Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits/e717a9eec85024c11e79e8bd9dcb664ad0de8f94 Link: https://lore.kernel.org/all/20250523125424.192843-3-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
58cebd68 | 23-May-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: examples, tests: add conditional compilation in order to compile under any feature combination
In the CI, all examples & tests should be run under all feature combinations. Currently
rust: pin-init: examples, tests: add conditional compilation in order to compile under any feature combination
In the CI, all examples & tests should be run under all feature combinations. Currently several examples & tests use `std` without conditionally enabling it. Thus make them all compile under any feature combination by conditionally disabling the code that uses e.g. `std`.
Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits/fdfb70efddbc711b4543c850ee38a2f5a8d17cb6 Link: https://lore.kernel.org/all/20250523125424.192843-2-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
e832374c | 29-May-2025 |
Benno Lossin <lossin@kernel.org> |
rust: pin-init: change blanket impls for `[Pin]Init` and add one for `Result<T, E>`
Remove the error from the blanket implementations `impl<T, E> Init<T, E> for T` (and also for `PinInit`). Add impl
rust: pin-init: change blanket impls for `[Pin]Init` and add one for `Result<T, E>`
Remove the error from the blanket implementations `impl<T, E> Init<T, E> for T` (and also for `PinInit`). Add implementations for `Result<T, E>`.
This allows one to easily construct (un)conditional failing initializers. It also improves the compatibility with APIs that do not use pin-init, because users can supply a `Result<T, E>` to a function taking an `impl PinInit<T, E>`.
Suggested-by: Alice Ryhl <aliceryhl@google.com> Link: https://github.com/Rust-for-Linux/pin-init/pull/62/commits/58612514b256c6f4a4a0718be25298410e67387a [ Also fix a compile error in block. - Benno ] Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Link: https://lore.kernel.org/all/20250529081027.297648-2-lossin@kernel.org [ Add title prefix `rust: pin-init`. - Benno ] Signed-off-by: Benno Lossin <lossin@kernel.org>
show more ...
|
9de1a293 | 26-Apr-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: improve documentation for `Zeroable` derive macros
Specify that both `MaybeZeroable` and `Zeroable` work on `union`s. Add a doc example for a union. Also include an example with visi
rust: pin-init: improve documentation for `Zeroable` derive macros
Specify that both `MaybeZeroable` and `Zeroable` work on `union`s. Add a doc example for a union. Also include an example with visibility on the field.
Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/ab0985a0e08df06c60a32ca5888f74adcc2c1cf3 Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
a919ba21 | 26-Apr-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: fix typos
Correct two typos in the `Wrapper::pin_init` documentation.
Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/fd0bf5e244b685188dc642fc4a0bd3f042468fdb Revie
rust: pin-init: fix typos
Correct two typos in the `Wrapper::pin_init` documentation.
Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/fd0bf5e244b685188dc642fc4a0bd3f042468fdb Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
00fccd3e | 22-Apr-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: add `MaybeZeroable` derive macro
This derive macro implements `Zeroable` for structs & unions precisely if all fields also implement `Zeroable` and does nothing otherwise. The plain
rust: pin-init: add `MaybeZeroable` derive macro
This derive macro implements `Zeroable` for structs & unions precisely if all fields also implement `Zeroable` and does nothing otherwise. The plain `Zeroable` derive macro instead errors when it cannot derive `Zeroable` safely. The `MaybeZeroable` derive macro is useful in cases where manual checking is infeasible such as with the bindings crate.
Move the zeroable generics parsing into a standalone function in order to avoid code duplication between the two derive macros.
Link: https://github.com/Rust-for-Linux/pin-init/pull/42/commits/1165cdad1a391b923efaf30cf76bc61e38da022e Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
a313d41a | 22-Apr-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: allow `Zeroable` derive macro to also be applied to unions
Enabling the same behavior for unions as for structs is correct, but could be relaxed: the valid bit patterns for unions ar
rust: pin-init: allow `Zeroable` derive macro to also be applied to unions
Enabling the same behavior for unions as for structs is correct, but could be relaxed: the valid bit patterns for unions are the union of all valid bit patterns of their fields. So for a union to implement `Zeroable`, only a single field needs to implement `Zeroable`. This can be a future improvement, as it is currently only needed for unions where all fields implement `Zeroable`.
There is no danger for mis-parsing with the two optional tokens (ie neither one or both tokens are parsed), as the compiler will already have rejected that before giving it as the input to the derive macro.
Link: https://github.com/Rust-for-Linux/pin-init/pull/42/commits/5927b497ce522d82f6c082d5ba9235df57bfdb32 Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
983d13fc | 22-Apr-2025 |
Benno Lossin <benno.lossin@proton.me> |
rust: pin-init: allow `pub` fields in `derive(Zeroable)`
Add support for parsing `pub`, `pub(crate)` and `pub(super)` to the derive macro `Zeroable`.
Link: https://github.com/Rust-for-Linux/pin-ini
rust: pin-init: allow `pub` fields in `derive(Zeroable)`
Add support for parsing `pub`, `pub(crate)` and `pub(super)` to the derive macro `Zeroable`.
Link: https://github.com/Rust-for-Linux/pin-init/pull/42/commits/e8311e52ca57273e7ed6d099144384971677a0ba Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
c3815aa4 | 22-Apr-2025 |
Christian Schrefl <chrisi.schrefl@gmail.com> |
rust: pin-init: Update the structural pinning link in readme.
The previous link anchor was broken in rust 1.77, because the documentation was refactored in upstream rust. Change the link to refer to
rust: pin-init: Update the structural pinning link in readme.
The previous link anchor was broken in rust 1.77, because the documentation was refactored in upstream rust. Change the link to refer to the new section in the rust documentation.
Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com> Link: https://github.com/Rust-for-Linux/pin-init/pull/37/commits/a146142fe18cafa52f8c6da306ca2729d789cfbf [ Fixed commit authorship. - Benno ] Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
bc5f3e0e | 22-Apr-2025 |
Christian Schrefl <chrisi.schrefl@gmail.com> |
rust: pin-init: Update Changelog and Readme
Add Changelog entry for the `Wrapper` trait and document the `unsafe-pinned` feature in the Readme.
Signed-off-by: Christian Schrefl <chrisi.schrefl@gmai
rust: pin-init: Update Changelog and Readme
Add Changelog entry for the `Wrapper` trait and document the `unsafe-pinned` feature in the Readme.
Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com> Link: https://github.com/Rust-for-Linux/pin-init/pull/37/commits/986555f564645efb238e8092c6314388c859efe5 [ Fixed commit authorship. - Benno ] Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
b862aac8 | 22-Apr-2025 |
Christian Schrefl <chrisi.schrefl@gmail.com> |
rust: pin-init: Implement `Wrapper` for `UnsafePinned` behind feature flag.
Add the `unsafe-pinned` feature which gates the `Wrapper` implementation of the `core::pin::UnsafePinned` struct.
For now
rust: pin-init: Implement `Wrapper` for `UnsafePinned` behind feature flag.
Add the `unsafe-pinned` feature which gates the `Wrapper` implementation of the `core::pin::UnsafePinned` struct.
For now this is just a cargo feature, but once `core::pin::UnsafePinned` is stable a config flag can be added to allow the usage of this implementation in the linux kernel.
Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com> Link: https://github.com/Rust-for-Linux/pin-init/pull/37/commits/99cb1934425357e780ea5b0628f66633123847b8 [ Fixed commit authorship. - Benno ] Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|
2f7c7382 | 22-Apr-2025 |
Christian Schrefl <chrisi.schrefl@gmail.com> |
rust: pin-init: Add the `Wrapper` trait.
This trait allows creating `PinInitializers` for wrapper or new-type structs with the inner value structurally pinned, when given the initializer for the inn
rust: pin-init: Add the `Wrapper` trait.
This trait allows creating `PinInitializers` for wrapper or new-type structs with the inner value structurally pinned, when given the initializer for the inner value.
Implement this trait for `UnsafeCell` and `MaybeUninit`.
Signed-off-by: Christian Schrefl <chrisi.schrefl@gmail.com> Link: https://github.com/Rust-for-Linux/pin-init/pull/37/commits/3ab4db083bd7b41a1bc23d937224f975d7400e50 [ Reworded commit message into imperative mode, fixed typo and fixed commit authorship. - Benno ] Signed-off-by: Benno Lossin <benno.lossin@proton.me>
show more ...
|