diff options
| author | 2021-01-13 17:22:51 -0800 | |
|---|---|---|
| committer | 2021-01-20 11:38:54 -0800 | |
| commit | 06ea0ef4e90df180222a8362fe42e929c60a9c20 (patch) | |
| tree | 76b8258e9f41f4979496ba4440e15233adc34fe6 | |
| parent | 1621ada2590c62e45f4bea3f9dff2a56b20a290d (diff) | |
[MTE] Add SYNC compat feature & disable for system apps.
Adds the synchronous compat feature for MTE. It takes precedence over
the ASYNC feature if both are specified.
Also disable MTE by default for system apps. MTE is entirely opt-in, not
opt-out.
Bug: 135772972
Bug: 177438394
Test: Boot FVP.
Change-Id: Id4c356912163b646abef82b9cce74e9cdbcf1d3d
| -rw-r--r-- | services/core/java/com/android/server/am/ProcessList.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 88b0c3be5464..b6e632d42d8e 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -110,7 +110,6 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.ProcessMap; import com.android.internal.app.procstats.ProcessStats; -import com.android.internal.os.RuntimeInit; import com.android.internal.os.Zygote; import com.android.internal.util.ArrayUtils; import com.android.internal.util.FrameworkStatsLog; @@ -349,12 +348,23 @@ public final class ProcessList { private static final long NATIVE_HEAP_POINTER_TAGGING = 135754954; // This is a bug id. /** - * Enable memory tag checks in non-system apps. This flag will only have an effect on - * hardware supporting the ARM Memory Tagging Extension (MTE). + * Enable asynchronous (ASYNC) memory tag checking in this process. This + * flag will only have an effect on hardware supporting the ARM Memory + * Tagging Extension (MTE). */ @ChangeId @Disabled - private static final long NATIVE_MEMORY_TAGGING = 135772972; // This is a bug id. + private static final long NATIVE_MEMTAG_ASYNC = 135772972; // This is a bug id. + + /** + * Enable synchronous (SYNC) memory tag checking in this process. This flag + * will only have an effect on hardware supporting the ARM Memory Tagging + * Extension (MTE). If both NATIVE_MEMTAG_ASYNC and this option is selected, + * this option takes preference and MTE is enabled in SYNC mode. + */ + @ChangeId + @Disabled + private static final long NATIVE_MEMTAG_SYNC = 177438394; // This is a bug id. /** * Enable sampled memory bug detection in the app. @@ -1677,23 +1687,23 @@ public final class ProcessList { return gidArray; } - private boolean shouldEnableMemoryTagging(ProcessRecord app) { + // Returns the memory tagging level to be enabled. If memory tagging isn't + // requested, returns zero. + private int getMemtagLevel(ProcessRecord app) { // Ensure the hardware + kernel actually supports MTE. if (!Zygote.nativeSupportsMemoryTagging()) { - return false; + return 0; } - // Enable MTE for system apps if supported. - if ((app.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { - return true; + if (mPlatformCompat.isChangeEnabled(NATIVE_MEMTAG_SYNC, app.info)) { + return Zygote.MEMORY_TAG_LEVEL_SYNC; } - // Enable MTE if the compat feature is enabled. - if (mPlatformCompat.isChangeEnabled(NATIVE_MEMORY_TAGGING, app.info)) { - return true; + if (mPlatformCompat.isChangeEnabled(NATIVE_MEMTAG_ASYNC, app.info)) { + return Zygote.MEMORY_TAG_LEVEL_ASYNC; } - return false; + return 0; } private boolean shouldEnableTaggedPointers(ProcessRecord app) { @@ -1717,8 +1727,9 @@ public final class ProcessList { private int decideTaggingLevel(ProcessRecord app) { // Check MTE support first, as it should take precedence over TBI. - if (shouldEnableMemoryTagging(app)) { - return Zygote.MEMORY_TAG_LEVEL_ASYNC; + int memtagLevel = getMemtagLevel(app); + if (memtagLevel != 0) { + return memtagLevel; } if (shouldEnableTaggedPointers(app)) { |