Merge "Don't ask libc for PT feature w/o kernel support." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6acebc809a
@@ -1060,4 +1060,11 @@ public final class Zygote {
|
|||||||
*/
|
*/
|
||||||
@FastNative
|
@FastNative
|
||||||
public static native int nativeParseSigChld(byte[] in, int length, int[] out);
|
public static native int nativeParseSigChld(byte[] in, int length, int[] out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -757,9 +757,11 @@ public class ZygoteInit {
|
|||||||
Zygote.applyDebuggerSystemProperty(parsedArgs);
|
Zygote.applyDebuggerSystemProperty(parsedArgs);
|
||||||
Zygote.applyInvokeWithSystemProperty(parsedArgs);
|
Zygote.applyInvokeWithSystemProperty(parsedArgs);
|
||||||
|
|
||||||
/* Enable pointer tagging in the system server unconditionally. Hardware support for
|
if (Zygote.nativeSupportsTaggedPointers()) {
|
||||||
* this is present in all ARMv8 CPUs; this flag has no effect on other platforms. */
|
/* Enable pointer tagging in the system server. Hardware support for this is present
|
||||||
parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
|
* in all ARMv8 CPUs. */
|
||||||
|
parsedArgs.mRuntimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable gwp-asan on the system server with a small probability. This is the same
|
/* Enable gwp-asan on the system server with a small probability. This is the same
|
||||||
* policy as applied to native processes and system apps. */
|
* policy as applied to native processes and system apps. */
|
||||||
|
|||||||
@@ -2405,6 +2405,15 @@ static jint com_android_internal_os_Zygote_nativeParseSigChld(JNIEnv* env, jclas
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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[] = {
|
static const JNINativeMethod gMethods[] = {
|
||||||
{"nativeForkAndSpecialize",
|
{"nativeForkAndSpecialize",
|
||||||
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/"
|
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/"
|
||||||
@@ -2440,6 +2449,8 @@ static const JNINativeMethod gMethods[] = {
|
|||||||
(void*)com_android_internal_os_Zygote_nativeBoostUsapPriority},
|
(void*)com_android_internal_os_Zygote_nativeBoostUsapPriority},
|
||||||
{"nativeParseSigChld", "([BI[I)I",
|
{"nativeParseSigChld", "([BI[I)I",
|
||||||
(void*)com_android_internal_os_Zygote_nativeParseSigChld},
|
(void*)com_android_internal_os_Zygote_nativeParseSigChld},
|
||||||
|
{"nativeSupportsTaggedPointers", "()Z",
|
||||||
|
(void*)com_android_internal_os_Zygote_nativeSupportsTaggedPointers},
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_com_android_internal_os_Zygote(JNIEnv* env) {
|
int register_com_android_internal_os_Zygote(JNIEnv* env) {
|
||||||
|
|||||||
@@ -1846,11 +1846,13 @@ public final class ProcessList {
|
|||||||
runtimeFlags |= Zygote.USE_APP_IMAGE_STARTUP_CACHE;
|
runtimeFlags |= Zygote.USE_APP_IMAGE_STARTUP_CACHE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable heap pointer tagging, unless disabled by the app manifest, target sdk level,
|
if (Zygote.nativeSupportsTaggedPointers()) {
|
||||||
// or the compat feature.
|
// Enable heap pointer tagging if supported by the kernel, unless disabled by the
|
||||||
if (app.info.allowsNativeHeapPointerTagging()
|
// app manifest, target sdk level, or compat feature.
|
||||||
&& mPlatformCompat.isChangeEnabled(NATIVE_HEAP_POINTER_TAGGING, app.info)) {
|
if (app.info.allowsNativeHeapPointerTagging()
|
||||||
runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
|
&& mPlatformCompat.isChangeEnabled(NATIVE_HEAP_POINTER_TAGGING, app.info)) {
|
||||||
|
runtimeFlags |= Zygote.MEMORY_TAG_LEVEL_TBI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeFlags |= decideGwpAsanLevel(app);
|
runtimeFlags |= decideGwpAsanLevel(app);
|
||||||
|
|||||||
Reference in New Issue
Block a user