Re: [PATCH] rust: bindings: derive Zeroable for bindgen's opaque array wrappers
From: Miguel Ojeda
Date: Sun Nov 01 2026 - 21:09:38 EST
On Sat, Oct 31, 2026 at 4:28 PM Sasha Levin <sashal@xxxxxxxxxx> wrote:
>
> bindgen 0.73 emits the blob of some opaque types, such as ones aligned
> to more than 4 bytes, as a `__BindgenOpaqueArray` or
> `__BindgenOpaqueArray<align>` newtype instead of a plain array. The
> newtype only derives `PartialEq`, `Eq`, `Copy`, `Clone`, `Debug` and
> `Hash`, and the `MaybeZeroable` custom derive does not reach it, so a
> struct that embeds such an opaque type is no longer `Zeroable`.
>
> `spinlock` is opaque (see rust/bindgen_parameters), and with lockdep its
> blob becomes a `__BindgenOpaqueArray8<[u8; 72]>`. Commit 71ec3c7d6db8
> ("blk-mq: quiesce a queue that joins a quiesced tag set") added a
> `spinlock_t` to `struct blk_mq_tag_set`, so an allmodconfig build with
> bindgen 0.73 now fails:
>
> error[E0277]: the trait bound `bindings::__BindgenOpaqueArray8<[u8; 72]>: pin_init::Zeroable` is not satisfied
> --> rust/kernel/block/mq/tag_set.rs:41:49
>
> Which wrappers exist depends on the bindgen version and on the opaque
> types of the configuration, so they cannot be covered by unconditional
> impls in rust/bindings/lib.rs like `__BindgenBitfieldUnit` is. Derive
> `Zeroable` for each wrapper in the generated bindings instead. The
> pattern allows for the spacing of bindgen's output when rustfmt is not
> available.
>
> Fixes: 71ec3c7d6db8 ("blk-mq: quiesce a queue that joins a quiesced tag set")
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
Applied to `rust-fixes` -- thanks everyone!
I can send this to Linus in a couple days, unless Andreas shouts or
Jens prefer to take it through his tree for some reason (now that
v7.4-rc1 is out, it shouldn't matter).
Cc'ing Emilio as well so that he is aware that this means we are using
a regex to match the source code that `bindgen` emits, which isn't
great (fragile etc.) -- you can see the context at:
https://lore.kernel.org/rust-for-linux/20261031152846.746656-1-sashal@xxxxxxxxxx/T/
Cheers,
Miguel