This is an archive of the discontinued LLVM Phabricator instance.

AArch64: Add a tagged-globals backend feature.
ClosedPublic

Authored by pcc on Jul 26 2019, 7:13 PM.

Details

Summary

This feature instructs the backend to allow locally defined global variable
addresses to contain a pointer tag in bits 56-63 that will be ignored by
the hardware (i.e. TBI), but may be used by an instrumentation pass such
as HWASAN. It works by adding a MOVK instruction to the regular ADRP/ADD
sequence that sets bits 48-63 to the corresponding bits of the global, with
the linker bounds check disabled on the ADRP instruction to prevent the tag
from causing a link failure.

This implementation of the feature omits the MOVK when loading from or storing
to a global, which is sufficient for TBI. If the same approach is extended
to MTE, assuming that 0 is not configured as a catch-all tag, we will most
likely also need the MOVK in this case in order to avoid a tag mismatch.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Jul 26 2019, 7:13 PM
ostannard added inline comments.Jul 30 2019, 8:15 AM
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
231 ↗(On Diff #212038)

I don't really like the idea of re-using MO_NC to mean something more complex/specialised than the description in AArch64BaseInfo.h, maybe it would be better to add a new value (MO_TAGGED) to represent this?

pcc marked an inline comment as done.Jul 30 2019, 10:56 AM
pcc added inline comments.
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
231 ↗(On Diff #212038)

That would be fine with me, but we currently only have 12 bits of storage for the target flags and I didn't want to take another one unnecessarily.

pcc updated this revision to Diff 212402.Jul 30 2019, 11:56 AM
pcc marked 2 inline comments as done.

Address review comment

llvm/lib/Target/AArch64/AArch64Subtarget.cpp
231 ↗(On Diff #212038)

Done; this required fixing a silent truncation of flags above bit 8 in D65465.

This revision is now accepted and ready to land.Jul 31 2019, 2:14 AM
This revision was automatically updated to reflect the committed changes.