v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
memory-tagging.cc
Go to the documentation of this file.
1// Copyright 2023 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include "src/base/cpu.h"
8#include "src/base/logging.h"
9#include "v8config.h"
10
11#define SUPPORTS_MTE V8_OS_LINUX&& V8_HOST_ARCH_ARM64
12
13namespace heap::base {
14
16#if SUPPORTS_MTE
17 v8::base::CPU cpu;
18 if (V8_UNLIKELY(cpu.has_mte())) {
19 uint64_t val;
20 // Do a test to see if anything else has interfered with TCO.
21 // We expect TCO to be unset here.
22 asm volatile(".arch_extension memtag \n mrs %0, tco" : "=r"(val));
23 CHECK_EQ(val, 0);
24
25 // Suspend tag checks via PSTATE.TCO.
26 asm volatile(".arch_extension memtag \n msr tco, #1" ::: "memory");
27 }
28#endif
29}
30
32#if SUPPORTS_MTE
33 v8::base::CPU cpu;
34 if (V8_UNLIKELY(cpu.has_mte())) {
35 uint64_t val;
36 // Do a test to see if anything else has interfered with TCO.
37 // We expect TCO to be set here.
38 asm volatile(".arch_extension memtag \n mrs %0, tco" : "=r"(val));
39 CHECK_EQ(val, 1u << 25);
40
41 asm volatile(".arch_extension memtag \n msr tco, #0" ::: "memory");
42 }
43#endif
44}
45
46} // namespace heap::base
#define CHECK_EQ(lhs, rhs)
#define V8_UNLIKELY(condition)
Definition v8config.h:660