[compiler-rt] 2eac70c - [RISC-V][HWASAN] Enable HWASAN for RISC-V architecture
Alexey Baturo via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 06:29:31 PST 2022
Author: Alexey Baturo
Date: 2022-12-14T17:29:05+03:00
New Revision: 2eac70c1084cca6a1fa067c95ba7db2c9c00f103
URL: https://github.com/llvm/llvm-project/commit/2eac70c1084cca6a1fa067c95ba7db2c9c00f103
DIFF: https://github.com/llvm/llvm-project/commit/2eac70c1084cca6a1fa067c95ba7db2c9c00f103.diff
LOG: [RISC-V][HWASAN] Enable HWASAN for RISC-V architecture
Reviewed by: vitalybuka, kito-cheng
These changes will allow to use HWASAN with RISCV64 architecture.
The majority of existing tests are passing with a few exceptions(see below).
The tests were running on QEMU, since currently there're no hardware with support
for J-extension.
For this feature to work the system must support PR_{SET,GET}_TAGGED_ADDR_CTRL
syscall. For now this is only available for a patched Linux kernel and QEMU with
enabled experimental J-extension.
Results of running HWASAN lit tests for RISC-V:
```
Unsupported : 6
Passed : 79
Expectedly Failed: 2
```
Tests are marked as expected to fail or unsupported either because of:
- android platform not being supported
- no support for legacy hwasan v1 mode
- test config explicitly uses aarch64 option
```
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/abort-message-android.cpp
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/cfi.cpp
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/lto.c
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/print-memory-usage-android.c
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/register-dump-read.c
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/try-catch.cpp
XFAIL: HWAddressSanitizer-riscv64 :: TestCases/stack-oob.c
XFAIL: HWAddressSanitizer-riscv64 :: TestCases/exported-tagged-global.c
```
Differential Revision: https://reviews.llvm.org/D131345
Added:
Modified:
clang/lib/Driver/ToolChains/Linux.cpp
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index ec35c1e98a3c0..ceb8b0f7daaf8 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -778,8 +778,10 @@ SanitizerMask Linux::getSupportedSanitizers() const {
if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
IsPowerPC64 || IsHexagon || IsLoongArch64)
Res |= SanitizerKind::Scudo;
- if (IsX86_64 || IsAArch64) {
+ if (IsX86_64 || IsAArch64 || IsRISCV64) {
Res |= SanitizerKind::HWAddress;
+ }
+ if (IsX86_64 || IsAArch64) {
Res |= SanitizerKind::KernelHWAddress;
}
return Res;
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 5c48a72f2a07d..069ce087e79d8 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -55,7 +55,7 @@ else()
${PPC64} ${S390X} ${RISCV64} ${HEXAGON})
endif()
set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X})
-set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64})
+set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} ${PPC64}
${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
More information about the llvm-commits
mailing list