This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Enabled MTE before the first allocator
ClosedPublic

Authored by vitalybuka on Jun 4 2021, 4:45 PM.

Diff Detail

Event Timeline

vitalybuka created this revision.Jun 4 2021, 4:45 PM
vitalybuka requested review of this revision.Jun 4 2021, 4:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2021, 4:45 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka updated this revision to Diff 350009.Jun 4 2021, 7:52 PM

MemoryTaggingConfig

pcc added inline comments.Jun 21 2021, 1:15 PM
compiler-rt/lib/scudo/standalone/allocator_config.h
92

So the only difference with DefaultConfig is that this is true? Maybe we should just turn it on in DefaultConfig.

compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp
37

This is presumably because some ctor linked to ScudoCUnitTest or ScudoCxxUnitTest is calling the allocator, correct? This needs a comment.

vitalybuka marked 2 inline comments as done.

comments and use DefaultConfig

pcc accepted this revision.Jun 23 2021, 5:12 PM

LGTM

compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp
37

"The wrapper tests initialize the global allocator early, before main(). We need to have Memory Tagging enabled before that happens or the allocator will disable the feature entirely."

This revision is now accepted and ready to land.Jun 23 2021, 5:12 PM
This revision was landed with ongoing or failed builds.Jun 23 2021, 11:01 PM
This revision was automatically updated to reflect the committed changes.
crownyanguan added a subscriber: crownyanguan.EditedJul 5 2021, 7:10 PM

Hi, when i using cross-build in x86 machine, i found an build error:
/usr/bin/aarch64-linux-gnu-g++ -D_GNU_SOURCE -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/scudo/standalone -I/llvm-project/compiler-rt/lib/scudo/standalone -Iinclude -I/llvm-project/llvm/include -I/llvm-project/compiler-rt/lib/scudo/standalone/../.. -I/llvm-project/compiler-rt/lib/scudo/standalone/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG -march=armv8-a -fno-lto -Werror=conversion -Wall -g -nostdinc++ -fvisibility=hidden -fno-exceptions -Wno-pedantic -fno-lto -O3 -DGWP_ASAN_HOOKS -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -std=c++14 -MD -MT projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone_cxx-aarch64.dir/wrappers_cpp.cpp.o -MF projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone_cxx-aarch64.dir/wrappers_cpp.cpp.o.d -o projects/compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone_cxx-aarch64.dir/wrappers_cpp.cpp.o -c /llvm-project/compiler-rt/lib/scudo/standalone/wrappers_cpp.cp

01:20:30 /tmp/cc8oDmob.s: Assembler messages:
01:20:30 /tmp/cc8oDmob.s:582: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:610: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:618: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:628: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:925: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:953: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:961: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:971: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:1829: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:1857: Error: unknown mnemonic stzg' -- stzg x1,[x1],#16'
01:20:30 /tmp/cc8oDmob.s:1865: Error: unknown or missing operation name at operand 1 -- `dc gzva,x1'
01:20:30 /tmp/cc8oDmob.s:1875: Error: unknown mnemonic stzg' -- stzg x1,[x1],#16'
01:20:30 /tmp/cc8oDmob.s:1950: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:1978: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:1986: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:1996: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:2026: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:2054: Error: unknown mnemonic stzg' -- stzg x1,[x1],#16'
01:20:30 /tmp/cc8oDmob.s:2062: Error: unknown or missing operation name at operand 1 -- `dc gzva,x1'
01:20:30 /tmp/cc8oDmob.s:2072: Error: unknown mnemonic stzg' -- stzg x1,[x1],#16'
01:20:30 /tmp/cc8oDmob.s:14161: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14161: Error: unknown mnemonic stg' -- stg x0,[x0]'
01:20:30 /tmp/cc8oDmob.s:14176: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14176: Error: unknown mnemonic irg' -- irg x22,x25,x22'
01:20:30 /tmp/cc8oDmob.s:14193: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14221: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:14229: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:14239: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:14271: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14271: Error: unknown mnemonic stg' -- stg x1,[x1]'
01:20:30 /tmp/cc8oDmob.s:14375: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14375: Error: unknown mnemonic ldg' -- ldg x8,[x8]'
01:20:30 /tmp/cc8oDmob.s:14429: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14429: Error: unknown mnemonic ldg' -- ldg x1,[x1]'
01:20:30 /tmp/cc8oDmob.s:14502: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14502: Error: unknown mnemonic stg' -- stg x1,[x1]'
01:20:30 /tmp/cc8oDmob.s:14631: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:14659: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:14667: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:14677: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:17421: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:17421: Error: unknown mnemonic irg' -- irg x0,x20,x0'
01:20:30 /tmp/cc8oDmob.s:17437: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:17465: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:17473: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:17483: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:17799: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:17827: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:17835: Error: unknown or missing operation name at operand 1 -- `dc gzva,x0'
01:20:30 /tmp/cc8oDmob.s:17845: Error: unknown mnemonic stzg' -- stzg x0,[x0],#16'
01:20:30 /tmp/cc8oDmob.s:18248: Error: unknown architectural extension `memtag'
01:20:30 /tmp/cc8oDmob.s:18276: Error: unknown mnemonic stzg' -- stzg x1,[x1],#16'
01:20:30 /tmp/cc8oDmob.s:18284: Error: unknown or missing operation name at operand 1 -- `dc gzva,x1'
01:20:30 /tmp/cc8oDmob.s:18294: Error: unknown mnemonic stzg' -- stzg x1,[x1],#16'

pcc added a comment.Jul 7 2021, 10:36 AM

This is a known issue with the use of MTE instructions in memtag.h -- they should really be conditional on whether the assembler supports them. For now, please upgrade your assembler.

This is a known issue with the use of MTE instructions in memtag.h -- they should really be conditional on whether the assembler supports them. For now, please upgrade your assembler.

How to update assembly, I build it on a x86 machine.
And, should it be better to be conditional in Makefiles to chose which instructions it produce?

This is a known issue with the use of MTE instructions in memtag.h -- they should really be conditional on whether the assembler supports them. For now, please upgrade your assembler.

How to update assembly, I build it on a x86 machine.
And, should it be better to be conditional in Makefiles to chose which instructions it produce?

Maybe memtag..h till someone volunteer to fix MTE for GCC?
#if clang_major >= 12 && (defined(aarch64) || defined(SCUDO_FUZZ))

pcc added a comment.Jul 9 2021, 11:10 AM

Yeah, that should be good enough for now. It won't cover users who have the integrated assembler disabled, but it's better than nothing.