summaryrefslogtreecommitdiff
path: root/rust
AgeCommit message (Collapse)Author
2026-09-29rust: block: fix `Send` bound for `GenDisk`Andreas Hindborg
The `Send` implementation for `GenDisk<T>` was conditioned on `T: Send`. This constrains the wrong type. `T` is the `Operations` implementation, which is typically a zero-sized marker type that carries no data, so `T: Send` says nothing about whether the data a `GenDisk` actually owns can be moved to another thread. A `GenDisk<T>` owns the queue data `T::QueueData` (stored as the `gendisk`'s `queuedata` and dropped when the `GenDisk` is dropped) and an `Arc<TagSet<T>>`. These are the values transferred when a `GenDisk` is sent across a thread boundary, so the `Send` bound must constrain exactly them. Bound `T::QueueData: Send` and `Arc<TagSet<T>>: Send` instead. Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module") Cc: stable@vger.kernel.org Reported-by: Priya Bala Govindasamy <pgovind2@uci.edu>, Dylan Zueck <dzueck@uci.edu>, Yuan Tan <ytan089@ucr.edu> Closes: https://lore.kernel.org/all/cover.1780633578.git.ytan089@ucr.edu Signed-off-by: Yuan Tan <ytan089@ucr.edu> Link: https://msgid.link/20260709100100.604252-1-yuantan098@gmail.com [ Andreas: Fix tags to make checkpatch happy. Change summary line. ] Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260929-rust-block-for-v7-4-rc1-b4-v1-4-642a4c1aebd7@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-09-29rust: block: mq: remove redundant imports and formatAlvin Sun
Drop `Result`, `Pin`, `pin_data`, `pinned_drop`, `PinInit`, and `try_pin_init` imports already provided by `kernel::prelude`. Simplify `error` imports and flatten parameters formatting. Reviewed-by: Onur Özkan <work@onurozkan.dev> Signed-off-by: Alvin Sun <alvin.sun@linux.dev> Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://msgid.link/20260521-miscdev-use-format-v3-5-56240ca70d0c@linux.dev Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260929-rust-block-for-v7-4-rc1-b4-v1-2-642a4c1aebd7@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-09-29rust: block: mq: use vertical import styleAlvin Sun
Convert `use` imports to vertical layout for better readability and maintainability. Reviewed-by: Onur Özkan <work@onurozkan.dev> Signed-off-by: Alvin Sun <alvin.sun@linux.dev> Link: https://msgid.link/20260521-miscdev-use-format-v3-4-56240ca70d0c@linux.dev Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260929-rust-block-for-v7-4-rc1-b4-v1-1-642a4c1aebd7@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-09-29rust: net: netlink: validate attribute length before casting to `c_int`Sagar Taunk
`put()` trusted an unchecked `as` cast from `usize` to `c_int`. When the length exceeds `i32::MAX` that cast wraps around to a negative value. This ultimately resulted in a kernel panic when the reinterpreted value via `__nla_reserve()` and `skb_put()` became enormous. Validate payload and header both fit together in a `u16`, rejecting any payload that wouldn't leave room for `NLA_HDRLEN`. Fixes: 5eaa5fbb6e6c ("rust: netlink: add raw netlink abstraction") Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Sagar Taunk <sagartaunk@proton.me> Link: https://patch.msgid.link/20260925085449.22553-1-sagartaunk@proton.me Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29rust: configfs: fix data offset calculation for subsystem callbacksAndreas Hindborg
`get_group_data()` chooses between `Group::<Parent>::container_of()` and `Subsystem::<Parent>::container_of()` based on whether `this` represents the root group of a configfs subsystem. It detects this by checking `(*this).cg_subsys.is_null()`, but `link_group()` in `fs/configfs/dir.c` unconditionally sets `cg_subsys` for every `config_group` attached anywhere in a registered subsystem, including the subsystem's own `su_group`. The only `config_group` with a NULL `cg_subsys` is the configfs root, on which userspace cannot trigger callbacks. The check is therefore always false at runtime, and the `Subsystem` branch is dead. Subsystem-level callbacks reach the `Group` branch and may read `data` at the wrong offset. Thus change the `is_root` check to correctly identify whether a group is a root group by comparing `this` to `subsys.su_group`. Cc: stable@vger.kernel.org Fixes: 446cafc295bf ("rust: configfs: introduce rust support for configfs") Link: https://msgid.link/20260608-configfs-fix-offset-v1-1-7f01b8fb9e5f@kernel.org [ Andreas: Fix clippy warning on 1.85.0 by moving safety comment. ] Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-29rust: hrtimer: document handle based design rationaleAndreas Hindborg
Add implementation notes explaining why the hrtimer abstraction uses a handle based approach. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Boqun Feng <boqun@kernel.org> Reviewed-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://msgid.link/20260215-hrtimer-docs-v1-1-bff6a6c0d923@kernel.org Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-28rust: time: add Delta::to_jiffies_timeout() for timeout conversionFUJITA Tomonori
The boundaries of __msecs_to_jiffies() and nsecs_to_jiffies64() depend on which HZ branch is compiled. With CONFIG_HZ_300 nsecs_to_jiffies64() overflows after 64.99 years, which is less than the 292 years a Delta can hold. With HZ=1000 a jiffy is a millisecond, so __msecs_to_jiffies() returns its argument unchanged and never caps it at MAX_JIFFY_OFFSET. Compute the conversion in Rust with mul_u64_add_u64_div_u64() instead. It returns (a * b + c) / d, computing a * b internally in 128 bits, so ceil(nanos * HZ / NSEC_PER_SEC) needs no input clamp and rounds once. The bound then follows from the arithmetic: with HZ <= NSEC_PER_SEC, which a static_assert() checks, the result is at most the nanosecond count. Unless the result saturates, the value is rounded up, so the timeout is never shorter than the requested span. It saturates at zero jiffies for a negative span, i.e. an immediate timeout, and at MAX_JIFFY_OFFSET, the upper bound the kernel uses for a jiffies span. Since MAX_JIFFY_OFFSET is derived from long, only 32 bit can reach it, and a saturated timeout there is finite, so it can be shorter than the requested span. Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://msgid.link/20260924232530.446588-3-tomo@flapping.org Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-28rust: bindings: set HZ to CONFIG_HZFUJITA Tomonori
include/uapi/asm-generic/param.h defines HZ as __USER_HZ and include/asm-generic/param.h then sets it to CONFIG_HZ. bindgen keeps the first definition of a macro and ignores a later #undef, so the generated binding is __USER_HZ. Redefine HZ in rust/bindings/lib.rs, the same way compat_ptr_ioctl is redefined there. Nothing in the tree reads bindings::HZ today, so this prevents accidental misuse rather than fixing a bug. Suggested-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://msgid.link/20260924232530.446588-2-tomo@flapping.org Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-28rust: configfs: require thread-safe callback dataYilin Chen
The Rust configfs abstractions do not fully constrain callback data for cross-thread use. Add the missing `Send` and `Sync` requirements. Specifically, make the following changes: 1. Require `Data: Send` when implementing `Send` for `Subsystem<Data>`, since the subsystem stores its data by value. 2. Make `GroupOperations` a `Sync` supertrait because `make_group` and `drop_item` receive `&self` from foreign threads. Require `Child: Send` because configfs may release child groups on an arbitrary thread. 3. Require `AttributeOperations::Data: Sync` because its callbacks receive `&Data` from foreign threads. 4. Update the safety comments in FFI callbacks that call `get_group_data` to cite these bounds as justification for sharing the returned references with the callback thread. 5. Remove redundant `Child: 'static` bounds from `GroupOperationsVTable` and `new_with_child_ctor`. Fixes: 446cafc295bf ("rust: configfs: introduce rust support for configfs") Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Should.20add.20Data.3A.20Send.2FSync.20bounds.20in.20configfs.3A.3ASubsystem.3F/with/623719979 Assisted-by: Gpt-5.6 Sol Signed-off-by: Yilin Chen <1479826151@qq.com> Link: https://msgid.link/tencent_5449081195EDDF5726C709CF648DD4044A08@qq.com [ Andreas: Add Send/Sync bounds for `Group<Data>`, add `Send` bounds to `GroupOperationsVTable`, `ItemOperationsVTable` and `ItemType` macro implementation. ] Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-28rust: pin-init: internal: improve diagnostics robustness against panickingGary Guo
Currently, if proc macro panicked, the diagnostics clean up is not executed, and further invocation will cause the "DiagCtxt cannot be nested" error. While we should aim to have no panics inside proc macros, producing a sensible diagnostics message even when macro panicked is very useful for developing. Thus, catch proc macro panics and convert them to errors, and emit them together with all diagnostics accumulated so far. Ideally we would like panic location w/ line numbers being available as well; however this is not currently implementable without overriding the global panic hook. Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20260923140618.1978181-3-gary@kernel.org Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-28rust: pin-init: internal: make `DiagCtxt` available inside parserGary Guo
Currently, there is a split between `syn::Error` and pin-init's custom `DiagCtxt`. Parsing has no access to `DiagCtxt` and therefore cannot report diagnostics without failing the parse. Bridge the gap by making the `DiagCtxt` available inside parsers using `thread_local!`. `parse_macro_input!` returns error as token stream directly, so it is no longer suitable when the parsing is moved inside `DiagCtxt` closure. Add a `From<syn::Error> for ErrorGuaranteed` implementation so `?` can be used to add a `syn::Error` into the current diagnostic context and obtain a `ErrorGuaranteed`. Clean up the handler of using `<-` inside tuple expression as a demonstration of the usefulness of having `DiagCtxt` access inside `Parse`. Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20260923140618.1978181-2-gary@kernel.org Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-28rust: pin-init: internal: handle item and expr diagnostics differentlyGary Guo
Currently `DiagCtxt` is used to allow error recovery in the pin-init macros, by generating both a `compile_error!()` macro item and continue expansion, and then merge token streams together. This works very well for items, however for expressions, this will produce invalid expression and result in a confusing error message. error: macro expansion ignores `::` and any tokens following --> tests/ui/compile-fail/zeroable/invalid_spread.rs:15:9 | 13 | let _ = init!(Foo { | _____________- 14 | | a: 0, 15 | | ..MyZeroable::init_zeroed() | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | | }); | |______- caused by the macro expansion here | = note: the usage of `init!` is likely invalid in expression context Fix this by wrap the concatenated diagnostics in a block, with the generated expression in its tail position. This results in the desired error message. error: expected nothing or `..Zeroable::init_zeroed()`. --> tests/ui/compile-fail/zeroable/invalid_spread.rs:15:9 | 15 | ..MyZeroable::init_zeroed() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20260923140618.1978181-1-gary@kernel.org Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-28Merge tag 'v7.3-rc5' into driver-core-nextDanilo Krummrich
We need the driver-core fixes in here as well to build on top of. Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-27rust: uaccess: add UserSliceWriter::write_truncated()Alistair Popple
Add a helper that writes as much of an AsBytes value as fits in the remaining userspace buffer and returns the number of bytes copied. This avoids requiring callers of versioned UAPIs to convert values to byte slices and truncate them manually. Suggested-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/nova-gpu/DKC6T1DQX2L3.HTHPB2L167TC@kernel.org/ Signed-off-by: Alistair Popple <apopple@nvidia.com> Acked-by: Miguel Ojeda <ojeda@kernel.org> Link: https://patch.msgid.link/20260909064506.910162-7-apopple@nvidia.com [ Inline write_slice_partial() and use it to simplify write_truncated(). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-27rust: auxiliary: let registration_data_with() closures return covariant ↵Alistair Popple
sub-fields The closure passed to registration_data_with() currently receives `Pin<&'a F::Of<'a>>` with `'a` universally quantified. This prevents the closure from returning references derived from the registration data, even for sub-fields that are covariant in their lifetime, because the compiler cannot relate `'a` to any lifetime the caller knows about. Tie the outer reference to the `&self` lifetime instead, i.e. pass `Pin<&'this F::Of<'a>>`. This gives the closure the implied bound `'a: 'this`, so covariant sub-fields such as `&'a T` can be coerced to `'this` and returned directly, while invariant fields still cannot be coerced and therefore cannot escape with an incorrect lifetime. This allows auxiliary child drivers to project covariant data out of invariant registration data without having to wrap every use in a closure. Link: https://lore.kernel.org/nova-gpu/DL3WPTVM033J.33RWYCZOC67Z1@kernel.org/ Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alistair Popple <apopple@nvidia.com> Link: https://patch.msgid.link/20260909064506.910162-2-apopple@nvidia.com Co-developed-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-25rust: pin-init: add diagnostic attribute for `PinInit` and `Init`Gary Guo
Give a slightly more useful error message when these traits are not implemented. Before this change: error[E0277]: the trait bound `impl pin_init::PinInit<Bar>: Init<Bar, _>` is not satisfied --> tests/ui/compile-fail/init/invalid_init.rs:19:16 | 19 | bar <- Bar::new(), | -------^^^^^^^^^^ | | | | | the trait `Init<Bar, _>` is not implemented for `impl pin_init::PinInit<Bar>` | required by a bound introduced by this call After this change: error[E0277]: `impl pin_init::PinInit<Bar>` cannot be used to movably initialize `Bar` with error `_` --> tests/ui/compile-fail/init/invalid_init.rs:19:16 | 19 | bar <- Bar::new(), | -------^^^^^^^^^^ | | | | | the trait `Init<Bar, _>` is not implemented for `impl pin_init::PinInit<Bar>` | required by a bound introduced by this call | = note: if your type implements `PinInit` but not `Init`, you might be forgetting a `#[pin]` annotation on fields Ideally, we would generate differnet message when `PinInit` is implemented but not `Init`; that is not feasible with today's `diagnostics::on_unimplemented` attribute. However, the added note is worth it because in `init!()` is more rarely used compared to `pin_init!()`; in most cases `Init` being unimplemented is the result of missing `#[pin]`. Link: https://patch.msgid.link/20260923-dev-pin-data-diag-v1-5-e4d7193569e5@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-25rust: pin-init: internal: add custom diagnostic when `#[pin_data]` is not ↵Gary Guo
implemented Produce a more helpful error message when `#[pin_data]` is omitted. The error message changes from error[E0277]: the trait bound `Foo: pin_init::__internal::HasPinData` is not satisfied --> tests/ui/compile-fail/init/missing_pin_data.rs:9:19 | 9 | pin_init!(Self { a: 42 }) | ^^^^ unsatisfied trait bound | help: the trait `pin_init::__internal::HasPinData` is not implemented for `Foo` --> tests/ui/compile-fail/init/missing_pin_data.rs:3:1 | 3 | struct Foo { | ^^^^^^^^^^ to error[E0277]: `Foo` cannot be used with `pin_init!` macro --> tests/ui/compile-fail/init/missing_pin_data.rs:9:19 | 9 | pin_init!(Self { a: 42 }) | ^^^^ unsatisfied trait bound | help: the trait `pin_init::__internal::HasPinData` is not implemented for `Foo` --> tests/ui/compile-fail/init/missing_pin_data.rs:3:1 | 3 | struct Foo { | ^^^^^^^^^^ = note: did you forget to add `#[pin_data]` attribute to the struct? Link: https://patch.msgid.link/20260923-dev-pin-data-diag-v1-4-e4d7193569e5@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-25rust: pin-init: internal: use `HasInitData` to provide inference help onlyGary Guo
Currently, type inference of the initialized type is done by use the function calling syntax `PATH::__pin_data` or `PATH::__init_data` to obtain the required init data type, without needing the user to explicitly mention all generics. Switch to always use `HasInitData::__init_data` to provide that inference, which will not produce method-not-found errors as it is always available. Change `__pin_data` to take `InitData<Self>` as the receiver, so for types that require `HasPinData`, `HasPinData::__pin_data(data)` can be used to obtain the needed type without having to mention the user-provided path again. The expanded code also uses the span of the type, so diagnostics will hint to user that the type is causing the issue. With this change, the error message when `HasPinData` is not implemented changes from error[E0599]: no associated function or constant named `__pin_data` found for struct `Foo` in the current scope --> tests/ui/compile-fail/init/missing_pin_data.rs:9:9 | 3 | struct Foo { | ---------- associated function or constant `__pin_data` not found for this struct ... 9 | pin_init!(Self { a: 42 }) | ^^^^^^^^^^^^^^^^^^^^^^^^^ associated function or constant not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `__pin_data`, perhaps you need to implement it: candidate #1: `pin_init::__internal::HasPinData` to error[E0277]: the trait bound `Foo: pin_init::__internal::HasPinData` is not satisfied --> tests/ui/compile-fail/init/missing_pin_data.rs:9:19 | 9 | pin_init!(Self { a: 42 }) | ^^^^ unsatisfied trait bound | help: the trait `pin_init::__internal::HasPinData` is not implemented for `Foo` --> tests/ui/compile-fail/init/missing_pin_data.rs:3:1 | 3 | struct Foo { | ^^^^^^^^^^ Link: https://patch.msgid.link/20260923-dev-pin-data-diag-v1-3-e4d7193569e5@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-25rust: pin-init: internal: remove associated type of `HasInitData`Gary Guo
There is only a single implementation, the associated type is not necessary. Remove it, and rename `AllData` to `InitData` to be a more meaningful name. The single implementation also means that "unsafe" is redundant, so remove it as well. Link: https://patch.msgid.link/20260923-dev-pin-data-diag-v1-2-e4d7193569e5@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-25rust: pin-init: internal: make `__init_data` and `__pin_data` safeGary Guo
Remove the unsafe markers of `__init_data` and `__pin_data`. These methods are for inference help and does not need to be unsafe. The `HasInitData` cannot be implemented outside pin-init, so the `unsafe trait` marker is not necessary. Link: https://patch.msgid.link/20260923-dev-pin-data-diag-v1-1-e4d7193569e5@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-25rust: pin-init: internal: pin_data: use HRTB to work around `trivial_bounds` ↵Gary Guo
for `Unpin` `#[pin_data]` generates a `Unpin` implementation for the user, which requires reasoning using field types. This is rejected by rustc as "trivial bounds", which can only be specified using the `#![feature(trivial_bounds)]`. Currently we use an extra lifetime in `__Unpin` to work around this; use HRTB to introduce a dummy lifetime can achieve the same, which the `Zeroable` implementation already uses. Unify the `Unpin` impl to also use the same HRTB trick that `Zeroable` uses. This produces slightly better error message and slightly shorter expansion. Link: https://patch.msgid.link/20260922211320.1390159-1-gary@kernel.org Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-24rust: scatterlist: honor the device's maximum segment sizeMatteo Kloiber
SGTable::new() caps segment length at dma_max_mapping_size() only, which limits the DMA mapping path (e.g. swiotlb), not the device itself. The per-device limit from dma_set_max_seg_size() is ignored, so contiguous page segments can be longer than the declared max segment size, potentially causing problems for future drivers that use this abstraction. Fixes: 05aa6fb1c21d ("rust: scatterlist: Add abstraction for sg_table") Signed-off-by: Matteo Kloiber <kernel@matt3o12.de> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260913210828.125655-3-kernel@matt3o12.de Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-23rust: clk: document overflow panics in `Hertz` constructorsGeorgios Androutsopoulos
`Hertz::from_khz()`, `from_mhz()` and `from_ghz()` multiply their argument by 1_000, 1_000_000 and 1_000_000_000 respectively without checking for overflow. When `CONFIG_RUST_OVERFLOW_CHECKS` is enabled, each panics once its argument exceeds `c_ulong::MAX` divided by that factor. None of the three documents this. The panic occurs only at runtime, when the argument is not a constant expression. Add the missing `# Panics` sections stating the bound for each unit. Fixes: d01d70205601 ("rust: clk: Add initial abstractions") Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Brian Masney <bmasney@redhat.com>
2026-09-23configfs: Allow the registration of const struct configfs_attributeThomas Weißschuh
The attribute structure defined in driver code never need to be modified. Allow them to be marked as const. As there are many drivers which use these attributes, prepare for a phased transition by using a union of const and non-const attributes. After all drivers have been migrated to the const variant, the non-const one can be replaced by the const one and the transition machinery will be removed again. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260716-configfs-const-base-v1-5-c545a4053cb5@weissschuh.net Signed-off-by: Breno Leitao <leitao@debian.org>
2026-09-23configfs: Constify configfs_bin_attributeThomas Weißschuh
The configfs_bin_attribute structures defined by driver are never modified. Make them const. As there are only two users of these attributes, adapt them in the same commit to avoid a phased transition. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260716-configfs-const-base-v1-4-c545a4053cb5@weissschuh.net Signed-off-by: Breno Leitao <leitao@debian.org>
2026-09-23rust: configfs: remove mutability from some field initializersThomas Weißschuh
These fields do not require mutable pointers. Use regular immutable ones. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260716-configfs-const-base-v1-1-c545a4053cb5@weissschuh.net Signed-off-by: Breno Leitao <leitao@debian.org>
2026-09-22rust: time: rename ClockSource trait to ClockIdFUJITA Tomonori
The `ClockSource` trait has nothing to do with the C `struct clocksource` in `include/linux/clocksource.h`, which abstracts the hardware counter used as a source of time for the majority of the clockids. The trait instead carries a `clockid_t` `ID`, i.e. one of the IDs of "the various system clocks (for POSIX.1b interval timers)" as described in include/uapi/linux/time.h (CLOCK_MONOTONIC, CLOCK_REALTIME, ...). It thus plays the role of a `clockid_t`, and the `ClockSource` name overlaps confusingly with the C `clocksource` concept when reading across C and Rust code. Rename the trait to `ClockId` to reflect that it represents a `clockid_t`. This is a pure rename; there is no functional change. Suggested-by: John Stultz <jstultz@google.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://lore.kernel.org/rust-for-linux/CANDhNCrKMdHCmL76LWCROVF2Ly-9NxmfmQ2T+P=iv34aVkO2uQ@mail.gmail.com/ Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://msgid.link/20260722001050.4115708-1-tomo@flapping.org Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-22rust: configfs: fix release safety documentationYilin Chen
ItemOperationsVTable<Group<Data>, Data>::release() receives a pointer to a config_item, not a config_group. The old Safety docs described the pointer as a config_group embedded in Group<Parent>. Update them to state that the pointer must be the cg_item field of a config_group embedded in a valid Group<Data>. Assisted-by: Codex:GPT-5 Signed-off-by: Yilin Chen <1479826151@qq.com> Link: https://msgid.link/tencent_9FAFC60382D724C608F0F6BFABFC63BB6707@qq.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-22rust: time: warn and assert out-of-range input in fsleep() and udelay()Sang-Heon Jeon
fsleep() documents out-of-range input as a bug but does not check it, unlike udelay(). Add `debug_assert!` calls to catch it in debug builds. Also add `pr_warn_once!` calls in both fsleep() and udelay() so the clamped path is observable at runtime. Reviewed-by: Onur Özkan <work@onurozkan.dev> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com> Link: https://msgid.link/20260621105909.4055210-1-ekffu200098@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
2026-09-22Backmerge tag 'v7.3-rc4' into drm-nextDave Airlie
Linux 7.3-rc4 Requested by Philipp Stanner for 2ab510e63197360945f915dd5631a77c63ac6b27 would be needed as a groundlayer for further patches that extend the locking in drm_sched Signed-off-by: Dave Airlie <airlied@redhat.com>
2026-09-18rust: pin-init: internal: use span of `Index` for generated identifiersGary Guo
Use the span of `Index` for generated identifiers, so diagnostics can point to the span of the index. Link: https://patch.msgid.link/20260916184131.435059-1-gary@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-18rust: pin-init: internal: init: provide span for slot projectionGary Guo
When initializing a field, pin-init first projects the full slot to a slot of the field, then initialize it by invoking a method. Currently the span location is not explicitly set, so the error message points to the full macro invocation. Improve it by provide a span, so Rust will point to the specific fields causing the error when type check fails. Old error message: error[E0308]: mismatched types --> tests/ui/compile-fail/init/field_value_wrong_type.rs:8:28 | 8 | let _ = init!(Foo { a: () }); | ---------------^^--- | | | | | expected `usize`, found `()` | arguments to this method are incorrect New error message: error[E0308]: mismatched types --> tests/ui/compile-fail/init/field_value_wrong_type.rs:8:28 | 8 | let _ = init!(Foo { a: () }); | ---^^ | | | | | expected `usize`, found `()` | arguments to this method are incorrect Link: https://patch.msgid.link/20260916-dev-hygiene-v1-3-dfb6ae2588ba@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-18rust: pin-init: internal: init: use `slot` identifier directly with mixed siteGary Guo
Use `quote_spanned!(Span::mixed_site() => ...)` directly instead of creating `slot` identifier and interpolate it later. Do the same for `__data`, too. This is needed so that we can customize the location of the span without having the `slot` identifier getting in the way. For example: quote_spanned!(Span::mixed_site().located_at(loc) => ...) with `slot` mentioned directly will have the diagnostic pointing to the desired location, while `#slot` won't. Link: https://patch.msgid.link/20260916-dev-hygiene-v1-2-dfb6ae2588ba@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-18rust: pin-init: internal: init: emit `slot` using mixed site hygieneGary Guo
Syn/quote's default is the call site hygiene. If user provides a field named `slot`, it will conflict with pin-init generated `slot` identifier. Change it to use mixed site hygiene instead. Fixes: 4883830e9784 ("rust: pin-init: rewrite the initializer macros using `syn`") Link: https://patch.msgid.link/20260916-dev-hygiene-v1-1-dfb6ae2588ba@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-18Merge tag 'drm-misc-next-2026-09-17' of ↵Dave Airlie
https://gitlab.freedesktop.org/drm/misc/kernel into drm-next drm-misc-next for v7.4: UAPI Changes: ivpu: - add DRM_IVPU_CAP_CMDQ_SET_PRIORITY Cross-subsystem Changes: dma-fence: - fix documentation vga_switcheroo: - disconnect from fbcon; update fbcon from within DRM fbdev emulation Core Changes: atomic: - replace state reset callback with create_state throughout DRM core and drivers panic: - split into core and helpers sched: - clean up interface sysfs: - drop drm_class_device_register() Driver Changes: amdxdna: - fix BO handling arcpgu: - replace simple-display pipeline with regular atomic helpers aspeed: - replace simple-display pipeline with regular atomic helpers gm12u320: - replace simple-display pipeline with regular atomic helpers imagination: - various improvement to firmware interaction ivpu: - support command-queue priority ioctl mcde: - replace simple-display pipeline with regular atomic helpers p111: - replace simple-display pipeline with regular atomic helpers - drop unsupported alpha formats from primary plane panel: - edp: Add support for BOE NV140FHM-T0A - samsung: Share test-key helpers rcar-du: - support Renesas R-Car V4H DSC - dsi: Support larger transfers with AXI memory repaper: - replace simple-display pipeline with regular atomic helpers rockchip: - dsi: improve PHY timings ssd130x: - support Solomon SSD1351 OLED plus DT bindings - ssd133x: upgrade color format to RGB565 tve200: - replace simple-display pipeline with regular atomic helpers xen: - replace simple-display pipeline with regular atomic helpers Signed-off-by: Dave Airlie <airlied@redhat.com> From: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patch.msgid.link/20260917090534.GA420415@2a02-2455-9062-2500-ec39-e8a6-193-9c05.dyn6.pyur.net
2026-09-17rust: net: netlink: Migrate to zerocopy's IntoBytesSagar Taunk
Replace the kernel's own `transmute::FromBytes` and `AsBytes` traits with their zerocopy equivalents. Specifically, this updates `GenlMsg::put` to rely on `IntoBytes` for converting attributes into byte slices. Also, add `Immutable` trait bound on `GenlMsg::put` as zerocopy splits the `no interior mutability` guarantee that `AsBytes` bundled together. Link: https://github.com/Rust-for-Linux/linux/issues/1241 Signed-off-by: Sagar Taunk <sagartaunk@proton.me> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260915144231.31932-1-sagartaunk@proton.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-17Merge tag 'net-7.3-rc4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net Pull networking fixes from Paolo Abeni: "Including fixes from Netfilter, Bluetooth, IPSec and WiFi. Previous releases - regressions: - netfilter: hold reference on ct until flow is released - bridge: - move switchdev call outside rcu - vlan: fix bugs caused by switchdev deletion errors - wifi: - mac80211: reset state when starting AP fails - cfg80211: don't free driver-owned scan requests - tcp: don't call skb_clone_and_charge_r() for close()d listener in tcp_v6_do_rcv() - mptcp: return sk_wait_data() errors from recvmsg() - xfrm: serialize state GC with device state flush - drop_monitor: synchronize tracepoint unregistration on error path - bluetooth: - eir: validate service data length before reading UUID - hci_sync: serialize local codec list cleanup - RFCOMM: avoid socket lock inversion in listener cleanup - eth: - lan743x: fix RX checksum use-after-free - mvpp2: prevent buffer overflow in page_pool allocation Previous releases - always broken: - core: lock the socket in sock_gettstamp() - neighbour: enforce min/max to NDTPA_INTERVAL_PROBE_TIME_MS. - sched: codel: bound the dropping loop per dequeue call - wifi: mac80211: include TIM bitmap control for buffered S1G mcast traffic - psp: avoid conflicts with skb->decrypted and sk_validate_xmit_skb() - xfrm: fix stack OOB read in iptfs_skb_reset_frag_walk() - bluetooth: hci_qca: do not write to the serial port after it is closed - dsa: mxl862xx: disable the stats poll on teardown - eth: - stmmac: fix TSO header length truncation - ip_tunnel: initialize `options_len` before referencing options" * tag 'net-7.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (159 commits) mptcp: fix bad accounting in __mptcp_subflow_push_pending() mptcp: close race between scheduler and state change mptcp: avoid unneeded actions on subflow reset net: skbuff: do not leave stale header offsets after pskb_carve() selftests: net: packetdrill: test exclusion of old ACK from TCP fast path tcp: exclude old ACKs from tcp fast path dpll: reject a reference sync pin which is not on the pin's dpll net: mvpp2: prevent buffer overflow in page_pool allocation net: macb: fix ordering around PTP timestamp read selftests: drv-net: psp: test PSP and TCP ULP mutual exclusion net: psp: avoid conflicts with skb->decrypted and sk_validate_xmit_skb() net: stmmac: preserve real_num_tx_queues on mqprio setup failure net: stmmac: propagate FPE preemption-class mapping errors net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb() net: wwan: mhi_wwan_mbim: check skb_copy_bits() return value net: wwan: mhi_wwan_mbim: guard against a cyclic NDP chain net: ethernet: cortina: Ack RX overrun interrupt correctly net: lock the socket in sock_gettstamp() eth: fbnic: ring the doorbell if a burst ends in a drop net: netsec: fix device_node reference leak on phy_np ...
2026-09-17Merge tag 'amd-drm-next-7.4-2026-09-10' of ↵Dave Airlie
https://gitlab.freedesktop.org/drm/amdgpu/kernel into drm-next amd-drm-next-7.4-2026-09-10: amdgpu: - Freesync fixes - GPUVM fix - Debugfs fixes - HDMI updates - IPS fix - GPU reset fix - RGB quantization fixes - SMU 13.0.x fixes - MES updates - UserQ updates - UVD fix - Various bounds checks - DML fixes - DCN 6 updates - NBIO 7.11.5 support - Audio fixes - More display KUnit tests - SMU 15 updates - RAS updates - VCN 5.0.2 updates - JPEG 5.0.2 updates - DCN 4.2 updates - PSR fixes - Misc cleanups - PSP 15.0.8 updates - RAS BERT support - RAS CPER updates - vblank fixes - LSDMA updates - GC 12.1 updates - MMHUB 4.2 updates - NBIO 6.3.2 updates - SMU 15.0.8 updates - IP discovery updates - GPU spatial partitioning updates - HDMI 2.1 freesync support - HDMI 2.1 ALLM support - HDMI 2.1 VRR support - Require jobs for IBs - Enable FRL for HDMI - MES oversubscription fixes - IH 6-7 updates - GMC 11-12 fault handling updates - Fixed point cleanup - Backlight fixes - GPUVM cleanup - Devcoredump fixes - UALoE (UALink over Ethernet) Support - SDMA userq fixes - GC 8 fix amdkfd: - Various bounds checks - SVM fixes - GC 12.1 updates - MES updates - Trap handler fixes - Debugfs fixes drm: - Add gem callback for when handle count goes to 0 - Rust fix UAPI: - INFO IOCTL fix for 32 bit userspace on 64 bit kernel - Add syncobj_points to USERQ signal ioctl Proposed userspace: * radeonsi NV_timeline_semaphore https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37335 * RADV user queues https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40808 - Add UALink support IOCTLs Proposed userspace: https://github.com/ROCm/rocm-systems/blob/35959f8e1260c7cee3e51a740e320be3856ee4ff/projects/rocr-runtime/libhsakmt/src/memory.c#L971 https://github.com/ROCm/rocm-systems/blob/35959f8e1260c7cee3e51a740e320be3856ee4ff/projects/rocr-runtime/libhsakmt/src/memory.c#L1036 Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexander.deucher@amd.com> Link: https://patch.msgid.link/20260910213040.826425-1-alexander.deucher@amd.com
2026-09-17drm/panic: Move panic display code into helper libraryThomas Zimmermann
Move drm_plane_helper_display_panic_screen() and the existing panic- display code into drm_panic_helper.c. Rename symbols accordingly. Also update the QR-related code and the bindings accordingly. Link the rsp. object file into drm_kms_helper.ko. Eventually the code will become a DRM drawing library, together with DRM's format and draw helpers. This requires more preparation. until then, KMS helpers serve as a module. All DRM drivers link it anyway. Add a new section about drawing helpers to the documentation of the KMS helpers. List format and panic helpers there. v2: - fix dependencies on other DRM modules (Randy, Sashiko) - provide placeholders for drm_panic_helper_{init,exit}() (Sashiko) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://patch.msgid.link/20260911124540.279841-14-tzimmermann@suse.de
2026-09-14rust: net: phy: fix off-by-one bit positions in device status accessorsChunfeng Song
The hand-written bitfield offsets in is_link_up(), is_autoneg_enabled() and is_autoneg_completed() were correct when the abstraction was merged: at that time autoneg, link, and autoneg_complete were at bits 13, 14, and 15 of struct phy_device's first bitfield unit. Commit 2796ff1e3dca ("net: phy: add flag is_genphy_driven to struct phy_device") later inserted is_genphy_driven just before autoneg, shifting the three fields up by one, so the accessors now read: is_link_up() reads bit 14 = autoneg is_autoneg_enabled() reads bit 13 = is_genphy_driven is_autoneg_completed() reads bit 15 = link The official ax88796b Rust driver uses all three accessors in its read_status() implementation, so it inherits the bug. phy_attach_direct() sets is_genphy_driven only when it falls back to the generic driver, and ax88796b has a real driver, so is_genphy_driven stays 0. The broken is_autoneg_enabled() therefore reads bit 13 as 0, compares it against AUTONEG_ENABLE (1), and always returns false, so read_status() never reaches the resolve_aneg_linkmode() call. The ordinary bindgen accessors take &self. Calling them through (*phydev).link() would create a shared reference to the complete bindings::phy_device, which is not appropriate for an object wrapped in Opaque. Use the bindgen-generated raw accessors (link_raw(), autoneg_raw(), and autoneg_complete_raw()) instead. They retain the bit positions and endianness handling generated from the C layout without creating a Rust reference to the complete phy_device. Drop the hand-written numbers together with the TODO comment that marked them as a stopgap. The raw accessors are only emitted by bindgen 0.71 and later, and were added at the Rust-for-Linux project's request, so this fix can only be backported to stable branches whose minimum bindgen version is at least that, hence the scope on the Cc: stable line below. Found by a static equivalence audit (C2RustDrv, a C-to-Rust driver migration tool) that compares hand-written bitfield offsets against the bindgen layout of struct phy_device. Verified by building the bindings and checking the generated accessors; no runtime testing was possible without PHY hardware. Fixes: 2796ff1e3dca ("net: phy: add flag is_genphy_driven to struct phy_device") Cc: stable@vger.kernel.org # Only 7.1.y and later (requires bindgen's raw pointer accessors). Link: https://github.com/rust-lang/rust-bindgen/issues/2674 Signed-off-by: Chunfeng Song <springbreeze@stu.pku.edu.cn> Reviewed-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://patch.msgid.link/20260910055110.167110-1-springbreeze@stu.pku.edu.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-14rust: pin-init: internal: init: support tuple struct constructor syntaxMohamad Alsadhan
A tuple struct whose fields are all set to a value reads better written like a call to its constructor than with the indices spelled out: pin_init!(Foo(value, value)) Parse the two forms into separate types and rewrite the constructor arguments into the indexed fields they are shorthand for, so that only the parser has to know about the second form. The arguments have no names, so they cannot use `<-`. Parse it anyway and reject it afterwards, which reports the position of every offending `<-` rather than stopping at the first one. `cfg` needs different treatment for tuple constructor syntax. As non-derive proc macros are invoked before cfg is resolved, the macro cannot know whether a field survives, and dropping a tuple field renumbers every field after it. That cannot be expressed by attaching a `cfg` attribute to the initializer of a single field. Thus, resolve tuple field cfgs up front instead, by generating two cfg-gated invocations of the macro with one field resolved in each. This is the approach of commit 5bbf2b2deb94 ("rust: pin-init: internal: rework how `#[pin_data]` handles cfg"), and it is linear time because only one of the two branches is ever expanded. Struct expression syntax do not renumber, so using tuple structs with struct syntax can keep using the existing attribute-based handling. Suggested-by: Gary Guo <gary@garyguo.net> Link: https://github.com/Rust-for-Linux/pin-init/pull/165 Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc> [ Pre-expand cfgs for tuple init syntax. Use generics instead of separate types for normalization - Gary ] Co-developed-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260904-tuple-struct-v1-4-72c50bd037fd@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-14rust: pin-init: internal: init: support tuple structs in `[pin_]init!`Mohamad Alsadhan
Extend the initializer syntax so that a field can be named by an index, addressing tuple struct fields the same way a struct expression does: pin_init!(Foo { 0: value, 1 <- initializer }) Tuple fields are not exposed by a `let` binding to the fields after them, since they have no name to bind; `_0` would shadow a user variable. Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc> [ Fixed incorrect index calculation and cleaned up the code - Gary ] Link: https://patch.msgid.link/20260904-tuple-struct-v1-3-72c50bd037fd@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-14rust: pin-init: internal: pin_data: support tuple struct projectionsMohamad Alsadhan
`#[pin_data]` rejects tuple structs because it assumes every field has a name, which it uses for the projection field, the `__Unpin` field and the pin-data accessor. Identify fields by `syn::Member` instead, so that tuple fields are referred to by their index in generated field accesses. The names that generated items still need are derived from the index as `_0`, `_1`, etc. The projection of a tuple struct is a tuple struct itself, so projected fields are accessed with the same `.0`, `.1` syntax as on the input type rather than through synthesised names. Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc> [ Moved utility code to util.rs as extension trait - Gary ] Link: https://patch.msgid.link/20260904-tuple-struct-v1-2-72c50bd037fd@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-14rust: pin-init: internal: extract utility code to new moduleGary Guo
Create a new `util.rs` to host utility code that are generic and can be shared by multiple macros. Link: https://patch.msgid.link/20260904-tuple-struct-v1-1-72c50bd037fd@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
2026-09-13Merge tag 'rust-fixes-7.3-2' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux Pull Rust fixes from Miguel Ojeda: "Toolchain and infrastructure: - Work around a 'bindgen' 0.73.2 bug that emits an 'allow' attribute for 'unnecessary_transmutes', which is unknown in older compilers - Clean 'clippy::as_underscore' lints in generated code by the new 'bindgen' 0.73.0+ releases - Clean new 'clippy::needless_range_loop' lint for the upcoming Rust 1.100.0 (expected 2026-11-12) 'kernel' crate: - 'num' module: fix soundness issue in 'Bounded' by sealing the 'Integer' trait 'pin-init' crate: - Fix unreachable warning for the upcoming Rust 1.100.0 (expected 2026-11-12) due to 'Infallible' becoming an alias of '!' Samples: - Add missing newlines in 'pr_*!'s macro calls" * tag 'rust-fixes-7.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: rust: allow `unknown_lints` in generated bindings for Rust < 1.88 rust: allow `clippy::as_underscore` in the generated bindings rust: num: seal Integer drm/panic: clean new `clippy::needless_range_loop` lint for Rust 1.100.0 rust: samples: add missing newlines in rust_print_main rust: pin-init: use irrefutable pattern for `stack_pin_init`
2026-09-11rust: auxiliary: validate DeviceId name lengthGeorgios Androutsopoulos
`DeviceId::new()` copies `modname` and `name` into the fixed 40-byte `auxiliary_device_id::name` array without checking that they fit. An oversized name is caught by the array bounds check, but the error reports an out-of-bounds index in the copy loop rather than the constraint the caller violated. Check the invariant explicitly instead, so the failure states the length limit rather than an array index. This should only be reached when constructing a device ID table, so the failure is a compile time error. Document that intent. Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260910153844.3987791-1-georgeandrout13@gmail.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-11rust: pci: add resource_flags accessorJoel Fernandes
Add a `Device::resource_flags()` method to the PCI Rust abstraction, wrapping the C-side static inline `pci_resource_flags()`. The flags returned correspond to the `IORESOURCE` bitmask carried by a PCI BAR's `struct resource`. The immediate motivation is BAR layout discovery on NVIDIA GPUs: a 64-bit BAR consumes two consecutive Linux PCI resource slots (the lower 32 bits at index N and the upper 32 bits at index N+1, with the latter having no flags or size of its own). Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260908-pci-resource-flags-v1-1-269f29f81de6@nvidia.com Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
2026-09-11rust: maple_tree: implement Send and Sync for MapleTreeJoel Fernandes
The C maple_tree struct contains a *mut c_void, which prevents Rust from auto-deriving Send/Sync. Following is an example error message when using MapleTree in nova-core's Vmm. This propagates up through MapleTreeAlloc to Vmm, BarUser, Gpu, and NovaCore, causing NovaCore to fail the Send bound required by pci::Driver: error[E0277]: `*mut c_void` cannot be sent between threads safely --> drivers/gpu/nova-core/driver.rs:77:22 | 77 | impl pci::Driver for NovaCore { | ^^^^^^^^ `*mut c_void` cannot be sent between threads safely | = help: within `MapleTreeAlloc<()>`, the trait `Send` is not implemented for `*mut c_void` note: required because it appears within the type `kernel::bindings::maple_tree` note: required because it appears within the type `Opaque<kernel::bindings::maple_tree>` note: required because it appears within the type `MapleTree<()>` note: required because it appears within the type `MapleTreeAlloc<()>` = note: required for `Box<MapleTreeAlloc<()>, Kmalloc>` to implement `Send` note: required because it appears within the type `core::pin::Pin<Box<MapleTreeAlloc<()>, Kmalloc>>` note: required because it appears within the type `Vmm` note: required because it appears within the type `BarUser` note: required because it appears within the type `Gpu` note: required because it appears within the type `NovaCore` note: required by a bound in `kernel::pci::Driver` --> rust/kernel/pci.rs:294:19 Implement Send and Sync for MapleTree. The tree contains no thread-local state, and all shared access goes through the internal ma_lock spinlock. Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Boqun Feng <boqun@kernel.org> [ecourtney: also require T: Sync for the Sync impl] Acked-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Liam R. Howlett (Oracle) <liam@infradead.org> Link: https://patch.msgid.link/20260908-maple-tree-send-sync-v2-1-24aae5b3a990@nvidia.com Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
2026-09-10rust: lsm: replace `core::mem::zeroed` with `pin_init::zeroed`Benno Lossin
All types in `bindings` implement `Zeroable` if they can, so use `pin_init::zeroed` instead of relying on `unsafe` code. If this ends up not compiling in the future, something in bindgen or on the C side changed and is most likely incorrect. Link: https://lore.kernel.org/r/20250814093046.2071971-8-lossin@kernel.org Link: https://github.com/Rust-for-Linux/linux/issues/1189 Signed-off-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Nils Lehnen <nils.lehnen@proton.me> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> [PM: subject tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
2026-09-10rust/drm/gem: initialize callbacks with ..pin_init::zeroed()Klara Modin
When the commit b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0") added the handle_free callback, it did not update the rust abstraction, which will cause a build failure when that is enabled. Rather than just adding another None initializer, use ..pin_init::zeroed() to make all unlisted callbacks None, and remove the existing zero-initializations. Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0") Reported-by: Thorsten Leemhuis <linux@leemhuis.info> Closes: https://lore.kernel.org/all/aaef18cd-ab55-4fb8-8563-ca3a5ea9cbc6@leemhuis.info Reported-by: Thomas Zimmermann <tzimmermann@suse.de> Closes: https://lore.kernel.org/all/4da62a4b-c4ef-492a-9a27-b56bd4784acf@suse.de Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Klara Modin <klarasmodin@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>