diff options
-rw-r--r-- | cmds/atrace/atrace.cpp | 5 | ||||
-rw-r--r-- | cmds/bugreportz/readme.md | 2 | ||||
-rw-r--r-- | cmds/servicemanager/ServiceManager.cpp | 6 | ||||
-rw-r--r-- | cmds/servicemanager/ServiceManager.h | 6 | ||||
-rw-r--r-- | cmds/servicemanager/ServiceManagerFuzzer.cpp | 1 | ||||
-rw-r--r-- | libs/binder/IServiceManager.cpp | 11 | ||||
-rw-r--r-- | libs/binder/RpcTrusty.cpp | 11 | ||||
-rw-r--r-- | libs/binder/include_trusty/binder/RpcTrusty.h | 4 | ||||
-rw-r--r-- | libs/binder/ndk/Android.bp | 4 | ||||
-rw-r--r-- | libs/binder/rust/Android.bp | 3 | ||||
-rw-r--r-- | libs/binder/rust/rpcbinder/Android.bp | 43 | ||||
-rw-r--r-- | libs/binder/rust/rpcbinder/src/client.rs | 9 | ||||
-rw-r--r-- | libs/binder/rust/rpcbinder/src/server.rs | 14 | ||||
-rw-r--r-- | libs/binder/rust/src/native.rs | 2 | ||||
-rw-r--r-- | libs/binderthreadstate/test.cpp | 32 | ||||
-rw-r--r-- | libs/nativewindow/Android.bp | 3 | ||||
-rw-r--r-- | libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp | 8 | ||||
-rw-r--r-- | opengl/libs/Android.bp | 23 | ||||
-rw-r--r-- | vulkan/libvulkan/Android.bp | 3 |
19 files changed, 156 insertions, 34 deletions
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 6fb9a4d112..5cd2dea377 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -193,8 +193,9 @@ static const TracingCategory k_categories[] = { { OPT, "events/ext4/ext4_da_write_end/enable" }, { OPT, "events/ext4/ext4_sync_file_enter/enable" }, { OPT, "events/ext4/ext4_sync_file_exit/enable" }, - { REQ, "events/block/block_rq_issue/enable" }, - { REQ, "events/block/block_rq_complete/enable" }, + { REQ, "events/block/block_bio_queue/enable" }, + { REQ, "events/block/block_bio_complete/enable" }, + { REQ, "events/ufs/ufshcd_command/enable" }, } }, { "mmc", "eMMC commands", 0, { { REQ, "events/mmc/enable" }, diff --git a/cmds/bugreportz/readme.md b/cmds/bugreportz/readme.md index eb0d898be1..3606827a4d 100644 --- a/cmds/bugreportz/readme.md +++ b/cmds/bugreportz/readme.md @@ -1,6 +1,6 @@ # bugreportz protocol -`bugreportz` is used to generate a zippped bugreport whose path is passed back to `adb`, using +`bugreportz` is used to generate a zipped bugreport whose path is passed back to `adb`, using the simple protocol defined below. # Version 1.1 diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp index 3cfe5297ca..07273835f9 100644 --- a/cmds/servicemanager/ServiceManager.cpp +++ b/cmds/servicemanager/ServiceManager.cpp @@ -762,4 +762,10 @@ Status ServiceManager::getServiceDebugInfo(std::vector<ServiceDebugInfo>* outRet return Status::ok(); } +void ServiceManager::clear() { + mNameToService.clear(); + mNameToRegistrationCallback.clear(); + mNameToClientCallback.clear(); +} + } // namespace android diff --git a/cmds/servicemanager/ServiceManager.h b/cmds/servicemanager/ServiceManager.h index 5e403194d7..c6db697a89 100644 --- a/cmds/servicemanager/ServiceManager.h +++ b/cmds/servicemanager/ServiceManager.h @@ -58,6 +58,12 @@ public: void binderDied(const wp<IBinder>& who) override; void handleClientCallbacks(); + /** + * This API is added for debug purposes. It clears members which hold service and callback + * information. + */ + void clear(); + protected: virtual void tryStartService(const std::string& name); diff --git a/cmds/servicemanager/ServiceManagerFuzzer.cpp b/cmds/servicemanager/ServiceManagerFuzzer.cpp index 39f8522f84..b76a6bd3cd 100644 --- a/cmds/servicemanager/ServiceManagerFuzzer.cpp +++ b/cmds/servicemanager/ServiceManagerFuzzer.cpp @@ -29,6 +29,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { auto accessPtr = std::make_unique<Access>(); auto serviceManager = sp<ServiceManager>::make(std::move(accessPtr)); fuzzService(serviceManager, FuzzedDataProvider(data, size)); + serviceManager->clear(); return 0; } diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 5db3eef392..05db7743f2 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -380,6 +380,13 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16) if (Status status = realGetService(name, &out); !status.isOk()) { ALOGW("Failed to getService in waitForService for %s: %s", name.c_str(), status.toString8().c_str()); + if (0 == ProcessState::self()->getThreadPoolMaxTotalThreadCount()) { + ALOGW("Got service, but may be racey because we could not wait efficiently for it. " + "Threadpool has 0 guaranteed threads. " + "Is the threadpool configured properly? " + "See ProcessState::startThreadPool and " + "ProcessState::setThreadPoolMaxThreadCount."); + } return nullptr; } if (out != nullptr) return out; @@ -410,7 +417,9 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16) if (waiter->mBinder != nullptr) return waiter->mBinder; } - ALOGW("Waited one second for %s (is service started? are binder threads started and available?)", name.c_str()); + ALOGW("Waited one second for %s (is service started? Number of threads started in the " + "threadpool: %zu. Are binder threads started and available?)", + name.c_str(), ProcessState::self()->getThreadPoolMaxTotalThreadCount()); // Handle race condition for lazy services. Here is what can happen: // - the service dies (not processed by init yet). diff --git a/libs/binder/RpcTrusty.cpp b/libs/binder/RpcTrusty.cpp index ea49eef676..3b53b05991 100644 --- a/libs/binder/RpcTrusty.cpp +++ b/libs/binder/RpcTrusty.cpp @@ -26,8 +26,12 @@ namespace android { using android::base::unique_fd; -sp<IBinder> RpcTrustyConnect(const char* device, const char* port) { +sp<RpcSession> RpcTrustyConnectWithSessionInitializer( + const char* device, const char* port, + std::function<void(sp<RpcSession>&)> sessionInitializer) { auto session = RpcSession::make(RpcTransportCtxFactoryTipcAndroid::make()); + // using the callback to initialize the session + sessionInitializer(session); auto request = [=] { int tipcFd = tipc_connect(device, port); if (tipcFd < 0) { @@ -40,6 +44,11 @@ sp<IBinder> RpcTrustyConnect(const char* device, const char* port) { LOG(ERROR) << "Failed to set up Trusty client. Error: " << statusToString(status).c_str(); return nullptr; } + return session; +} + +sp<IBinder> RpcTrustyConnect(const char* device, const char* port) { + auto session = RpcTrustyConnectWithSessionInitializer(device, port, [](auto) {}); return session->getRootObject(); } diff --git a/libs/binder/include_trusty/binder/RpcTrusty.h b/libs/binder/include_trusty/binder/RpcTrusty.h index f124e0c824..b034b9b65b 100644 --- a/libs/binder/include_trusty/binder/RpcTrusty.h +++ b/libs/binder/include_trusty/binder/RpcTrusty.h @@ -22,4 +22,8 @@ namespace android { sp<IBinder> RpcTrustyConnect(const char* device, const char* port); +sp<RpcSession> RpcTrustyConnectWithSessionInitializer( + const char* device, const char* port, + std::function<void(sp<RpcSession>&)> sessionInitializer); + } // namespace android diff --git a/libs/binder/ndk/Android.bp b/libs/binder/ndk/Android.bp index 33d28e65c5..8ae7537486 100644 --- a/libs/binder/ndk/Android.bp +++ b/libs/binder/ndk/Android.bp @@ -182,4 +182,8 @@ ndk_library { name: "libbinder_ndk", symbol_file: "libbinder_ndk.map.txt", first_version: "29", + export_header_libs: [ + "libbinder_ndk_headers", + "libbinder_ndk_helper_headers", + ], } diff --git a/libs/binder/rust/Android.bp b/libs/binder/rust/Android.bp index 0ec618352a..a135796179 100644 --- a/libs/binder/rust/Android.bp +++ b/libs/binder/rust/Android.bp @@ -30,6 +30,7 @@ rust_library { apex_available: [ "//apex_available:platform", "com.android.compos", + "com.android.rkpd", "com.android.uwb", "com.android.virt", ], @@ -80,6 +81,7 @@ rust_library { apex_available: [ "//apex_available:platform", "com.android.compos", + "com.android.rkpd", "com.android.uwb", "com.android.virt", ], @@ -138,6 +140,7 @@ rust_bindgen { apex_available: [ "//apex_available:platform", "com.android.compos", + "com.android.rkpd", "com.android.uwb", "com.android.virt", ], diff --git a/libs/binder/rust/rpcbinder/Android.bp b/libs/binder/rust/rpcbinder/Android.bp index f16939036c..5ebc27f694 100644 --- a/libs/binder/rust/rpcbinder/Android.bp +++ b/libs/binder/rust/rpcbinder/Android.bp @@ -16,7 +16,7 @@ rust_library { ], rustlibs: [ "libbinder_ndk_sys", - "libbinder_rpc_unstable_bindgen", + "libbinder_rpc_unstable_bindgen_sys", "libbinder_rs", "libdowncast_rs", "liblibc", @@ -29,6 +29,35 @@ rust_library { min_sdk_version: "Tiramisu", } +// Build a separate rust_library rather than depending directly on libbinder_rpc_unstable_bindgen, +// to work around the fact that rust_bindgen targets only produce rlibs and not dylibs, which would +// result in duplicate conflicting versions of libbinder_ndk_sys. This will hopefully be fixed in +// the build system, at which point we can delete this target and go back to using +// libbinder_rpc_unstable_bindgen directly. +rust_library { + name: "libbinder_rpc_unstable_bindgen_sys", + crate_name: "binder_rpc_unstable_bindgen", + srcs: [ + ":libbinder_rpc_unstable_bindgen", + ], + visibility: [":__subpackages__"], + rustlibs: [ + "libbinder_ndk_sys", + ], + shared_libs: [ + "libbinder_rpc_unstable", + "libutils", + ], + apex_available: [ + "com.android.compos", + "com.android.uwb", + "com.android.virt", + ], + min_sdk_version: "Tiramisu", + lints: "none", + clippy_lints: "none", +} + // TODO(b/184872979): remove once the RPC Binder API is stabilised. rust_bindgen { name: "libbinder_rpc_unstable_bindgen", @@ -36,6 +65,15 @@ rust_bindgen { crate_name: "binder_rpc_unstable_bindgen", visibility: [":__subpackages__"], source_stem: "bindings", + bindgen_flags: [ + "--blocklist-type", + "AIBinder", + "--raw-line", + "use binder_ndk_sys::AIBinder;", + ], + rustlibs: [ + "libbinder_ndk_sys", + ], shared_libs: [ "libbinder_rpc_unstable", "libutils", @@ -52,6 +90,9 @@ rust_test { name: "libbinder_rpc_unstable_bindgen_test", srcs: [":libbinder_rpc_unstable_bindgen"], crate_name: "binder_rpc_unstable_bindgen", + rustlibs: [ + "libbinder_ndk_sys", + ], test_suites: ["general-tests"], auto_gen_config: true, clippy_lints: "none", diff --git a/libs/binder/rust/rpcbinder/src/client.rs b/libs/binder/rust/rpcbinder/src/client.rs index dfc6f06b14..743800beb1 100644 --- a/libs/binder/rust/rpcbinder/src/client.rs +++ b/libs/binder/rust/rpcbinder/src/client.rs @@ -14,10 +14,7 @@ * limitations under the License. */ -use binder::{ - unstable_api::{new_spibinder, AIBinder}, - FromIBinder, SpIBinder, StatusCode, Strong, -}; +use binder::{unstable_api::new_spibinder, FromIBinder, SpIBinder, StatusCode, Strong}; use std::os::{ raw::{c_int, c_void}, unix::io::RawFd, @@ -27,7 +24,7 @@ use std::os::{ pub fn get_vsock_rpc_service(cid: u32, port: u32) -> Option<SpIBinder> { // SAFETY: AIBinder returned by RpcClient has correct reference count, and the ownership can // safely be taken by new_spibinder. - unsafe { new_spibinder(binder_rpc_unstable_bindgen::RpcClient(cid, port) as *mut AIBinder) } + unsafe { new_spibinder(binder_rpc_unstable_bindgen::RpcClient(cid, port)) } } /// Connects to an RPC Binder server for a particular interface over vsock. @@ -54,7 +51,7 @@ pub fn get_preconnected_rpc_service( new_spibinder(binder_rpc_unstable_bindgen::RpcPreconnectedClient( Some(request_fd_wrapper), param, - ) as *mut AIBinder) + )) } } diff --git a/libs/binder/rust/rpcbinder/src/server.rs b/libs/binder/rust/rpcbinder/src/server.rs index d98a439da4..aeb23c60e2 100644 --- a/libs/binder/rust/rpcbinder/src/server.rs +++ b/libs/binder/rust/rpcbinder/src/server.rs @@ -14,7 +14,10 @@ * limitations under the License. */ -use binder::{unstable_api::AsNative, SpIBinder}; +use binder::{ + unstable_api::{AIBinder, AsNative}, + SpIBinder, +}; use std::{os::raw, ptr::null_mut}; /// Runs a binder RPC server, serving the supplied binder service implementation on the given vsock @@ -44,7 +47,7 @@ where F: FnOnce(), { fn run_server(&mut self, mut service: SpIBinder, port: u32) -> bool { - let service = service.as_native_mut() as *mut binder_rpc_unstable_bindgen::AIBinder; + let service = service.as_native_mut(); let param = self.as_void_ptr(); // SAFETY: Service ownership is transferring to the server and won't be valid afterward. @@ -106,10 +109,7 @@ pub fn run_rpc_server_with_factory( } } -unsafe extern "C" fn factory_wrapper( - cid: u32, - context: *mut raw::c_void, -) -> *mut binder_rpc_unstable_bindgen::AIBinder { +unsafe extern "C" fn factory_wrapper(cid: u32, context: *mut raw::c_void) -> *mut AIBinder { // SAFETY: `context` was created from an `&mut RpcServerFactoryRef` by // `run_rpc_server_with_factory`, and we are still within the lifetime of the value it is // pointing to. @@ -117,7 +117,7 @@ unsafe extern "C" fn factory_wrapper( let factory = factory_ptr.as_mut().unwrap(); if let Some(mut service) = factory(cid) { - service.as_native_mut() as *mut binder_rpc_unstable_bindgen::AIBinder + service.as_native_mut() } else { null_mut() } diff --git a/libs/binder/rust/src/native.rs b/libs/binder/rust/src/native.rs index 3a6daddffd..dee05d07cf 100644 --- a/libs/binder/rust/src/native.rs +++ b/libs/binder/rust/src/native.rs @@ -296,7 +296,7 @@ impl<T: Remotable> InterfaceClassMethods for Binder<T> { /// Must be called with a valid pointer to a `T` object. After this call, /// the pointer will be invalid and should not be dereferenced. unsafe extern "C" fn on_destroy(object: *mut c_void) { - Box::from_raw(object as *mut T); + drop(Box::from_raw(object as *mut T)); } /// Called whenever a new, local `AIBinder` object is needed of a specific diff --git a/libs/binderthreadstate/test.cpp b/libs/binderthreadstate/test.cpp index 2f731377f0..df1f35d9a7 100644 --- a/libs/binderthreadstate/test.cpp +++ b/libs/binderthreadstate/test.cpp @@ -73,6 +73,15 @@ static void callAidl(size_t id, int32_t idx) { CHECK(ret.isOk()) << ret; } +static std::string getStackPointerDebugInfo() { + const void* hwbinderSp = android::hardware::IPCThreadState::self()->getServingStackPointer(); + const void* binderSp = android::IPCThreadState::self()->getServingStackPointer(); + + std::stringstream ss; + ss << "(hwbinder sp: " << hwbinderSp << " binder sp: " << binderSp << ")"; + return ss.str(); +} + static inline std::ostream& operator<<(std::ostream& o, const BinderCallType& s) { return o << static_cast<std::underlying_type_t<BinderCallType>>(s); } @@ -88,17 +97,21 @@ public: return android::hardware::Status::ok(); } Return<void> call(int32_t idx) { + bool doCallHidl = thisId == kP1Id && idx % 4 < 2; + LOG(INFO) << "HidlServer CALL " << thisId << " to " << otherId << " at idx: " << idx - << " with tid: " << gettid(); - CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall()); + << " with tid: " << gettid() << " calling " << (doCallHidl ? "HIDL" : "AIDL"); + CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall()) + << " before call " << getStackPointerDebugInfo(); if (idx > 0) { - if (thisId == kP1Id && idx % 4 < 2) { + if (doCallHidl) { callHidl(otherId, idx - 1); } else { callAidl(otherId, idx - 1); } } - CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall()); + CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall()) + << " after call " << getStackPointerDebugInfo(); return android::hardware::Status::ok(); } }; @@ -113,17 +126,20 @@ public: return Status::ok(); } Status call(int32_t idx) { + bool doCallHidl = thisId == kP2Id && idx % 4 < 2; LOG(INFO) << "AidlServer CALL " << thisId << " to " << otherId << " at idx: " << idx - << " with tid: " << gettid(); - CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall()); + << " with tid: " << gettid() << " calling " << (doCallHidl ? "HIDL" : "AIDL"); + CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall()) + << " before call " << getStackPointerDebugInfo(); if (idx > 0) { - if (thisId == kP2Id && idx % 4 < 2) { + if (doCallHidl) { callHidl(otherId, idx - 1); } else { callAidl(otherId, idx - 1); } } - CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall()); + CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall()) + << " after call " << getStackPointerDebugInfo(); return Status::ok(); } }; diff --git a/libs/nativewindow/Android.bp b/libs/nativewindow/Android.bp index dd07319791..d7db6bd174 100644 --- a/libs/nativewindow/Android.bp +++ b/libs/nativewindow/Android.bp @@ -61,6 +61,9 @@ ndk_library { // Android O first_version: "26", + export_header_libs: [ + "libnativewindow_ndk_headers", + ], } cc_library { diff --git a/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp b/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp index 6f10a67ebd..6a61d3615f 100644 --- a/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp +++ b/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp @@ -24,14 +24,14 @@ using namespace android; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { FuzzedDataProvider fdp(data, size); - BitTube bittube(size); + sp<BitTube> bittube(new BitTube(size)); Parcel parcel[5]; - bittube.writeToParcel(parcel); + bittube->writeToParcel(parcel); sp<BitTube> tube(new BitTube(size)); - bittube.sendObjects<uint8_t>(tube, data, size); + bittube->sendObjects<uint8_t>(tube, data, size); uint8_t recvData[size]; for (int i = 0; i < size; i++) recvData[i] = fdp.ConsumeIntegral<uint8_t>(); - bittube.recvObjects<uint8_t>(tube, recvData, size); + bittube->recvObjects<uint8_t>(tube, recvData, size); return 0; } diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp index c1e935aab0..62cf2555ca 100644 --- a/opengl/libs/Android.bp +++ b/opengl/libs/Android.bp @@ -12,7 +12,10 @@ cc_library { name: "libETC1", srcs: ["ETC1/etc1.cpp"], host_supported: true, - cflags: ["-Wall", "-Werror"], + cflags: [ + "-Wall", + "-Werror", + ], target: { android: { @@ -37,6 +40,9 @@ ndk_library { symbol_file: "libEGL.map.txt", first_version: "9", unversioned_until: "current", + export_header_libs: [ + "libEGL_headers", + ], } ndk_library { @@ -44,6 +50,9 @@ ndk_library { symbol_file: "libGLESv1_CM.map.txt", first_version: "9", unversioned_until: "current", + export_header_libs: [ + "libGLESv1_CM_headers", + ], } ndk_library { @@ -51,6 +60,9 @@ ndk_library { symbol_file: "libGLESv2.map.txt", first_version: "9", unversioned_until: "current", + export_header_libs: [ + "libGLESv2_headers", + ], } ndk_library { @@ -58,6 +70,9 @@ ndk_library { symbol_file: "libGLESv3.map.txt", first_version: "18", unversioned_until: "current", + export_header_libs: [ + "libGLESv3_headers", + ], } cc_defaults { @@ -170,7 +185,11 @@ cc_library_shared { "libEGL_getProcAddress", "libEGL_blobCache", ], - ldflags: ["-Wl,--exclude-libs=ALL,--Bsymbolic-functions"], + ldflags: [ + "-Wl,--exclude-libs=libEGL_getProcAddress.a", + "-Wl,--exclude-libs=libEGL_blobCache.a", + "-Wl,--Bsymbolic-functions", + ], export_include_dirs: ["EGL/include"], stubs: { symbol_file: "libEGL.map.txt", diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp index 5719b5cf61..a87f82fcbd 100644 --- a/vulkan/libvulkan/Android.bp +++ b/vulkan/libvulkan/Android.bp @@ -27,6 +27,9 @@ ndk_library { symbol_file: "libvulkan.map.txt", first_version: "24", unversioned_until: "current", + export_header_libs: [ + "ndk_vulkan_headers", + ], } cc_library_shared { |