[PATCH] D102288: [HWASan] Add -fsanitize=lam flag and enable HWASan to use it.

Matt Morehouse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 12 08:29:33 PDT 2021


morehouse added inline comments.


================
Comment at: clang/include/clang/Basic/Sanitizers.def:55-59
+// Utilize Intel LAM in sanitizers.  Currently only used in combination with
+// -fsanitize=hwaddress.  This is an experimental flag which may be removed in
+// the future.
+// TODO: Use -mlam instead, if/when it is supported by clang.
+SANITIZER("lam", LAM)
----------------
vitalybuka wrote:
> if it's experimental, why not just "-fsanitize=hwaddress -mllvm -havasan-lam=1" ?
Well, `-mllvm` indicates a flag for LLVM, but we need to change the Clang behavior to link with the LAM-enabled HWASan runtime.  It seems to me that we should use a flag directed to Clang for this.

Maybe it's possible to parse the `-mllvm` flag before the point where we need to choose a runtime (I'm not sure), but it seems simpler to do it this way.


================
Comment at: compiler-rt/test/hwasan/TestCases/Linux/vfork.c:7
-// Aliasing mode does not support stack tagging.
-// XFAIL: x86_64
 
----------------
xiangzhangllvm wrote:
> What does here XFAIL mean, do not test in x86_64 ?
It means the test will run in x86_64 and is expected to fail.

Under LAM the test actually passes, since manually tagging the upper bits in the stack pointers succeeds.  So we need to distinguish between x86 LAM mode and x86 aliasing mode, which we do with the new `pointer-tagging` feature.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102288/new/

https://reviews.llvm.org/D102288



More information about the cfe-commits mailing list