[PATCH] D44824: [Spectre] Introduce a new pass to do speculative load hardening to mitigate Spectre variant #1.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 03:52:14 PDT 2018


chandlerc created this revision.
Herald added subscribers: mgrang, hiraditya, mgorny, mcrosier, sanjoy, qcolombet, MatzeB.

Please do not discuss the high-level matters here. There will be an
llvm-dev RFC thread which is much more appropriate for that kind of
discussion, and it will contain nicely accessible versions of the
markdown documentation here.

This is a *prototype* patch. It is *not* ready for detailed review. It
has a number of pretty glaring problems currently:

1. It only supports x86-64, and only certain ABIs. Many assumptions are currently hard-coded and need to be factored out of the code here.
2. It has numerous prototypes of different techniques hidden behind flags. It isn't clear that all of them are interesting to land, but they were useful during development.
3. It has essentially no real regression or functional testing. I've been testing very manually so far and would need to produce *some* reasonable collection of tests before this could realistically land.
4. It contains fixes, extensions, or workarounds for issues encountered during development that should almost certainly be factored into separate commits.
5. The code is quite poorly organized and commented. Significant refactoring is likely called for before this is landed.
6. The documentation is currently in markdown rather than an RST file. I'm hoping we can start supporting markdown in Sphinx, but unless that lands first this would need to be converted.

There are probably more issues I've not thought of or not remembered.

However, this should serve as a basis for folks to try this out and
experiment with it. Currently, it has received a moderate amount of
testing on Haswell (and newer) CPUs with `-march=haswell` passed to any
build. In that configuration, it appears to work reasonable well and
passes the LLVM test suite and a number of internal tests for us. That
said, it is obviously not thoroughly tested yet, so be cautious with it.

Currently I'm posting this just for folks to have access to it in
prototype form. I'll update when it gets to the point of being ready for
review (and when any high level issues from the RFC thread have been
addressed).


Repository:
  rL LLVM

https://reviews.llvm.org/D44824

Files:
  llvm/docs/SpeculativeLoadHardening.md
  llvm/docs/speculative_load_hardening_microbenchmarks.png
  llvm/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/lib/CodeGen/RegisterCoalescer.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/LLVMBuild.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.h
  llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/speculative-load-hardening.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44824.139573.patch
Type: text/x-patch
Size: 139699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180323/2bd199bf/attachment.bin>


More information about the llvm-commits mailing list