Page MenuHomePhabricator

[HWASan] Port HWASan to Linux x86-64 (LLVM)
ClosedPublic

Authored by alekseyshl on Mar 20 2018, 2:01 PM.

Details

Summary

Porting HWASan to Linux x86-64, first of the three patches, LLVM part.

The approach is similar to ARM case, trap signal is used to communicate
memory tag check failure. int3 instruction is used to generate a signal,
access parameters are stored in nop [eax + offset] instruction immediately
following the int3 one.

One notable difference is that x86-64 has to untag the pointer before use
due to the lack of feature comparable to ARM's TBI (Top Byte Ignore).

Diff Detail

Repository
rL LLVM

Event Timeline

alekseyshl created this revision.Mar 20 2018, 2:01 PM
eugenis added inline comments.Mar 21 2018, 4:37 PM
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
369 ↗(On Diff #139192)

the condition should be not-arm64, not is-x86.

389 ↗(On Diff #139192)

I'd move untagging to a separate function. It does not need to be tied to tag checking. In the future we'll probably want to untag other stuff, like pointers in external function call arguments.

test/Instrumentation/HWAddressSanitizer/X86/basic.ll
1 ↗(On Diff #139192)

That's a lot of copy-paste, and most of it is covered by aarch64 tests.
Lets only test the parts that differ: trap instruction sequence (one or two cases would be enough), and pointer untagging.

alekseyshl marked 2 inline comments as done.
  • Move pointer operand untagging into a separate function.
lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
389 ↗(On Diff #139192)

Not sure what the future API would be for this function, settled for the most efficient for the current use case.

eugenis accepted this revision.Mar 22 2018, 1:52 PM
This revision is now accepted and ready to land.Mar 22 2018, 1:52 PM
alekseyshl updated this revision to Diff 139507.EditedMar 22 2018, 2:17 PM
  • Remove shared code checks from X86 specific tests.
alekseyshl marked an inline comment as done.Mar 22 2018, 2:17 PM
This revision was automatically updated to reflect the committed changes.