Initial commit for Android 10, syncing up to v201
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
From efbdeeea6ac6ac7e6a33ba9034d0d26a2da2c92e Mon Sep 17 00:00:00 2001
|
||||
From: Danny Baumann <dannybaumann@web.de>
|
||||
Date: Wed, 29 Aug 2018 11:21:52 +0200
|
||||
Subject: [PATCH 1/6] Implement per-process target SDK version override.
|
||||
|
||||
Change-Id: I65bbdbe96541d8aacdd4de125cdb9c1435129413
|
||||
|
||||
This is only partial cherry-pick. Value won't be set via Android.bp
|
||||
---
|
||||
linker/linker.cpp | 13 ++++++++++++-
|
||||
1 file changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/linker/linker.cpp b/linker/linker.cpp
|
||||
index b59df7302..ccdb131ca 100644
|
||||
--- a/linker/linker.cpp
|
||||
+++ b/linker/linker.cpp
|
||||
@@ -4217,7 +4217,18 @@ std::vector<android_namespace_t*> init_default_namespaces(const char* executable
|
||||
// somain and ld_preloads are added to these namespaces after LD_PRELOAD libs are linked
|
||||
}
|
||||
|
||||
- set_application_target_sdk_version(config->target_sdk_version());
|
||||
+ uint32_t target_sdk = config->target_sdk_version();
|
||||
+#ifdef SDK_VERSION_OVERRIDES
|
||||
+ for (const auto& entry : android::base::Split(SDK_VERSION_OVERRIDES, " ")) {
|
||||
+ auto splitted = android::base::Split(entry, "=");
|
||||
+ if (splitted.size() == 2 && splitted[0] == executable_path) {
|
||||
+ target_sdk = static_cast<uint32_t>(std::stoul(splitted[1]));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ DEBUG("Target SDK for %s = %d", executable_path, target_sdk);
|
||||
+#endif
|
||||
+ set_application_target_sdk_version(target_sdk);
|
||||
|
||||
std::vector<android_namespace_t*> created_namespaces;
|
||||
created_namespaces.reserve(namespaces.size());
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From 38b21e5ba3f2ee5c8a6473ed20e6fa1946bdd2e3 Mon Sep 17 00:00:00 2001
|
||||
From: Ethan Chen <intervigil@gmail.com>
|
||||
Date: Tue, 25 Sep 2018 00:11:05 -0700
|
||||
Subject: [PATCH 2/6] Actually restore pre-P mutex behavior
|
||||
|
||||
Apps built against versions < P may not actually expect the EBUSY return
|
||||
code, and may crash or otherwise misbehave. Check for target SDK
|
||||
versions earlier than P when performing the IsMutexDestroyed check so
|
||||
any invocation of HandleUsingDestroyedMutex is bypassed and pre-P mutex
|
||||
behavior is restored.
|
||||
|
||||
See 9e989f12d1186231d97dac6d038db7955acebdf3 for the change that
|
||||
introduced this new behavior.
|
||||
|
||||
Change-Id: I45f8882c9527c63eed1ef5820a5004b8958d58ea
|
||||
---
|
||||
libc/bionic/pthread_mutex.cpp | 15 +++++++++++----
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
|
||||
index f92184e50..f006bb92d 100644
|
||||
--- a/libc/bionic/pthread_mutex.cpp
|
||||
+++ b/libc/bionic/pthread_mutex.cpp
|
||||
@@ -783,16 +783,23 @@ static int MutexLockWithTimeout(pthread_mutex_internal_t* mutex, bool use_realti
|
||||
} // namespace NonPI
|
||||
|
||||
static inline __always_inline bool IsMutexDestroyed(uint16_t mutex_state) {
|
||||
- return mutex_state == 0xffff;
|
||||
+ if (android_get_application_target_sdk_version() >= __ANDROID_API_P__) {
|
||||
+ return mutex_state == 0xffff;
|
||||
+ }
|
||||
+ return false;
|
||||
}
|
||||
|
||||
// Inlining this function in pthread_mutex_lock() adds the cost of stack frame instructions on
|
||||
// ARM64. So make it noinline.
|
||||
static int __attribute__((noinline)) HandleUsingDestroyedMutex(pthread_mutex_t* mutex,
|
||||
const char* function_name) {
|
||||
- if (android_get_application_target_sdk_version() >= __ANDROID_API_P__) {
|
||||
- __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
|
||||
- }
|
||||
+ __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
|
||||
+ return EBUSY;
|
||||
+}
|
||||
+
|
||||
+static int __always_inline HandleUsingDestroyedMutex(pthread_mutex_t* mutex,
|
||||
+ const char* function_name) {
|
||||
+ __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
From 45eed08a80644561adc9e103e7d58af691afeb86 Mon Sep 17 00:00:00 2001
|
||||
From: nx111 <gd.zhangdz@gmail.com>
|
||||
Date: Wed, 3 Oct 2018 16:58:19 +0800
|
||||
Subject: [PATCH 3/6] bionic: Use legacy pthread_mutex_init() behavior on pre-P
|
||||
API levels
|
||||
|
||||
* Google's changes to pthread_mutex_init is breaking RIL
|
||||
on certain Samsung devices like klte and hlte
|
||||
* To resolve this, add a check for their new additions
|
||||
to only apply the new behavior for P and higher APIs
|
||||
|
||||
Change-Id: I41335c5c436fa28a66d044e6634466556dfd7f95
|
||||
---
|
||||
libc/bionic/pthread_mutex.cpp | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
|
||||
index f006bb92d..969feb43c 100644
|
||||
--- a/libc/bionic/pthread_mutex.cpp
|
||||
+++ b/libc/bionic/pthread_mutex.cpp
|
||||
@@ -527,7 +527,8 @@ int pthread_mutex_init(pthread_mutex_t* mutex_interface, const pthread_mutexattr
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
- if (((*attr & MUTEXATTR_PROTOCOL_MASK) >> MUTEXATTR_PROTOCOL_SHIFT) == PTHREAD_PRIO_INHERIT) {
|
||||
+ if (((*attr & MUTEXATTR_PROTOCOL_MASK) >> MUTEXATTR_PROTOCOL_SHIFT) == PTHREAD_PRIO_INHERIT
|
||||
+ && bionic_get_application_target_sdk_version() >= __ANDROID_API_P__) {
|
||||
#if !defined(__LP64__)
|
||||
if (state & MUTEX_SHARED_MASK) {
|
||||
return EINVAL;
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From e77d8ff8326def1d6b457bfd4c8b232dc58dd7cb Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Thu, 3 Jan 2019 17:50:03 +0100
|
||||
Subject: [PATCH 4/6] Read SDK version override from property
|
||||
|
||||
Change-Id: I88ca5d0bde15ee4f2b2bd1255e98f9592973dbf9
|
||||
---
|
||||
linker/linker.cpp | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/linker/linker.cpp b/linker/linker.cpp
|
||||
index ccdb131ca..f45a40b9d 100644
|
||||
--- a/linker/linker.cpp
|
||||
+++ b/linker/linker.cpp
|
||||
@@ -4218,7 +4218,9 @@ std::vector<android_namespace_t*> init_default_namespaces(const char* executable
|
||||
}
|
||||
|
||||
uint32_t target_sdk = config->target_sdk_version();
|
||||
-#ifdef SDK_VERSION_OVERRIDES
|
||||
+
|
||||
+ std::string sdkVersionOverrides = android::base::GetProperty("persist.sys.phh.sdk_override", "");
|
||||
+ static const char *SDK_VERSION_OVERRIDES = sdkVersionOverrides.c_str();
|
||||
for (const auto& entry : android::base::Split(SDK_VERSION_OVERRIDES, " ")) {
|
||||
auto splitted = android::base::Split(entry, "=");
|
||||
if (splitted.size() == 2 && splitted[0] == executable_path) {
|
||||
@@ -4227,7 +4229,7 @@ std::vector<android_namespace_t*> init_default_namespaces(const char* executable
|
||||
}
|
||||
}
|
||||
DEBUG("Target SDK for %s = %d", executable_path, target_sdk);
|
||||
-#endif
|
||||
+
|
||||
set_application_target_sdk_version(target_sdk);
|
||||
|
||||
std::vector<android_namespace_t*> created_namespaces;
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From f32750cc994642f6ba792051f20c3f930f3007d2 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Thu, 12 Sep 2019 12:54:23 +0200
|
||||
Subject: [PATCH 5/6] Use vndk_lite ld.config only on same-version vendor
|
||||
|
||||
When running Q over P lite, there is currently absolutely no chance the
|
||||
device boots, because it will be using Q vndk.
|
||||
Thus using ld.config.28.txt when running Q over P lite gives a little more
|
||||
chance for the device to boot, than when using vndk_lite ld.config.
|
||||
Also, once this patch is applied, the required effort to boot
|
||||
Q over P lite is exclusively in vndk, which is manageable.
|
||||
|
||||
Change-Id: I55257cd7c738b1d20582e198e1d5621e1c87a03e
|
||||
---
|
||||
linker/linker.cpp | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/linker/linker.cpp b/linker/linker.cpp
|
||||
index f45a40b9d..9082fde53 100644
|
||||
--- a/linker/linker.cpp
|
||||
+++ b/linker/linker.cpp
|
||||
@@ -4069,7 +4069,10 @@ static std::string get_ld_config_file_apex_path(const char* executable_path) {
|
||||
}
|
||||
|
||||
static std::string get_ld_config_file_vndk_path() {
|
||||
- if (android::base::GetBoolProperty("ro.vndk.lite", false)) {
|
||||
+ bool same_version_system_vendor = false;
|
||||
+ if(std::to_string(__ANDROID_API__) == Config::get_vndk_version_string('.'))
|
||||
+ same_version_system_vendor = true;
|
||||
+ if (android::base::GetBoolProperty("ro.vndk.lite", false) && same_version_system_vendor) {
|
||||
return kLdConfigVndkLiteFilePath;
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
From 13acd597e0dd22c5fa462007b20fe4f2398db297 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Thu, 12 Sep 2019 13:00:55 +0200
|
||||
Subject: [PATCH 6/6] fixup! Actually restore pre-P mutex behavior
|
||||
|
||||
---
|
||||
libc/bionic/pthread_mutex.cpp | 8 +-------
|
||||
1 file changed, 1 insertion(+), 7 deletions(-)
|
||||
|
||||
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
|
||||
index 969feb43c..bd9fabdb6 100644
|
||||
--- a/libc/bionic/pthread_mutex.cpp
|
||||
+++ b/libc/bionic/pthread_mutex.cpp
|
||||
@@ -528,7 +528,7 @@ int pthread_mutex_init(pthread_mutex_t* mutex_interface, const pthread_mutexattr
|
||||
}
|
||||
|
||||
if (((*attr & MUTEXATTR_PROTOCOL_MASK) >> MUTEXATTR_PROTOCOL_SHIFT) == PTHREAD_PRIO_INHERIT
|
||||
- && bionic_get_application_target_sdk_version() >= __ANDROID_API_P__) {
|
||||
+ && android_get_application_target_sdk_version() >= __ANDROID_API_P__) {
|
||||
#if !defined(__LP64__)
|
||||
if (state & MUTEX_SHARED_MASK) {
|
||||
return EINVAL;
|
||||
@@ -798,12 +798,6 @@ static int __attribute__((noinline)) HandleUsingDestroyedMutex(pthread_mutex_t*
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
-static int __always_inline HandleUsingDestroyedMutex(pthread_mutex_t* mutex,
|
||||
- const char* function_name) {
|
||||
- __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
|
||||
- return EBUSY;
|
||||
-}
|
||||
-
|
||||
int pthread_mutex_lock(pthread_mutex_t* mutex_interface) {
|
||||
#if !defined(__LP64__)
|
||||
// Some apps depend on being able to pass NULL as a mutex and get EINVAL
|
||||
--
|
||||
2.17.1
|
||||
|
||||
Reference in New Issue
Block a user