Re: [PATCH] rust: bindings: derive Zeroable for bindgen's opaque array wrappers

From: Andreas Hindborg

Date: Mon Nov 02 2026 - 07:14:18 EST


"Miguel Ojeda" <miguel.ojeda.sandonis@xxxxxxxxx> writes:

> 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).

Thanks, works for me.

Best regards,
Andreas Hindborg