This short patch set aims to bring -fsanitize=hwaddress to a usable
state on RISC-V targets supporting the pointer masking extension, under
a sufficiently up to date linux kernel to feature the RISC-V pointer
masking userspace ABI.
This contribution is structured in three parts:
* Introduces a patch to libsanitizer, that has already been accepted
upstream in LLVM, to properly negotiate the necessary pointer mask
bits according to the RISC-V userspace ABI.
* Implements the target hooks related to pointer tagging in the RISC-V
back end, to allow generating code under -fsanitize=hwaddress when
pointer masking extensions are supported by the target machine.
* Enables building libsanitizer with HWASAN support for RISC-V, now
that both libsanitizer and the compiler back end support it.
With these changes, I have had success in compiling and instrumenting
simple test cases running under kernel release 6.18 in the Spike RISC-V
ISA Simulator. I was not able to locate much in the way of existing
tests covering HWASAN in the testsuite, please advise if testsuite
coverage is desired.
I hope it's not a problem to introduce a patch to libsanitizer rather
than updating libsanitizer from upstream as a whole.
As this is my first upstream contribution to GCC there may be some rough
edges in this contribution. I look forward to any feedback.
Thanks,
Max
Maximilian Ciric (3):
libsanitizer: Update EnableTaggingAbi for RISC-V linux.
RISC-V: Enable address tagging on 64-bit targets supporting pointer
masking.
libsanitizer: RISC-V supports HWASAN.
gcc/config/riscv/riscv.cc | 38 ++++++++++++++++++++++++++++
libsanitizer/configure.tgt | 1 +
libsanitizer/hwasan/hwasan.h | 9 ++++++-
libsanitizer/hwasan/hwasan_linux.cpp | 16 ++++++++++--
4 files changed, 61 insertions(+), 3 deletions(-)
--
2.34.1