Skip to content

Commit ec4c7fb

Browse files
author
Colin Robertson
authored
Speculative changes
Updated to be more informative, based on draft blog post.
1 parent 27ba3a7 commit ec4c7fb

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

docs/build/reference/qspectre-load.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/Qspectre-load"
33
description: "Describes the Microsoft C/C++ compiler (MSVC) /Qspectre-load option."
4-
ms.date: "01/08/2020"
4+
ms.date: "01/28/2020"
55
helpviewer_keywords: ["/Qspectre-load"]
66
---
77
# /Qspectre-load
@@ -14,12 +14,21 @@ Specifies compiler generation of serializing instructions for every load instruc
1414
1515
## Remarks
1616

17-
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.
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+
```
1825

19-
**/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 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.
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 do not require protection, you can disable these mitigations by using `__declspec(spectre(nomitigation))`. For more information, see [__declspec spectre](../../cpp/spectre.md).
2027

2128
The **/Qspectre-load** option is off by default, and supports all optimization levels.
2229

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+
2332
### To set this compiler option in the Visual Studio development environment
2433

2534
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).
@@ -34,6 +43,6 @@ The **/Qspectre-load** option is off by default, and supports all optimization l
3443

3544
## See also
3645

37-
[/Q Options (Low-Level Operations)](q-options-low-level-operations.md)\
38-
[MSVC Compiler Options](compiler-options.md)\
39-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
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)

0 commit comments

Comments
 (0)