AArch64: Use SBFX instead of UBFX to extract address granule in outlined HWASan checks.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 27 Oct 2020 21:56:21 +0000 (14:56 -0700)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 30 Oct 2020 19:53:15 +0000 (12:53 -0700)
commitc9b1a2b41dca6e6734aa39833a0dab0d0a8b53d3
tree7cafebdc87122ddfbd3cf49d0886e090f813a1a6
parent3859fc653fb49f4acfb61b6f2c38736ec9bfae06
AArch64: Use SBFX instead of UBFX to extract address granule in outlined HWASan checks.

In a kernel (or in general in environments where bit 55 of the address
is set) the shadow base needs to point to the end of the shadow region,
not the beginning. Bit 55 needs to be sign extended into bits 52-63
of the shadow base offset, otherwise we end up loading from an invalid
address. We can do this by using SBFX instead of UBFX.

Using SBFX should have no effect in the userspace case where bit 55
of the address is clear so we do so unconditionally. I don't think
we need a ABI version bump for this (but one will come anyway when
we switch to x20 for the shadow base register).

Differential Revision: https://reviews.llvm.org/D90424
clang/docs/HardwareAssistedAddressSanitizerDesign.rst
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll