xref: /linux/Documentation/admin-guide/hw-vuln/gather_data_sampling.rst (revision a3dd14c0d079c214c4de7939dfbb8738887e67e7)
1.. SPDX-License-Identifier: GPL-2.0
2
3GDS - Gather Data Sampling
4==========================
5
6Gather Data Sampling is a hardware vulnerability which allows unprivileged
7speculative access to data which was previously stored in vector registers.
8
9Problem
10-------
11When a gather instruction performs loads from memory, different data elements
12are merged into the destination vector register. However, when a gather
13instruction that is transiently executed encounters a fault, stale data from
14architectural or internal vector registers may get transiently forwarded to the
15destination vector register instead. This will allow a malicious attacker to
16infer stale data using typical side channel techniques like cache timing
17attacks. GDS is a purely sampling-based attack.
18
19The attacker uses gather instructions to infer the stale vector register data.
20The victim does not need to do anything special other than use the vector
21registers. The victim does not need to use gather instructions to be
22vulnerable.
23
24Because the buffers are shared between Hyper-Threads cross Hyper-Thread attacks
25are possible.
26
27Attack scenarios
28----------------
29Without mitigation, GDS can infer stale data across virtually all
30permission boundaries:
31
32	Non-enclaves can infer SGX enclave data
33	Userspace can infer kernel data
34	Guests can infer data from hosts
35	Guest can infer guest from other guests
36	Users can infer data from other users
37
38Because of this, it is important to ensure that the mitigation stays enabled in
39lower-privilege contexts like guests and when running outside SGX enclaves.
40
41The hardware enforces the mitigation for SGX. Likewise, VMMs should  ensure
42that guests are not allowed to disable the GDS mitigation. If a host erred and
43allowed this, a guest could theoretically disable GDS mitigation, mount an
44attack, and re-enable it.
45
46Mitigation mechanism
47--------------------
48This issue is mitigated in microcode. The microcode defines the following new
49bits:
50
51 ================================   ===   ============================
52 IA32_ARCH_CAPABILITIES[GDS_CTRL]   R/O   Enumerates GDS vulnerability
53                                          and mitigation support.
54 IA32_ARCH_CAPABILITIES[GDS_NO]     R/O   Processor is not vulnerable.
55 IA32_MCU_OPT_CTRL[GDS_MITG_DIS]    R/W   Disables the mitigation
56                                          0 by default.
57 IA32_MCU_OPT_CTRL[GDS_MITG_LOCK]   R/W   Locks GDS_MITG_DIS=0. Writes
58                                          to GDS_MITG_DIS are ignored
59                                          Can't be cleared once set.
60 ================================   ===   ============================
61
62GDS can also be mitigated on systems that don't have updated microcode by
63disabling AVX. This can be done by setting gather_data_sampling="force" or
64"clearcpuid=avx" on the kernel command-line.
65
66If used, these options will disable AVX use by turning off XSAVE YMM support.
67However, the processor will still enumerate AVX support.  Userspace that
68does not follow proper AVX enumeration to check both AVX *and* XSAVE YMM
69support will break.
70
71Mitigation control on the kernel command line
72---------------------------------------------
73The mitigation can be disabled by setting "gather_data_sampling=off" or
74"mitigations=off" on the kernel command line. Not specifying either will default
75to the mitigation being enabled. Specifying "gather_data_sampling=force" will
76use the microcode mitigation when available or disable AVX on affected systems
77where the microcode hasn't been updated to include the mitigation.
78
79GDS System Information
80------------------------
81The kernel provides vulnerability status information through sysfs. For
82GDS this can be accessed by the following sysfs file:
83
84/sys/devices/system/cpu/vulnerabilities/gather_data_sampling
85
86The possible values contained in this file are:
87
88 ============================== =============================================
89 Not affected                   Processor not vulnerable.
90 Vulnerable                     Processor vulnerable and mitigation disabled.
91 Vulnerable: No microcode       Processor vulnerable and microcode is missing
92                                mitigation.
93 Mitigation: AVX disabled,
94 no microcode                   Processor is vulnerable and microcode is missing
95                                mitigation. AVX disabled as mitigation.
96 Mitigation: Microcode          Processor is vulnerable and mitigation is in
97                                effect.
98 Mitigation: Microcode (locked) Processor is vulnerable and mitigation is in
99                                effect and cannot be disabled.
100 Unknown: Dependent on
101 hypervisor status              Running on a virtual guest processor that is
102                                affected but with no way to know if host
103                                processor is mitigated or vulnerable.
104 ============================== =============================================
105
106GDS Default mitigation
107----------------------
108The updated microcode will enable the mitigation by default. The kernel's
109default action is to leave the mitigation enabled.
110