Re: [PATCH] rust_binder: add Rust Binder driver

From: Alice Ryhl

Date: Thu Sep 18 2025 - 12:55:14 EST


On Thu, Sep 18, 2025 at 04:19:57PM +0000, Carlos Llamas wrote:
> On Thu, Sep 18, 2025 at 10:19:38AM +0000, Alice Ryhl wrote:
> > Please see the attached link to the original RFC for motivation.
> >
> > I did not include all of the tracepoints as I felt that the mechansim
> > for making C access fields of Rust structs should be discussed on list
> > separately. I also did not include the support for building Rust Binder
> > as a module since that requires exporting a bunch of additional symbols
> > on the C side.
> >
> > Link: https://lore.kernel.org/r/20231101-rust-binder-v1-0-08ba9197f637@xxxxxxxxxx
> > Co-developed-by: Wedson Almeida Filho <wedsonaf@xxxxxxxxx>
> > Signed-off-by: Wedson Almeida Filho <wedsonaf@xxxxxxxxx>
> > Co-developed-by: Matt Gilbride <mattgilbride@xxxxxxxxxx>
> > Signed-off-by: Matt Gilbride <mattgilbride@xxxxxxxxxx>
> > Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> > --- /dev/null
> > +++ b/drivers/android/binder/Makefile
> > @@ -0,0 +1,9 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +ccflags-y += -I$(src) # needed for trace events
> > +
> > +obj-$(CONFIG_ANDROID_BINDER_IPC_RUST) += rust_binder.o
> > +rust_binder-$(CONFIG_ANDROID_BINDER_IPC_RUST) := \
>
> Since there is only one option for rust_binder.o, the target here should
> probably be just 'rust_binder-y := ...'.

Ok. I don't mind.

> > diff --git a/drivers/android/binder/dummy.c b/drivers/android/binder/dummy.c
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..7e9f6ea3a474b59f11e723a709c0c21e8b8beae0
> > --- /dev/null
> > +++ b/drivers/android/binder/dummy.c
>
> This dummy should be removed, we aren't going to need it here right?

Ah yeah, thanks. This file can be deleted.

> > +// SPDX-License-Identifier: GPL-2.0
>
> I'm not sure if all these need to be "GPL-2.0-only" explicitly?

It should be the same.

> > +int init_rust_binderfs(void)
> > +{
> > + int ret;
> > + const char *name;
> > + size_t len;
> > +
> > + /* Verify that the default binderfs device names are valid. */
> > + name = rust_binder_devices_param;
> > + for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) {
> > + if (len > BINDERFS_MAX_NAME)
> > + return -E2BIG;
> > + name += len;
> > + if (*name == ',')
> > + name++;
> > + }
> > +
> > + /* Allocate new major number for binderfs. */
> > + ret = alloc_chrdev_region(&binderfs_dev, 0, BINDERFS_MAX_MINOR,
> > + "rust_binder");
> > + if (ret)
> > + return ret;
> > +
> > + ret = register_filesystem(&binder_fs_type);
> > + if (ret) {
> > + unregister_chrdev_region(binderfs_dev, BINDERFS_MAX_MINOR);
> > + return ret;
> > + }
> > +
> > + return ret;
> > +}
>
> Hmm, is there anyway to keep a single binderfs.c implementation? In this
> case we now have separate CONFIGs we could use for the file creation
> callback? It would be nice to keep a single binderfs source file.

It could be nice, but it's pretty non-trivial to unify them. If we do
that, it will have to be a follow-up, and the follow-up will modify C
Binder too.

Alice