diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 4d3df00d368c..63e56c95f79c 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -7157,6 +7157,34 @@ const struct binder_debugfs_entry binder_debugfs_entries[] = { {} /* terminator */ }; +bool binder_use_rust; +EXPORT_SYMBOL_GPL(binder_use_rust); + +static int binder_impl_param_set(const char *buffer, const struct kernel_param *kp) +{ + if (!strcmp(buffer, "rust")) + binder_use_rust = true; + else if (!strcmp(buffer, "c")) + binder_use_rust = false; + else + return -EINVAL; + + return 0; +} + +static int binder_impl_param_get(char *buffer, const struct kernel_param *kp) +{ + /* The buffer is 4k bytes, so this will not overflow. */ + return sprintf(buffer, "%s\n", binder_use_rust ? "rust" : "c"); +} + +static const struct kernel_param_ops binder_impl_param_ops = { + .set = binder_impl_param_set, + .get = binder_impl_param_get, +}; + +module_param_cb(impl, &binder_impl_param_ops, NULL, 0444); + static int __init init_binder_device(const char *name) { int ret; @@ -7195,6 +7223,9 @@ static int __init binder_init(void) char *device_names = NULL; const struct binder_debugfs_entry *db_entry; + if (binder_use_rust) + return 0; + ret = binder_alloc_shrinker_init(); if (ret) return ret;