You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/reference/qspectre-load.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "/Qspectre-load"
3
3
description: "Describes the Microsoft C/C++ compiler (MSVC) /Qspectre-load option."
4
-
ms.date: "01/08/2020"
4
+
ms.date: "01/28/2020"
5
5
helpviewer_keywords: ["/Qspectre-load"]
6
6
---
7
7
# /Qspectre-load
@@ -14,12 +14,21 @@ Specifies compiler generation of serializing instructions for every load instruc
14
14
15
15
## Remarks
16
16
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
+
```
18
25
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).
20
27
21
28
The **/Qspectre-load** option is off by default, and supports all optimization levels.
22
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
+
23
32
### To set this compiler option in the Visual Studio development environment
24
33
25
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).
@@ -34,6 +43,6 @@ The **/Qspectre-load** option is off by default, and supports all optimization l
0 commit comments