0c7ae432 | 30-Jan-2023 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: implement `ForeignOwnable` for `Arc<T>`
This allows us to hand ownership of Rust ref-counted objects to the C side of the kernel.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.co
rust: types: implement `ForeignOwnable` for `Arc<T>`
This allows us to hand ownership of Rust ref-counted objects to the C side of the kernel.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Reviewed-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
71185944 | 30-Jan-2023 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: implement `ForeignOwnable` for the unit type
This allows us to use the unit type `()` when we have no object whose ownership must be managed but one implementing the `ForeignOwnable` tr
rust: types: implement `ForeignOwnable` for the unit type
This allows us to use the unit type `()` when we have no object whose ownership must be managed but one implementing the `ForeignOwnable` trait is needed.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
26949bac | 30-Jan-2023 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: implement `ForeignOwnable` for `Box<T>`
This allows us to hand ownership of Rust dynamically allocated objects to the C side of the kernel.
Signed-off-by: Wedson Almeida Filho <wedsona
rust: types: implement `ForeignOwnable` for `Box<T>`
This allows us to hand ownership of Rust dynamically allocated objects to the C side of the kernel.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Reviewed-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
0fc4424d | 30-Jan-2023 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: introduce `ForeignOwnable`
It was originally called `PointerWrapper`. It is used to convert a Rust object to a pointer representation (void *) that can be stored on the C side, used, an
rust: types: introduce `ForeignOwnable`
It was originally called `PointerWrapper`. It is used to convert a Rust object to a pointer representation (void *) that can be stored on the C side, used, and eventually returned to Rust.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
4d4692a2 | 30-Jan-2023 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: introduce `ScopeGuard`
This allows us to run some code when the guard is dropped (e.g., implicitly when it goes out of scope). We can also prevent the guard from running by calling its
rust: types: introduce `ScopeGuard`
This allows us to run some code when the guard is dropped (e.g., implicitly when it goes out of scope). We can also prevent the guard from running by calling its `dismiss()` method.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
c83b16ce | 07-Jan-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
kbuild: rust: move rust/target.json to scripts/
scripts/ is a better place to generate files used treewide.
With target.json moved to scripts/, you do not need to add target.json to no-clean-files
kbuild: rust: move rust/target.json to scripts/
scripts/ is a better place to generate files used treewide.
With target.json moved to scripts/, you do not need to add target.json to no-clean-files or MRPROPER_FILES.
'make clean' does not visit scripts/, but 'make mrproper' does.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
2185242f | 07-Jan-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
kbuild: remove sed commands after rustc rules
rustc may put comments in dep-info, so sed is used to drop them before passing it to fixdep.
Now that fixdep can remove comments, Makefiles do not need
kbuild: remove sed commands after rustc rules
rustc may put comments in dep-info, so sed is used to drop them before passing it to fixdep.
Now that fixdep can remove comments, Makefiles do not need to run sed.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
show more ...
|
dec1df54 | 14-Dec-2022 |
Finn Behrens <fin@nyantec.com> |
rust: prelude: prevent doc inline of external imports
This shows exactly where the items are from, previously the items from macros, alloc and core were shown as a declaration from the kernel crate,
rust: prelude: prevent doc inline of external imports
This shows exactly where the items are from, previously the items from macros, alloc and core were shown as a declaration from the kernel crate, this shows the correct path.
Link: https://github.com/rust-lang/rust/issues/106713 Signed-off-by: Finn Behrens <fin@nyantec.com> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> [Reworded to add Link, fixed two typos and comment style] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
0748424a | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: add support for dispatching on Arc and ArcBorrow.
Trait objects (`dyn T`) require trait `T` to be "object safe". One of the requirements for "object safety" is that the receiver have one
rust: sync: add support for dispatching on Arc and ArcBorrow.
Trait objects (`dyn T`) require trait `T` to be "object safe". One of the requirements for "object safety" is that the receiver have one of the allowed types. This commit adds `Arc<T>` and `ArcBorrow<'_, T>` to the list of allowed types.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
70e42ebb | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: introduce `UniqueArc`
Since `Arc<T>` does not allow mutating `T` directly (i.e., without inner mutability), it is currently not possible to do some initialisation of `T` post constructio
rust: sync: introduce `UniqueArc`
Since `Arc<T>` does not allow mutating `T` directly (i.e., without inner mutability), it is currently not possible to do some initialisation of `T` post construction but before being shared.
`UniqueArc<T>` addresses this problem essentially being an `Arc<T>` that has a refcount of 1 and is therefore writable. Once initialisation is completed, it can be transitioned (without failure paths) into an `Arc<T>`.
Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
92a655ae | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: allow type of `self` to be `ArcBorrow<T>`
This allows associated functions whose `self` argument has `ArcBorrow<T>` as their type. This, in turn, allows callers to use the dot syntax to
rust: sync: allow type of `self` to be `ArcBorrow<T>`
This allows associated functions whose `self` argument has `ArcBorrow<T>` as their type. This, in turn, allows callers to use the dot syntax to make calls.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
17f67160 | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: introduce `ArcBorrow`
This allows us to create references to a ref-counted allocation without double-indirection and that still allow us to increment the refcount to a new `Arc<T>`.
Sig
rust: sync: introduce `ArcBorrow`
This allows us to create references to a ref-counted allocation without double-indirection and that still allow us to increment the refcount to a new `Arc<T>`.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
f75cb6fc | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: allow coercion from `Arc<T>` to `Arc<U>`
The coercion is only allowed if `U` is a compatible dynamically-sized type (DST). For example, if we have some type `X` that implements trait `Y`
rust: sync: allow coercion from `Arc<T>` to `Arc<U>`
The coercion is only allowed if `U` is a compatible dynamically-sized type (DST). For example, if we have some type `X` that implements trait `Y`, then this allows `Arc<X>` to be coerced into `Arc<dyn Y>`.
Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
53528772 | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: allow type of `self` to be `Arc<T>` or variants
This allows associated functions whose `self` argument has `Arc<T>` or variants as their type. This, in turn, allows callers to use the do
rust: sync: allow type of `self` to be `Arc<T>` or variants
This allows associated functions whose `self` argument has `Arc<T>` or variants as their type. This, in turn, allows callers to use the dot syntax to make calls.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
9dc04365 | 28-Dec-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: sync: add `Arc` for ref-counted allocations
This is a basic implementation of `Arc` backed by C's `refcount_t`. It allows Rust code to idiomatically allocate memory that is ref-counted.
Cc: W
rust: sync: add `Arc` for ref-counted allocations
This is a basic implementation of `Arc` backed by C's `refcount_t`. It allows Rust code to idiomatically allocate memory that is ref-counted.
Cc: Will Deacon <will@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
cb7d9def | 05-Dec-2022 |
Gary Guo <gary@garyguo.net> |
rust: compiler_builtins: make stubs non-global
Currently we define a number of stubs for compiler-builtin intrinsics that compiled libcore generates. The defined stubs are weak so they will not conf
rust: compiler_builtins: make stubs non-global
Currently we define a number of stubs for compiler-builtin intrinsics that compiled libcore generates. The defined stubs are weak so they will not conflict with genuine implementation of these intrinsics, but their effect is global and will cause non-libcore code that accidently generate these intrinsics calls compile and bug on runtime.
Instead of defining a stub that can affect all code, this patch uses objcopy's `--redefine-sym` flag to redirect these calls (from libcore only) to a prefixed version (e.g. redirect `__multi3` to `__rust_multi3`), so we can define panciking stubs that are only visible to libcore.
This patch was previously discussed on GitHub [1]. This approach was also independently proposed by Nick Desaulniers in [2].
Link: https://github.com/Rust-for-Linux/linux/pull/779 [1] Link: https://lore.kernel.org/lkml/CAKwvOdkc0Qhwu=gfe1+H23TnAa6jnO6A3ZCO687dH6mSrATmDA@mail.gmail.com/ Suggested-by: Nick Desaulniers <ndesaulniers@google.com> Acked-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
b9ecf9b9 | 10-Nov-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: add `Opaque` type
Add the `Opaque` type, which is meant to be used with FFI objects that are never interpreted by Rust code, e.g.:
struct Waiter { completion: Opaque<bindin
rust: types: add `Opaque` type
Add the `Opaque` type, which is meant to be used with FFI objects that are never interpreted by Rust code, e.g.:
struct Waiter { completion: Opaque<bindings::completion>, next: *mut Waiter, }
It has the advantage that the objects don't have to be zero-initialised before calling their init functions, making the code performance closer to C.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> [Reworded, adapted for upstream and applied latest changes] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
ba20915b | 10-Nov-2022 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: types: add `Either` type
Introduce the new `types` module of the `kernel` crate with `Either` as its first type.
`Either<L, R>` is a sum type that always holds either a value of type `L` (`Le
rust: types: add `Either` type
Introduce the new `types` module of the `kernel` crate with `Either` as its first type.
`Either<L, R>` is a sum type that always holds either a value of type `L` (`Left` variant) or `R` (`Right` variant).
For instance:
struct Executor { queue: Either<BoxedQueue, &'static Queue>, }
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Reviewed-by: Wei Liu <wei.liu@kernel.org> [Reworded, adapted for upstream and applied latest changes] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|