ANDROID: rust_binder: add Rust Binder to Makefile

For now, we only provide the option to only enable C Binder, or to
enable both drivers. When both drivers are enabled, C Binder is always
the default.

We define a separate rust_binder-objs with all of the compilation units
rather than just listing them under obj-$(ANDROID_BINDER_IPC_RUST)
because otherwise five different GKI modules are built when choosing =m
for the config option.

With this commit, Rust Binder works as a built-in module. However it is
not actually enough to use it as a GKI module because GKI modules are
loaded too late in the boot process. That issue is tracked by
b/402049944 and will be fixed in a follow-up.

Bug: 388786466
Change-Id: I04a0b604a756717fff730e6e3eb4496da016a8e5
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
Alice Ryhl
2025-03-13 09:34:27 +00:00
committed by Matthew Maurer
parent 7163533526
commit b23e338263
3 changed files with 18 additions and 0 deletions

View File

@@ -37,6 +37,18 @@ config ANDROID_BINDER_DEVICES
created. Each binder device has its own context manager, and is
therefore logically separated from the other devices.
config ANDROID_BINDER_IPC_RUST
tristate "Rust version of Android Binder IPC Driver"
depends on RUST && ANDROID_BINDER_IPC && ANDROID_BINDERFS
help
This enables the Rust implementation of the Binder driver. At this
time, the Rust implementation can only be built as an alternative to
the C implementation. By default, the C implementation is used, but
if the binder.impl=rust kernel command-line parameter is provided,
then the Rust implementation is used instead.
To build this as a GKI module, choose m.
config ANDROID_BINDER_IPC_SELFTEST
bool "Android Binder IPC Driver Selftest"
depends on ANDROID_BINDER_IPC

View File

@@ -6,3 +6,7 @@ obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o
obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o
obj-$(CONFIG_ANDROID_DEBUG_KINFO) += debug_kinfo.o
obj-$(CONFIG_ANDROID_BINDER_IPC_RUST) += rust_binder.o
rust_binder-objs := binder/rust_binder.o binder/rust_binderfs.o binder/rust_binder_events.o
rust_binder-objs += binder/rust_binder_hooks.o binder/page_range_helper.o

View File

@@ -314,6 +314,8 @@ impl kernel::Module for BinderModule {
}
}
pr_warn!("Loaded Rust Binder.");
BINDER_SHRINKER.register(kernel::c_str!("android-binder"))?;
// SAFETY: The module is being loaded, so we can initialize binderfs.