Re: [PATCH] rust: fwctl: declare cfi_encoding for fwctl_rpc_scope
From: Alice Ryhl
Date: Tue Oct 20 2026 - 05:48:54 EST
On Tue, Oct 20, 2026 at 11:09 AM Zhi Wang <zhiw@xxxxxxxxxx> wrote:
>
> On Tue, 20 Oct 2026 11:04:43 +0200
> Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> > On Tue, Oct 20, 2026 at 10:56 AM Zhi Wang <zhiw@xxxxxxxxxx> wrote:
> > >
> > > On Tue, 20 Oct 2026 08:28:37 +0000
> > > Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
> > >
> > > > Currently, VTable::fw_rpc_callback() takes scope as a u32,
> > > > whereas C calls fwctl_ops::fw_rpc with enum fwctl_rpc_scope. With
> > > > kCFI enabled, enum types are encoded distinctly from integers,
> > > > causing every fw_rpc indirect call into a Rust fwctl driver to
> > > > trip a CFI failure. Thus, generate fwctl_rpc_scope as a newtype
> > > > with a cfi_encoding attribute and use it in fw_rpc_callback().
> > > >
> > >
> > > Thanks for the fix. Looks good to me.
> > >
> > > Reviewed-by: Zhi Wang <zhiw@xxxxxxxxxx>
> > >
> > > BTW: I saw this “lru_status” needs the same treatment, guess bindgen
> > > will someday automatically handle this?
> >
> > I believe lru_status is already handled.
> >
>
> Yes, lru_status is already handled.
>
> I meant that both lru_status and fwctl_rpc_scope need explicit entries
> in rust/bindgen_parameters. I was wondering whether there are plans for
> bindgen to generate the newtype and matching CFI encoding automatically
> for enums used in function-pointer signatures, so future additions
> wouldn't need the same manual setup.
That would be nice, but I'm not aware of anyone working on it.
Alice