Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mips] Spectre variant two mitigation for MIPSR2
This patch provides mitigation for CVE-2017-5715, Spectre variant two, which affects the P5600 and P6600. It provides the option -mindirect-jump=hazard, which instructs the LLVM backend to replace indirect branches with their hazard barrier variants. This option is accepted when targeting MIPS revision two or later. The migitation strategy suggested by MIPS for these processors is to use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard barrier variants of the 'jalr' and 'jr' instructions respectively. These instructions impede the execution of instruction stream until architecturally defined hazards (changes to the instruction stream, privileged registers which may affect execution) are cleared. These instructions in MIPS' designs are not speculated past. These instructions are used with the option -mindirect-jump=hazard when branching indirectly and for indirect function calls. These instructions are defined by the MIPS32R2 ISA, so this mitigation method is not compatible with processors which implement an earlier revision of the MIPS ISA. Implementation note: I've opted to provide this as an -mindirect-jump={hazard,...} style option in case alternative mitigation methods are required for other implementations of the MIPS ISA in future, e.g. retpoline style solutions. Reviewers: atanasyan Differential Revision: https://reviews.llvm.org/D43487 llvm-svn: 325651
- Loading branch information
Simon Dardis
committed
Feb 21, 2018
1 parent
39bb8c5
commit 0bc2d9b
Showing
7 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// REQUIRES: mips-registered-target | ||
// -mindirect-jump=hazard -mips32 | ||
// RUN: %clang -target mips-unknown-linux-gnu -mips32 -### -c %s \ | ||
// RUN: -mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS32 | ||
// MIPS32: error: '-mindirect-jump=hazard' is unsupported with the 'mips32' architecture | ||
|
||
// -mindirect-jump=hazard -mmicromips | ||
// RUN: %clang -target mips-unknown-linux-gnu -mmicromips -### -c %s \ | ||
// RUN: -mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MICROMIPS | ||
// MICROMIPS: error: '-mindirect-jump=hazard' is unsupported with the 'micromips' architecture | ||
|
||
// -mindirect-jump=hazard -mips16 | ||
// RUN: %clang -target mips-unknown-linux-gnu -mips16 -### -c %s \ | ||
// RUN: -mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS16 | ||
// MIPS16: error: '-mindirect-jump=hazard' is unsupported with the 'mips16' architecture | ||
|
||
// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \ | ||
// RUN: -mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=RETOPLINE | ||
// RETOPLINE: error: unknown '-mindirect-jump=' option 'retopline' | ||
|
||
// RUN: %clang -target mips-unknown-linux-gnu -### -mips32 -c %s \ | ||
// RUN: -mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=MIXED | ||
// MIXED: error: unknown '-mindirect-jump=' option 'retopline' |