Remove ANDROID_EXPERIMENTAL_MTE.
Now that the feature guarded by this flag has landed in Linux 5.10
we no longer need the flag, so we can remove it.
Bug: 135772972
Change-Id: I02fa50848cbd0486c23c8a229bb8f1ab5dd5a56f
diff --git a/libc/Android.bp b/libc/Android.bp
index 9dcd180..9cfe298 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -93,9 +93,6 @@
ldflags: ["-Wl,-z,muldefs"],
product_variables: {
- experimental_mte: {
- cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
- },
malloc_zero_contents: {
cflags: ["-DSCUDO_ZERO_CONTENTS"],
},
diff --git a/libc/arch-arm64/dynamic_function_dispatch.cpp b/libc/arch-arm64/dynamic_function_dispatch.cpp
index 0fd331f..83e5ca4 100644
--- a/libc/arch-arm64/dynamic_function_dispatch.cpp
+++ b/libc/arch-arm64/dynamic_function_dispatch.cpp
@@ -26,25 +26,15 @@
* SUCH DAMAGE.
*/
-#include <platform/bionic/mte_kernel.h>
#include <private/bionic_ifuncs.h>
#include <stddef.h>
#include <sys/auxv.h>
extern "C" {
-static bool supports_mte(unsigned long hwcap2) {
-#ifdef ANDROID_EXPERIMENTAL_MTE
- return hwcap2 & HWCAP2_MTE;
-#else
- (void)hwcap2;
- return false;
-#endif
-}
-
typedef void* memchr_func(const void*, int, size_t);
DEFINE_IFUNC_FOR(memchr) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(memchr_func, __memchr_aarch64_mte);
} else {
RETURN_FUNC(memchr_func, __memchr_aarch64);
@@ -53,7 +43,7 @@
typedef int stpcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(stpcpy) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(stpcpy_func, __stpcpy_aarch64_mte);
} else {
RETURN_FUNC(stpcpy_func, __stpcpy_aarch64);
@@ -62,7 +52,7 @@
typedef char* strchr_func(const char*, int);
DEFINE_IFUNC_FOR(strchr) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strchr_func, __strchr_aarch64_mte);
} else {
RETURN_FUNC(strchr_func, __strchr_aarch64);
@@ -71,7 +61,7 @@
typedef char* strchrnul_func(const char*, int);
DEFINE_IFUNC_FOR(strchrnul) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strchrnul_func, __strchrnul_aarch64_mte);
} else {
RETURN_FUNC(strchrnul_func, __strchrnul_aarch64);
@@ -80,7 +70,7 @@
typedef int strcmp_func(const char*, const char*);
DEFINE_IFUNC_FOR(strcmp) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strcmp_func, __strcmp_aarch64_mte);
} else {
RETURN_FUNC(strcmp_func, __strcmp_aarch64);
@@ -89,7 +79,7 @@
typedef int strcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(strcpy) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strcpy_func, __strcpy_aarch64_mte);
} else {
RETURN_FUNC(strcpy_func, __strcpy_aarch64);
@@ -98,7 +88,7 @@
typedef size_t strlen_func(const char*);
DEFINE_IFUNC_FOR(strlen) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strlen_func, __strlen_aarch64_mte);
} else {
RETURN_FUNC(strlen_func, __strlen_aarch64);
@@ -107,7 +97,7 @@
typedef int strncmp_func(const char*, const char*, int);
DEFINE_IFUNC_FOR(strncmp) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strncmp_func, __strncmp_aarch64_mte);
} else {
RETURN_FUNC(strncmp_func, __strncmp_aarch64);
@@ -116,7 +106,7 @@
typedef char* strrchr_func(const char*, int);
DEFINE_IFUNC_FOR(strrchr) {
- if (supports_mte(arg->_hwcap2)) {
+ if (arg->_hwcap2 & HWCAP2_MTE) {
RETURN_FUNC(strrchr_func, __strrchr_aarch64_mte);
} else {
RETURN_FUNC(strrchr_func, __strrchr_aarch64);
diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp
index 72f8f1d..788722f 100644
--- a/libc/bionic/heap_tagging.cpp
+++ b/libc/bionic/heap_tagging.cpp
@@ -32,7 +32,6 @@
#include <bionic/pthread_internal.h>
#include <platform/bionic/malloc.h>
-#include <platform/bionic/mte_kernel.h>
extern "C" void scudo_malloc_disable_memory_tagging();
extern "C" void scudo_malloc_set_track_allocation_stacks(int);
@@ -54,7 +53,7 @@
(0xffull << CHECK_SHIFT) | (0xffull << UNTAG_SHIFT);
});
break;
-#if defined(ANDROID_EXPERIMENTAL_MTE) && defined(USE_SCUDO)
+#if defined(USE_SCUDO)
case M_HEAP_TAGGING_LEVEL_SYNC:
scudo_malloc_set_track_allocation_stacks(1);
break;
@@ -62,14 +61,13 @@
case M_HEAP_TAGGING_LEVEL_NONE:
scudo_malloc_disable_memory_tagging();
break;
-#endif // ANDROID_EXPERIMENTAL_MTE
+#endif // USE_SCUDO
default:
break;
}
#endif // aarch64
}
-#ifdef ANDROID_EXPERIMENTAL_MTE
static bool set_tcf_on_all_threads(int tcf) {
static int g_tcf;
g_tcf = tcf;
@@ -89,7 +87,6 @@
},
nullptr);
}
-#endif
pthread_mutex_t g_heap_tagging_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -118,13 +115,9 @@
// tagged and checks no longer happen.
globals->heap_pointer_tag = static_cast<uintptr_t>(0xffull << UNTAG_SHIFT);
});
- } else {
-#if defined(ANDROID_EXPERIMENTAL_MTE)
- if (!set_tcf_on_all_threads(PR_MTE_TCF_NONE)) {
- error_log("SetHeapTaggingLevel: set_tcf_on_all_threads failed");
- return false;
- }
-#endif
+ } else if (!set_tcf_on_all_threads(PR_MTE_TCF_NONE)) {
+ error_log("SetHeapTaggingLevel: set_tcf_on_all_threads failed");
+ return false;
}
#if defined(USE_SCUDO)
scudo_malloc_disable_memory_tagging();
@@ -144,16 +137,12 @@
}
if (tag_level == M_HEAP_TAGGING_LEVEL_ASYNC) {
-#if defined(ANDROID_EXPERIMENTAL_MTE)
set_tcf_on_all_threads(PR_MTE_TCF_ASYNC);
-#endif
#if defined(USE_SCUDO)
scudo_malloc_set_track_allocation_stacks(0);
#endif
} else if (tag_level == M_HEAP_TAGGING_LEVEL_SYNC) {
-#if defined(ANDROID_EXPERIMENTAL_MTE)
set_tcf_on_all_threads(PR_MTE_TCF_SYNC);
-#endif
#if defined(USE_SCUDO)
scudo_malloc_set_track_allocation_stacks(1);
#endif
diff --git a/libc/platform/bionic/mte.h b/libc/platform/bionic/mte.h
index 1e393eb..b11b1a6 100644
--- a/libc/platform/bionic/mte.h
+++ b/libc/platform/bionic/mte.h
@@ -29,10 +29,9 @@
#pragma once
#include <sys/auxv.h>
-#include <bionic/mte_kernel.h>
inline bool mte_supported() {
-#if defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+#if defined(__aarch64__)
static bool supported = getauxval(AT_HWCAP2) & HWCAP2_MTE;
#else
static bool supported = false;
diff --git a/libc/platform/bionic/mte_kernel.h b/libc/platform/bionic/mte_kernel.h
deleted file mode 100644
index d81480a..0000000
--- a/libc/platform/bionic/mte_kernel.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#pragma once
-
-// Defines constants used as part of the interface in an experimental MTE branch
-// of the Linux kernel, which may be found at:
-//
-// https://github.com/pcc/linux/tree/android-experimental-mte
-//
-// This interface should not be considered to be stable.
-
-#ifdef ANDROID_EXPERIMENTAL_MTE
-
-#define HWCAP2_MTE (1 << 18)
-#define PROT_MTE 0x20
-
-#define PR_MTE_TCF_SHIFT 1
-#define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TCF_ASYNC (2UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT)
-#define PR_MTE_TAG_SHIFT 3
-#define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT)
-
-#define SEGV_MTEAERR 8
-#define SEGV_MTESERR 9
-
-#define PTRACE_PEEKMTETAGS 33
-#define PTRACE_POKEMTETAGS 34
-
-#define NT_ARM_TAGGED_ADDR_CTRL 0x409
-
-#endif
diff --git a/tests/Android.bp b/tests/Android.bp
index 477c8fc..e7118b3 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -67,12 +67,6 @@
// Use the bootstrap version of bionic because some tests call private APIs
// that aren't exposed by the APEX bionic stubs.
bootstrap: true,
-
- product_variables: {
- experimental_mte: {
- cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
- },
- },
}
// -----------------------------------------------------------------------------
diff --git a/tests/heap_tagging_level_test.cpp b/tests/heap_tagging_level_test.cpp
index 1dbf455..4f8f036 100644
--- a/tests/heap_tagging_level_test.cpp
+++ b/tests/heap_tagging_level_test.cpp
@@ -76,14 +76,14 @@
#endif // defined(__BIONIC__)
}
-#if defined(__BIONIC__) && defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+#if defined(__BIONIC__) && defined(__aarch64__)
void ExitWithSiCode(int, siginfo_t* info, void*) {
_exit(info->si_code);
}
#endif
TEST(heap_tagging_level, sync_async_bad_accesses_die) {
-#if defined(__BIONIC__) && defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+#if defined(__BIONIC__) && defined(__aarch64__)
if (!(getauxval(AT_HWCAP2) & HWCAP2_MTE)) {
GTEST_SKIP() << "requires MTE support";
}
@@ -110,6 +110,8 @@
EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
volatile int oob ATTRIBUTE_UNUSED = p[-1];
+#else
+ GTEST_SKIP() << "bionic/arm64 only";
#endif
}
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index ddd3416..bddd9ab 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -47,7 +47,6 @@
#include "platform/bionic/malloc.h"
#include "platform/bionic/mte.h"
-#include "platform/bionic/mte_kernel.h"
#include "platform/bionic/reserved_signals.h"
#include "private/bionic_config.h"
@@ -1263,7 +1262,6 @@
GTEST_SKIP() << "This function can only be tested with MTE";
}
-#ifdef ANDROID_EXPERIMENTAL_MTE
sem_t sem;
ASSERT_EQ(0, sem_init(&sem, 0, 0));
@@ -1287,7 +1285,6 @@
ASSERT_EQ(0, pthread_join(thread, &retval));
int thread_tagged_addr_ctrl = reinterpret_cast<uintptr_t>(retval);
ASSERT_EQ(my_tagged_addr_ctrl, thread_tagged_addr_ctrl);
-#endif
#else
GTEST_SKIP() << "bionic extension";
#endif