diff options
author | Evgenii Stepanov <eugenis@google.com> | 2021-02-26 20:50:30 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-02-26 20:50:30 +0000 |
commit | ac811c4025c0d33283d7cbc29bc4ccaf1c3552c8 (patch) | |
tree | aa56c17d681cb7acec9f0a6aa1d61f93f2112c46 /core/jni | |
parent | 355bd7d9b80bf8898f347bb596f13bed232b851d (diff) | |
parent | d600f5067afec168699aad232a5d246bc9fd95bc (diff) |
Merge "Implement memtagMode and nativeHeapZeroInit manifest attrs." am: d600f5067a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556655
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I9c84f162736af927f6cac041f4200dc3ab2b8efa
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 4cef2b099589..bcd203b6ca77 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -344,6 +344,7 @@ enum RuntimeFlags : uint32_t { GWP_ASAN_LEVEL_NEVER = 0 << 21, GWP_ASAN_LEVEL_LOTTERY = 1 << 21, GWP_ASAN_LEVEL_ALWAYS = 2 << 21, + NATIVE_HEAP_ZERO_INIT = 1 << 23, }; enum UnsolicitedZygoteMessageTypes : uint32_t { @@ -1682,15 +1683,20 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids, } mallopt(M_BIONIC_SET_HEAP_TAGGING_LEVEL, heap_tagging_level); + // Now that we've used the flag, clear it so that we don't pass unknown flags to the ART runtime. + runtime_flags &= ~RuntimeFlags::MEMORY_TAG_LEVEL_MASK; + // Avoid heap zero initialization for applications without MTE. Zero init may // cause app compat problems, use more memory, or reduce performance. While it // would be nice to have them for apps, we will have to wait until they are // proven out, have more efficient hardware, and/or apply them only to new // applications. - mallopt(M_BIONIC_ZERO_INIT, 0); + if (!(runtime_flags & RuntimeFlags::NATIVE_HEAP_ZERO_INIT)) { + mallopt(M_BIONIC_ZERO_INIT, 0); + } // Now that we've used the flag, clear it so that we don't pass unknown flags to the ART runtime. - runtime_flags &= ~RuntimeFlags::MEMORY_TAG_LEVEL_MASK; + runtime_flags &= ~RuntimeFlags::NATIVE_HEAP_ZERO_INIT; bool forceEnableGwpAsan = false; switch (runtime_flags & RuntimeFlags::GWP_ASAN_LEVEL_MASK) { |