Skip to content

Commit 4c9adbb

Browse files
committed
[scudo/standalone] Use .arch_extension memtag, not mte
GNU binutils accepts only `.arch_extension memtag` while Clang accepts either that or `.arch_extension mte` to mean the same thing. Reviewed By: pcc Differential Revision: https://reviews.llvm.org/D95996
1 parent bdf3ad5 commit 4c9adbb

File tree

1 file changed

+13
-11
lines changed
  • compiler-rt/lib/scudo/standalone

1 file changed

+13
-11
lines changed

compiler-rt/lib/scudo/standalone/memtag.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,33 @@ inline bool systemDetectsMemoryTagFaultsTestOnly() { return false; }
8888
#endif // SCUDO_LINUX
8989

9090
inline void disableMemoryTagChecksTestOnly() {
91-
__asm__ __volatile__(".arch_extension mte; msr tco, #1");
91+
__asm__ __volatile__(".arch_extension memtag; msr tco, #1");
9292
}
9393

9494
inline void enableMemoryTagChecksTestOnly() {
95-
__asm__ __volatile__(".arch_extension mte; msr tco, #0");
95+
__asm__ __volatile__(".arch_extension memtag; msr tco, #0");
9696
}
9797

9898
class ScopedDisableMemoryTagChecks {
9999
size_t PrevTCO;
100100

101101
public:
102102
ScopedDisableMemoryTagChecks() {
103-
__asm__ __volatile__(".arch_extension mte; mrs %0, tco; msr tco, #1"
103+
__asm__ __volatile__(".arch_extension memtag; mrs %0, tco; msr tco, #1"
104104
: "=r"(PrevTCO));
105105
}
106106

107107
~ScopedDisableMemoryTagChecks() {
108-
__asm__ __volatile__(".arch_extension mte; msr tco, %0" : : "r"(PrevTCO));
108+
__asm__ __volatile__(".arch_extension memtag; msr tco, %0"
109+
:
110+
: "r"(PrevTCO));
109111
}
110112
};
111113

112114
inline uptr selectRandomTag(uptr Ptr, uptr ExcludeMask) {
113115
uptr TaggedPtr;
114116
__asm__ __volatile__(
115-
".arch_extension mte; irg %[TaggedPtr], %[Ptr], %[ExcludeMask]"
117+
".arch_extension memtag; irg %[TaggedPtr], %[Ptr], %[ExcludeMask]"
116118
: [TaggedPtr] "=r"(TaggedPtr)
117119
: [Ptr] "r"(Ptr), [ExcludeMask] "r"(ExcludeMask));
118120
return TaggedPtr;
@@ -123,7 +125,7 @@ inline uptr storeTags(uptr Begin, uptr End) {
123125
if (Begin != End) {
124126
__asm__ __volatile__(
125127
R"(
126-
.arch_extension mte
128+
.arch_extension memtag
127129
128130
1:
129131
stzg %[Cur], [%[Cur]], #16
@@ -144,7 +146,7 @@ inline void *prepareTaggedChunk(void *Ptr, uptr Size, uptr ExcludeMask,
144146
// chunk holding a low alignment allocation is reused for a higher alignment
145147
// allocation, the chunk may already have a non-zero tag from the previous
146148
// allocation.
147-
__asm__ __volatile__(".arch_extension mte; stg %0, [%0, #-16]"
149+
__asm__ __volatile__(".arch_extension memtag; stg %0, [%0, #-16]"
148150
:
149151
: "r"(Ptr)
150152
: "memory");
@@ -161,7 +163,7 @@ inline void *prepareTaggedChunk(void *Ptr, uptr Size, uptr ExcludeMask,
161163
// purpose of catching linear overflows in this case.
162164
uptr UntaggedEnd = untagPointer(TaggedEnd);
163165
if (UntaggedEnd != BlockEnd)
164-
__asm__ __volatile__(".arch_extension mte; stg %0, [%0]"
166+
__asm__ __volatile__(".arch_extension memtag; stg %0, [%0]"
165167
:
166168
: "r"(UntaggedEnd)
167169
: "memory");
@@ -175,15 +177,15 @@ inline void resizeTaggedChunk(uptr OldPtr, uptr NewPtr, uptr BlockEnd) {
175177
// of the allocation to 0. See explanation in prepareTaggedChunk above.
176178
uptr RoundNewPtr = untagPointer(roundUpTo(NewPtr, 16));
177179
if (RoundNewPtr != BlockEnd)
178-
__asm__ __volatile__(".arch_extension mte; stg %0, [%0]"
180+
__asm__ __volatile__(".arch_extension memtag; stg %0, [%0]"
179181
:
180182
: "r"(RoundNewPtr)
181183
: "memory");
182184
return;
183185
}
184186

185187
__asm__ __volatile__(R"(
186-
.arch_extension mte
188+
.arch_extension memtag
187189
188190
// Set the memory tag of the region
189191
// [roundUpTo(OldPtr, 16), roundUpTo(NewPtr, 16))
@@ -208,7 +210,7 @@ inline void resizeTaggedChunk(uptr OldPtr, uptr NewPtr, uptr BlockEnd) {
208210

209211
inline uptr loadTag(uptr Ptr) {
210212
uptr TaggedPtr = Ptr;
211-
__asm__ __volatile__(".arch_extension mte; ldg %0, [%0]"
213+
__asm__ __volatile__(".arch_extension memtag; ldg %0, [%0]"
212214
: "+r"(TaggedPtr)
213215
:
214216
: "memory");

0 commit comments

Comments
 (0)