]> granicus.if.org Git - clang/commit
[mips] Spectre variant two mitigation for MIPSR2
authorSimon Dardis <simon.dardis@mips.com>
Wed, 21 Feb 2018 00:05:05 +0000 (00:05 +0000)
committerSimon Dardis <simon.dardis@mips.com>
Wed, 21 Feb 2018 00:05:05 +0000 (00:05 +0000)
commit5242ad1776dc939d2dd2f9d59d575374807d4d1e
tree647ab54cca4f13cf0c9b669002085bb6a5f51f57
parent799049fee5238acec7f3d737ea968ede1978cfe6
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325651 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticDriverKinds.td
include/clang/Driver/Options.td
lib/Basic/Targets/Mips.h
lib/Driver/ToolChains/Arch/Mips.cpp
lib/Driver/ToolChains/Arch/Mips.h
test/Driver/mips-features.c
test/Driver/mips-indirect-branch.c [new file with mode: 0644]