summaryrefslogtreecommitdiff
path: root/tests/utils.h
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2021-08-02 01:09:58 -0700
committerLinux Build Service Account <lnxbuild@localhost>2021-08-02 01:09:58 -0700
commit555d228b48c09d9372395a9f66f4788e65782d6d (patch)
treede8c191b12ad526f3d50641b42b3926aafbec985 /tests/utils.h
parentcfa63efcf51b81feb41d4c97cce98ae1c337e4b3 (diff)
parent7290ff7cfa79abad5f0a3b2d77383eea2ec90077 (diff)
Merge 7290ff7cfa79abad5f0a3b2d77383eea2ec90077 on remote branch
Change-Id: Ic055a046e8aaed75b4cad2c1f7d3704b63478bf9
Diffstat (limited to 'tests/utils.h')
-rw-r--r--tests/utils.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/utils.h b/tests/utils.h
index 145ba1ac2..592ac0e56 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -21,6 +21,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <sys/mman.h>
+#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -304,3 +305,13 @@ template <class Tp>
static inline void DoNotOptimize(Tp& value) {
asm volatile("" : "+r,m"(value) : : "memory");
}
+
+static inline bool running_with_mte() {
+#ifdef __aarch64__
+ int level = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
+ return level >= 0 && (level & PR_TAGGED_ADDR_ENABLE) &&
+ (level & PR_MTE_TCF_MASK) != PR_MTE_TCF_NONE;
+#else
+ return false;
+#endif
+}