Since we have both aliasing mode and Intel LAM on x86_64, we need to
choose the mode at either run time or compile time. This patch
implements the plumbing to build both and choose between them at
compile time.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Would it be simple if module constructor of initialized code just sets some global or call init function to switch HWASAN into LAM so we can have the same runtime?
compiler-rt/lib/hwasan/hwasan_linux.cpp | ||
---|---|---|
125 | Do we use this way to enable INTEL_LAM ? |
I have another patch that does this. It is actually much more complicated than this. The tradeoff is that we lose most of our constexpr stuff. kAddressTagShift, kNumBits, and even heap size become non-constexpr and need to be loaded on callbacks. Significant changes to the primary also need to be made to handle non-constant heap sizes.
Considering we want to optimize in future patches with, for example, a custom calling convention, we may need to switch back to constexpr stuff in the future anyway.
compiler-rt/lib/hwasan/hwasan_linux.cpp | ||
---|---|---|
125 | prctl is what the current public LAM patch uses: https://lore.kernel.org/linux-mm/20210205151631.43511-12-kirill.shutemov@linux.intel.com/ Kirill said the API is subject to change, but he wasn't sure when we'll know what the final API is. So for now we're using what the only interface we know about and can test in QEMU. |
compiler-rt/lib/hwasan/CMakeLists.txt | ||
---|---|---|
171 | I wonder if "lam" would look better as an arch suffix: libclang_rt.hwasan-x86_64-lam (or x86_64_lam) unless it creates complications that I don't yet see. | |
compiler-rt/lib/hwasan/hwasan_linux.cpp | ||
153 | Could we put this stuff undef INTEL_LAM? I don't want this experimental calls to be done on non-LAM targets, where it is known not to work. |
compiler-rt/lib/hwasan/CMakeLists.txt | ||
---|---|---|
171 | Just spent 30 minutes trying this. It seems to be more complicated since adding _lam to ${arch} requires all the RT* object libraries to be built with a _lam suffix, including non-hwasan ones. If you still want to do this, I can keep working on it and upload a new diff, but I think it will be more complex. |
- Rebase onto D102288.
- Refactor to make LAM the default runtime.
- Use alias runtime if specified.
We started seeing test failures in our Windows builds in Fuchsia after this patch.
FAILED: compiler-rt/lib/hwasan/CMakeFiles/RTHwasanAliases.aarch64.dir/hwasan_interceptors.cpp.o C:\b\s\w\ir\x\w\staging\llvm_build\.\bin\clang++.exe --target=aarch64-unknown-linux-gnu --sysroot=C:/b/s/w/ir/x/w/cipd/linux -DHWASAN_WITH_INTERCEPTORS=1 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/b/s/w/ir/x/w/llvm-project/compiler-rt/lib/hwasan/.. --target=aarch64-unknown-linux-gnu -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -ffile-prefix-map=C:/b/s/w/ir/x/w/staging/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins=../staging/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins -ffile-prefix-map=C:/b/s/w/ir/x/w/llvm-project/= -no-canonical-prefixes -Wall -std=c++14 -Wno-unused-parameter -O2 -g -DNDEBUG -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -fPIC -ffreestanding -DHWASAN_ALIASING_MODE -UNDEBUG -MD -MT compiler-rt/lib/hwasan/CMakeFiles/RTHwasanAliases.aarch64.dir/hwasan_interceptors.cpp.o -MF compiler-rt\lib\hwasan\CMakeFiles\RTHwasanAliases.aarch64.dir\hwasan_interceptors.cpp.o.d -o compiler-rt/lib/hwasan/CMakeFiles/RTHwasanAliases.aarch64.dir/hwasan_interceptors.cpp.o -c C:/b/s/w/ir/x/w/llvm-project/compiler-rt/lib/hwasan/hwasan_interceptors.cpp In file included from C:/b/s/w/ir/x/w/llvm-project/compiler-rt/lib/hwasan/hwasan_interceptors.cpp:18: C:/b/s/w/ir/x/w/llvm-project/compiler-rt/lib/hwasan/hwasan.h:41:6: error: Aliasing mode is only supported on x86_64
The error message to the full build:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8846968772132677360/+/u/clang/build/stdout
The CMake commands:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8846968772132677360/+/u/clang/configure/execution_details
@morehouse do you have any idea?
Looks like the same issue I fixed in https://reviews.llvm.org/rGd97bab651185. Let me know if you have the issue after that commit.
Looks like the same issue I fixed in https://reviews.llvm.org/rGd97bab651185. Let me know if you have the issue after that commit.
Thanks, that resolved the build issue.
I wonder if "lam" would look better as an arch suffix:
unless it creates complications that I don't yet see.