Loading core/java/com/android/internal/os/Zygote.java +7 −0 Original line number Diff line number Diff line Loading @@ -1065,4 +1065,11 @@ public final class Zygote { * Returns whether the hardware supports memory tagging (ARM MTE). */ public static native boolean nativeSupportsMemoryTagging(); /** * Returns whether the kernel supports tagged pointers. Present in the * Android Common Kernel from 4.14 and up. By default, you should prefer * fully-feature Memory Tagging, rather than the static Tagged Pointers. */ public static native boolean nativeSupportsTaggedPointers(); } core/java/com/android/internal/os/ZygoteInit.java +2 −2 Original line number Diff line number Diff line Loading @@ -754,9 +754,9 @@ public class ZygoteInit { /* The system server is more privileged than regular app processes, so it has async * tag checks enabled on hardware that supports memory tagging. */ parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_ASYNC; } else { } else if (Zygote.nativeSupportsTaggedPointers()) { /* Enable pointer tagging in the system server. Hardware support for this is present * in all ARMv8 CPUs; this flag has no effect on other platforms. */ * in all ARMv8 CPUs. */ parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI; } Loading core/jni/com_android_internal_os_Zygote.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -2456,6 +2456,15 @@ static jboolean com_android_internal_os_Zygote_nativeSupportsMemoryTagging(JNIEn #endif } static jboolean com_android_internal_os_Zygote_nativeSupportsTaggedPointers(JNIEnv* env, jclass) { #ifdef __aarch64__ int res = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0); return res >= 0 && res & PR_TAGGED_ADDR_ENABLE; #else return false; #endif } static const JNINativeMethod gMethods[] = { {"nativeForkAndSpecialize", "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/" Loading Loading @@ -2493,6 +2502,8 @@ static const JNINativeMethod gMethods[] = { (void*)com_android_internal_os_Zygote_nativeParseSigChld}, {"nativeSupportsMemoryTagging", "()Z", (void*)com_android_internal_os_Zygote_nativeSupportsMemoryTagging}, {"nativeSupportsTaggedPointers", "()Z", (void*)com_android_internal_os_Zygote_nativeSupportsTaggedPointers}, }; int register_com_android_internal_os_Zygote(JNIEnv* env) { Loading services/core/java/com/android/server/am/ProcessList.java +3 −3 Original line number Diff line number Diff line Loading @@ -1862,9 +1862,9 @@ public final class ProcessList { || mPlatformCompat.isChangeEnabled(NATIVE_MEMORY_TAGGING, app.info)) { runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_ASYNC; } } else { // Enable heap pointer tagging, unless disabled by the app manifest, target sdk // level, or the compat feature. } else if (Zygote.nativeSupportsTaggedPointers()) { // Enable heap pointer tagging if supported by the kernel, unless disabled by the // app manifest, target sdk level, or compat feature. if (app.info.allowsNativeHeapPointerTagging() && mPlatformCompat.isChangeEnabled(NATIVE_HEAP_POINTER_TAGGING, app.info)) { runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI; Loading Loading
core/java/com/android/internal/os/Zygote.java +7 −0 Original line number Diff line number Diff line Loading @@ -1065,4 +1065,11 @@ public final class Zygote { * Returns whether the hardware supports memory tagging (ARM MTE). */ public static native boolean nativeSupportsMemoryTagging(); /** * Returns whether the kernel supports tagged pointers. Present in the * Android Common Kernel from 4.14 and up. By default, you should prefer * fully-feature Memory Tagging, rather than the static Tagged Pointers. */ public static native boolean nativeSupportsTaggedPointers(); }
core/java/com/android/internal/os/ZygoteInit.java +2 −2 Original line number Diff line number Diff line Loading @@ -754,9 +754,9 @@ public class ZygoteInit { /* The system server is more privileged than regular app processes, so it has async * tag checks enabled on hardware that supports memory tagging. */ parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_ASYNC; } else { } else if (Zygote.nativeSupportsTaggedPointers()) { /* Enable pointer tagging in the system server. Hardware support for this is present * in all ARMv8 CPUs; this flag has no effect on other platforms. */ * in all ARMv8 CPUs. */ parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI; } Loading
core/jni/com_android_internal_os_Zygote.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -2456,6 +2456,15 @@ static jboolean com_android_internal_os_Zygote_nativeSupportsMemoryTagging(JNIEn #endif } static jboolean com_android_internal_os_Zygote_nativeSupportsTaggedPointers(JNIEnv* env, jclass) { #ifdef __aarch64__ int res = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0); return res >= 0 && res & PR_TAGGED_ADDR_ENABLE; #else return false; #endif } static const JNINativeMethod gMethods[] = { {"nativeForkAndSpecialize", "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/" Loading Loading @@ -2493,6 +2502,8 @@ static const JNINativeMethod gMethods[] = { (void*)com_android_internal_os_Zygote_nativeParseSigChld}, {"nativeSupportsMemoryTagging", "()Z", (void*)com_android_internal_os_Zygote_nativeSupportsMemoryTagging}, {"nativeSupportsTaggedPointers", "()Z", (void*)com_android_internal_os_Zygote_nativeSupportsTaggedPointers}, }; int register_com_android_internal_os_Zygote(JNIEnv* env) { Loading
services/core/java/com/android/server/am/ProcessList.java +3 −3 Original line number Diff line number Diff line Loading @@ -1862,9 +1862,9 @@ public final class ProcessList { || mPlatformCompat.isChangeEnabled(NATIVE_MEMORY_TAGGING, app.info)) { runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_ASYNC; } } else { // Enable heap pointer tagging, unless disabled by the app manifest, target sdk // level, or the compat feature. } else if (Zygote.nativeSupportsTaggedPointers()) { // Enable heap pointer tagging if supported by the kernel, unless disabled by the // app manifest, target sdk level, or compat feature. if (app.info.allowsNativeHeapPointerTagging() && mPlatformCompat.isChangeEnabled(NATIVE_HEAP_POINTER_TAGGING, app.info)) { runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI; Loading