Skip to content

Commit 0f4ee90

Browse files
authored
Merge pull request #2664 from MicrosoftDocs/master
2/5/2020 AM Publish
2 parents ba4180a + 1e37c36 commit 0f4ee90

7 files changed

+110
-1
lines changed

docs/build/reference/command-line-property-pages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Command Line Property Pages"
33
ms.date: "11/04/2016"
4-
f1_keywords: ["vc.project.AdditionalOptionsPage"]
4+
f1_keywords: ["vc.project.AdditionalOptionsPage", "vc.project.CommandLinePage"]
55
helpviewer_keywords: ["Command Line property pages"]
66
ms.assetid: e1721b6c-8b39-4b44-a41e-69b5bb470cc9
77
---

docs/build/reference/compiler-options-listed-alphabetically.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ The following is a comprehensive alphabetical list of compiler options. For a ca
106106
|[/Qpar (Auto-Parallelizer)](qpar-auto-parallelizer.md)|Enables automatic parallelization of loops that are marked with the [#pragma loop()](../../preprocessor/loop.md) directive.|
107107
|[/Qsafe_fp_loads](qsafe-fp-loads.md)|Uses integer move instructions for floating-point values and disables certain floating point load optimizations.|
108108
|[/Qspectre](qspectre.md)|Specifies compiler generation of instructions to mitigate certain Spectre variant 1 security vulnerabilities.|
109+
|[/Qspectre-load](qspectre-load.md)|Specifies compiler generation of serializing instructions to mitigate Spectre security vulnerabilities based on load instructions.|
110+
|[/Qspectre-load-cf](qspectre-load-cf.md)|Specifies compiler generation of serializing instructions to mitigate Spectre security vulnerabilities based on control flow instructions which load memory.|
109111
|[/Qvec-report (Auto-Vectorizer Reporting Level)](qvec-report-auto-vectorizer-reporting-level.md)|Enables reporting levels for automatic vectorization.|
110112
|[/RTC](rtc-run-time-error-checks.md)|Enables run-time error checking.|
111113
|[/sdl](sdl-enable-additional-security-checks.md)|Enables additional security features and warnings.|

docs/build/reference/compiler-options-listed-by-category.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ This article contains a categorical list of compiler options. For an alphabetica
6262
|[/Qpar-report](qpar-report-auto-parallelizer-reporting-level.md)|Enables reporting levels for automatic parallelization.|
6363
|[/Qsafe_fp_loads](qsafe-fp-loads.md)|Uses integer move instructions for floating-point values and disables certain floating point load optimizations.|
6464
|[/Qspectre](qspectre.md)|Enable mitigations for CVE 2017-5753, for a class of Spectre attacks.|
65+
|[/Qspectre-load](qspectre-load.md)|Generate serializing instructions for every load instruction.|
66+
|[/Qspectre-load-cf](qspectre-load-cf.md)|Generate serializing instructions for every control flow instruction which loads memory.|
6567
|[/Qvec-report](qvec-report-auto-vectorizer-reporting-level.md)|Enables reporting levels for automatic vectorization.|
6668
|[/RTC](rtc-run-time-error-checks.md)|Enables run-time error checking.|
6769
|[/volatile](volatile-volatile-keyword-interpretation.md)|Selects how the volatile keyword is interpreted.|

docs/build/reference/q-options-low-level-operations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ You can use the **/Q** compiler options to perform the following low-level compi
2424

2525
- [/Qspectre](qspectre.md): Generates instructions to mitigate certain Spectre security vulnerabilities.
2626

27+
- [/Qspectre-load](qspectre-load.md): Generates instructions to mitigate Spectre security vulnerabilities based on loads.
28+
29+
- [/Qspectre-load-cf](qspectre-load-cf.md): Generates instructions to mitigate Spectre security vulnerabilities based on control flow instructions which load.
30+
2731
- [/Qvec-report (Auto-Vectorizer Reporting Level)](qvec-report-auto-vectorizer-reporting-level.md): Enables reporting levels for automatic vectorization.
2832

2933
## See also
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "/Qspectre-load-cf"
3+
description: "Describes the Microsoft C/C++ compiler (MSVC) /Qspectre-load-cf option."
4+
ms.date: "01/28/2020"
5+
helpviewer_keywords: ["/Qspectre-load-cf"]
6+
no-loc: [Qspectre-load-cf]
7+
---
8+
# /Qspectre-load-cf
9+
10+
Specifies compiler generation of serializing instructions for every control-flow instruction that contains a load. This option performs a subset of the mitigations done by the [/Qspectre-load](qspectre-load.md) option.
11+
12+
## Syntax
13+
14+
> **/Qspectre-load-cf**
15+
16+
## Remarks
17+
18+
**/Qspectre-load-cf** causes the compiler to detect `JMP`, `RET`, and `CALL` control-flow instructions that load from memory, and to insert serializing instructions after the load. Where possible, these instructions are split into a load and a control flow transfer. The load is followed by an `LFENCE` to ensure the load is protected. There are cases where the compiler can't split instructions, such as the `JMP` instruction, so it uses an alternate mitigation technique. For example, the compiler mitigates `jmp [rax]` by adding instructions to load the target non-destructively before inserting an LFENCE, as shown here:
19+
20+
```asm
21+
xor rbx, [rax]
22+
xor rbx, [rax] ; force a load of [rax]
23+
lfence ; followed by an LFENCE
24+
jmp [rax]
25+
```
26+
27+
Because **/Qspectre-load-cf** stops speculation of all loads in control-flow instructions, the performance impact is high. The mitigation isn't appropriate everywhere. If there are performance critical blocks of code that don't require protection, you can disable these mitigations by using `__declspec(spectre(nomitigation))`.
28+
29+
The **/Qspectre-load-cf** option is off by default, and supports all optimization levels.
30+
31+
The **/Qspectre-load-cf** option is available in Visual Studio 2019 version 16.5 and later. This option is only available in compilers that target x86 and x64 processors. It's not available in compilers that target ARM processors.
32+
33+
### To set this compiler option in the Visual Studio development environment
34+
35+
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
36+
37+
2. Select the **Configuration Properties** > **C/C++** > **Code Generation** property page.
38+
39+
3. Select a new value for the **Spectre Mitigation** property. Choose **OK** to apply the change.
40+
41+
### To set this compiler option programmatically
42+
43+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
44+
45+
## See also
46+
47+
[/Q options (Low-level operations)](q-options-low-level-operations.md)\
48+
[MSVC compiler options](compiler-options.md)\
49+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/build/reference/qspectre-load.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: "/Qspectre-load"
3+
description: "Describes the Microsoft C/C++ compiler (MSVC) /Qspectre-load option."
4+
ms.date: "01/28/2020"
5+
helpviewer_keywords: ["/Qspectre-load"]
6+
---
7+
# /Qspectre-load
8+
9+
Specifies compiler generation of serializing instructions for every load instruction. This option extends the **/Qspectre** flag, mitigating against any possible **speculative execution side-channel attacks** based on loads.
10+
11+
## Syntax
12+
13+
> **/Qspectre-load**
14+
15+
## Remarks
16+
17+
**/Qspectre-load** causes the compiler to detect loads from memory, and insert serializing instructions after them. Control flow instructions that load memory, including `RET` and `CALL`, are split into a load and a control flow transfer. The load is followed by an `LFENCE` to ensure the load is protected. There are cases where the compiler can't split control flow instructions, such as the `jmp` instruction, so it uses an alternate mitigation technique. For example, the compiler mitigates `jmp [rax]` by adding instructions to load the target non-destructively before inserting an LFENCE, as shown here:
18+
19+
```asm
20+
xor rbx, [rax]
21+
xor rbx, [rax] ; force a load of [rax]
22+
lfence ; followed by an LFENCE
23+
jmp [rax]
24+
```
25+
26+
Because **/Qspectre-load** stops speculation of all loads, the performance impact is high. The mitigation isn't appropriate everywhere. If there are performance critical blocks of code that don't require protection, you can disable these mitigations by using `__declspec(spectre(nomitigation))`. For more information, see [__declspec spectre](../../cpp/spectre.md).
27+
28+
The **/Qspectre-load** option is off by default, and supports all optimization levels.
29+
30+
The **/Qspectre-load** option is available in Visual Studio 2019 version 16.5 and later. This option is only available in compilers that target x86 and x64 processors. It's not available in compilers that target ARM processors.
31+
32+
### To set this compiler option in the Visual Studio development environment
33+
34+
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
35+
36+
2. Select the **Configuration Properties** > **C/C++** > **Code Generation** property page.
37+
38+
3. Select a new value for the **Spectre Mitigation** property. Choose **OK** to apply the change.
39+
40+
### To set this compiler option programmatically
41+
42+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
43+
44+
## See also
45+
46+
[/Q options (Low-Level Operations)](q-options-low-level-operations.md)\
47+
[MSVC compiler options](compiler-options.md)\
48+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,10 @@
702702
href: build/reference/qsafe-fp-loads.md
703703
- name: /Qspectre
704704
href: build/reference/qspectre.md
705+
- name: /Qspectre-load
706+
href: build/reference/qspectre-load.md
707+
- name: /Qspectre-load-cf
708+
href: build/reference/qspectre-load-cf.md
705709
- name: /Qvec-report (Auto-vectorizer reporting level)
706710
href: build/reference/qvec-report-auto-vectorizer-reporting-level.md
707711
- name: /RTC (Run-time error checks)

0 commit comments

Comments
 (0)