rust_binder: add Rust Binder driver
Subsystems (5)
Alice Ryhl
maintainerPATCH v2 1/1 rust_binder: add Rust Binder driver
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.
---
Changes in v2:
- rust_binder-y in Makefile
- Remove spurious dummy.c file.
- Use &raw and KVVec in page_range.rs
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/android/Kconfig | 15 +- drivers/android/Makefile | 1 + drivers/android/binder/Makefile | 9 + drivers/android/binder/allocation.rs | 602 +++++++++ drivers/android/binder/context.rs | 180 +++ drivers/android/binder/deferred_close.rs | 204 +++ drivers/android/binder/defs.rs | 182 +++ drivers/android/binder/error.rs | 99 ++ drivers/android/binder/freeze.rs | 388 ++++++ drivers/android/binder/node.rs | 1131 +++++++++++++++++ drivers/android/binder/node/wrapper.rs | 78 ++ drivers/android/binder/page_range.rs | 734 +++++++++++ drivers/android/binder/page_range_helper.c | 24 + drivers/android/binder/page_range_helper.h | 15 + drivers/android/binder/process.rs | 1696 +++++++++++++++++++++++++ drivers/android/binder/range_alloc/array.rs | 251 ++++ drivers/android/binder/range_alloc/mod.rs | 329 +++++ drivers/android/binder/range_alloc/tree.rs | 488 +++++++ drivers/android/binder/rust_binder.h | 23 + drivers/android/binder/rust_binder_events.c | 59 + drivers/android/binder/rust_binder_events.h | 36 + drivers/android/binder/rust_binder_internal.h | 87 ++ drivers/android/binder/rust_binder_main.rs | 627 +++++++++ drivers/android/binder/rust_binderfs.c | 850 +++++++++++++ drivers/android/binder/stats.rs | 89 ++ drivers/android/binder/thread.rs | 1596 +++++++++++++++++++++++ drivers/android/binder/trace.rs | 16 + drivers/android/binder/transaction.rs | 456 +++++++ include/uapi/linux/android/binder.h | 2 +- rust/bindings/bindings_helper.h | 8 + rust/helpers/binder.c | 26 + rust/helpers/helpers.c | 1 + rust/helpers/page.c | 8 + rust/helpers/security.c | 24 + rust/kernel/cred.rs | 6 + rust/kernel/page.rs | 6 + rust/kernel/security.rs | 37 + rust/uapi/uapi_helper.h | 1 + 38 files changed, 10382 insertions(+), 2 deletions(-)
drivers/android/Kconfig +14 -1
@@ -14,6 +14,19 @@ config ANDROID_BINDER_IPC Android process, using Binder to identify, invoke and pass arguments between said processes. +config ANDROID_BINDER_IPC_RUST + bool "Rust version of Android Binder IPC Driver" + depends on RUST && MMU && !ANDROID_BINDER_IPC + help + This enables the Rust implementation of the Binder driver. + + Binder is used in Android for both communication between processes, + and remote method invocation. + + This means one Android process can call a method/routine in another + Android process, using Binder to identify, invoke and pass arguments + between said processes. + config ANDROID_BINDERFS bool "Android Binderfs filesystem" depends on ANDROID_BINDER_IPC
@@ -28,7 +41,7 @@ config ANDROID_BINDERFS config ANDROID_BINDER_DEVICES string "Android Binder devices" - depends on ANDROID_BINDER_IPC + depends on ANDROID_BINDER_IPC || ANDROID_BINDER_IPC_RUST default "binder,hwbinder,vndbinder" help Default value for the binder.devices parameter.
drivers/android/Makefile +1 -0
@@ -4,3 +4,4 @@ ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_ANDROID_BINDERFS) += binderfs.o obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o binder_netlink.o obj-$(CONFIG_ANDROID_BINDER_ALLOC_KUNIT_TEST) += tests/ +obj-$(CONFIG_ANDROID_BINDER_IPC_RUST) += binder/
drivers/android/binder/Makefile new file +9 -0
@@ -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-y := \ + rust_binder_main.o \ + rust_binderfs.o \ + rust_binder_events.o \ + page_range_helper.o
drivers/android/binder/allocation.rs new file +602 -0
602 lines not on this page · raw message
drivers/android/binder/context.rs new file +180 -0
180 lines not on this page · raw message
drivers/android/binder/deferred_close.rs new file +204 -0
204 lines not on this page · raw message
drivers/android/binder/defs.rs new file +182 -0
182 lines not on this page · raw message
drivers/android/binder/error.rs new file +99 -0
99 lines not on this page · raw message
drivers/android/binder/freeze.rs new file +388 -0
388 lines not on this page · raw message
drivers/android/binder/node.rs new file +1131 -0
1,131 lines not on this page · raw message
drivers/android/binder/node/wrapper.rs new file +78 -0
78 lines not on this page · raw message
drivers/android/binder/page_range.rs new file +734 -0
96 lines not on this page · raw message
drivers/android/binder/page_range_helper.c new file +24 -0
Lines of this file are not shown. View the raw message.
drivers/android/binder/page_range_helper.h new file +15 -0
Lines of this file are not shown. View the raw message.
drivers/android/binder/process.rs new file +1696 -0
1,696 lines not on this page · raw message
drivers/android/binder/range_alloc/array.rs new file +251 -0
251 lines not on this page · raw message
drivers/android/binder/range_alloc/mod.rs new file +329 -0
329 lines not on this page · raw message
drivers/android/binder/range_alloc/tree.rs new file +488 -0
488 lines not on this page · raw message
drivers/android/binder/rust_binder.h new file +23 -0
Lines of this file are not shown. View the raw message.
drivers/android/binder/rust_binder_events.c new file +59 -0
59 lines not on this page · raw message
drivers/android/binder/rust_binder_events.h new file +36 -0
Lines of this file are not shown. View the raw message.
drivers/android/binder/rust_binder_internal.h new file +87 -0
87 lines not on this page · raw message
drivers/android/binder/rust_binder_main.rs new file +627 -0
627 lines not on this page · raw message
drivers/android/binder/rust_binderfs.c new file +850 -0
850 lines not on this page · raw message
drivers/android/binder/stats.rs new file +89 -0
89 lines not on this page · raw message
drivers/android/binder/thread.rs new file +1596 -0
1,596 lines not on this page · raw message
drivers/android/binder/trace.rs new file +16 -0
Lines of this file are not shown. View the raw message.
drivers/android/binder/transaction.rs new file +456 -0
456 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
---
base-commit: 9441d6b876529d519547a1ed3af5a08b05bd0339
change-id: 20250918-rust-binder-d80251ab47cb
Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerQuoted 7 lines · Alice Ryhl
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.
I used most of the original RFC submission for the changelog text when applying this to the char-misc tree as this isn't really a valid changelog, but rather a "what has changed from before" type of text.
Anyway, great work, nice to see this finally land, let the A/B testing begin!
greg k-h