1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunSRBDS - Special Register Buffer Data Sampling
4*4882a593Smuzhiyun=============================================
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunSRBDS is a hardware vulnerability that allows MDS :doc:`mds` techniques to
7*4882a593Smuzhiyuninfer values returned from special register accesses.  Special register
8*4882a593Smuzhiyunaccesses are accesses to off core registers.  According to Intel's evaluation,
9*4882a593Smuzhiyunthe special register reads that have a security expectation of privacy are
10*4882a593SmuzhiyunRDRAND, RDSEED and SGX EGETKEY.
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunWhen RDRAND, RDSEED and EGETKEY instructions are used, the data is moved
13*4882a593Smuzhiyunto the core through the special register mechanism that is susceptible
14*4882a593Smuzhiyunto MDS attacks.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunAffected processors
17*4882a593Smuzhiyun-------------------
18*4882a593SmuzhiyunCore models (desktop, mobile, Xeon-E3) that implement RDRAND and/or RDSEED may
19*4882a593Smuzhiyunbe affected.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunA processor is affected by SRBDS if its Family_Model and stepping is
22*4882a593Smuzhiyunin the following list, with the exception of the listed processors
23*4882a593Smuzhiyunexporting MDS_NO while Intel TSX is available yet not enabled. The
24*4882a593Smuzhiyunlatter class of processors are only affected when Intel TSX is enabled
25*4882a593Smuzhiyunby software using TSX_CTRL_MSR otherwise they are not affected.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun  =============  ============  ========
28*4882a593Smuzhiyun  common name    Family_Model  Stepping
29*4882a593Smuzhiyun  =============  ============  ========
30*4882a593Smuzhiyun  IvyBridge      06_3AH        All
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun  Haswell        06_3CH        All
33*4882a593Smuzhiyun  Haswell_L      06_45H        All
34*4882a593Smuzhiyun  Haswell_G      06_46H        All
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun  Broadwell_G    06_47H        All
37*4882a593Smuzhiyun  Broadwell      06_3DH        All
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun  Skylake_L      06_4EH        All
40*4882a593Smuzhiyun  Skylake        06_5EH        All
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun  Kabylake_L     06_8EH        <= 0xC
43*4882a593Smuzhiyun  Kabylake       06_9EH        <= 0xD
44*4882a593Smuzhiyun  =============  ============  ========
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunRelated CVEs
47*4882a593Smuzhiyun------------
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunThe following CVE entry is related to this SRBDS issue:
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun    ==============  =====  =====================================
52*4882a593Smuzhiyun    CVE-2020-0543   SRBDS  Special Register Buffer Data Sampling
53*4882a593Smuzhiyun    ==============  =====  =====================================
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunAttack scenarios
56*4882a593Smuzhiyun----------------
57*4882a593SmuzhiyunAn unprivileged user can extract values returned from RDRAND and RDSEED
58*4882a593Smuzhiyunexecuted on another core or sibling thread using MDS techniques.
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunMitigation mechanism
62*4882a593Smuzhiyun--------------------
63*4882a593SmuzhiyunIntel will release microcode updates that modify the RDRAND, RDSEED, and
64*4882a593SmuzhiyunEGETKEY instructions to overwrite secret special register data in the shared
65*4882a593Smuzhiyunstaging buffer before the secret data can be accessed by another logical
66*4882a593Smuzhiyunprocessor.
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunDuring execution of the RDRAND, RDSEED, or EGETKEY instructions, off-core
69*4882a593Smuzhiyunaccesses from other logical processors will be delayed until the special
70*4882a593Smuzhiyunregister read is complete and the secret data in the shared staging buffer is
71*4882a593Smuzhiyunoverwritten.
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunThis has three effects on performance:
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun#. RDRAND, RDSEED, or EGETKEY instructions have higher latency.
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun#. Executing RDRAND at the same time on multiple logical processors will be
78*4882a593Smuzhiyun   serialized, resulting in an overall reduction in the maximum RDRAND
79*4882a593Smuzhiyun   bandwidth.
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun#. Executing RDRAND, RDSEED or EGETKEY will delay memory accesses from other
82*4882a593Smuzhiyun   logical processors that miss their core caches, with an impact similar to
83*4882a593Smuzhiyun   legacy locked cache-line-split accesses.
84*4882a593Smuzhiyun
85*4882a593SmuzhiyunThe microcode updates provide an opt-out mechanism (RNGDS_MITG_DIS) to disable
86*4882a593Smuzhiyunthe mitigation for RDRAND and RDSEED instructions executed outside of Intel
87*4882a593SmuzhiyunSoftware Guard Extensions (Intel SGX) enclaves. On logical processors that
88*4882a593Smuzhiyundisable the mitigation using this opt-out mechanism, RDRAND and RDSEED do not
89*4882a593Smuzhiyuntake longer to execute and do not impact performance of sibling logical
90*4882a593Smuzhiyunprocessors memory accesses. The opt-out mechanism does not affect Intel SGX
91*4882a593Smuzhiyunenclaves (including execution of RDRAND or RDSEED inside an enclave, as well
92*4882a593Smuzhiyunas EGETKEY execution).
93*4882a593Smuzhiyun
94*4882a593SmuzhiyunIA32_MCU_OPT_CTRL MSR Definition
95*4882a593Smuzhiyun--------------------------------
96*4882a593SmuzhiyunAlong with the mitigation for this issue, Intel added a new thread-scope
97*4882a593SmuzhiyunIA32_MCU_OPT_CTRL MSR, (address 0x123). The presence of this MSR and
98*4882a593SmuzhiyunRNGDS_MITG_DIS (bit 0) is enumerated by CPUID.(EAX=07H,ECX=0).EDX[SRBDS_CTRL =
99*4882a593Smuzhiyun9]==1. This MSR is introduced through the microcode update.
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunSetting IA32_MCU_OPT_CTRL[0] (RNGDS_MITG_DIS) to 1 for a logical processor
102*4882a593Smuzhiyundisables the mitigation for RDRAND and RDSEED executed outside of an Intel SGX
103*4882a593Smuzhiyunenclave on that logical processor. Opting out of the mitigation for a
104*4882a593Smuzhiyunparticular logical processor does not affect the RDRAND and RDSEED mitigations
105*4882a593Smuzhiyunfor other logical processors.
106*4882a593Smuzhiyun
107*4882a593SmuzhiyunNote that inside of an Intel SGX enclave, the mitigation is applied regardless
108*4882a593Smuzhiyunof the value of RNGDS_MITG_DS.
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunMitigation control on the kernel command line
111*4882a593Smuzhiyun---------------------------------------------
112*4882a593SmuzhiyunThe kernel command line allows control over the SRBDS mitigation at boot time
113*4882a593Smuzhiyunwith the option "srbds=".  The option for this is:
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun  ============= =============================================================
116*4882a593Smuzhiyun  off           This option disables SRBDS mitigation for RDRAND and RDSEED on
117*4882a593Smuzhiyun                affected platforms.
118*4882a593Smuzhiyun  ============= =============================================================
119*4882a593Smuzhiyun
120*4882a593SmuzhiyunSRBDS System Information
121*4882a593Smuzhiyun------------------------
122*4882a593SmuzhiyunThe Linux kernel provides vulnerability status information through sysfs.  For
123*4882a593SmuzhiyunSRBDS this can be accessed by the following sysfs file:
124*4882a593Smuzhiyun/sys/devices/system/cpu/vulnerabilities/srbds
125*4882a593Smuzhiyun
126*4882a593SmuzhiyunThe possible values contained in this file are:
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun ============================== =============================================
129*4882a593Smuzhiyun Not affected                   Processor not vulnerable
130*4882a593Smuzhiyun Vulnerable                     Processor vulnerable and mitigation disabled
131*4882a593Smuzhiyun Vulnerable: No microcode       Processor vulnerable and microcode is missing
132*4882a593Smuzhiyun                                mitigation
133*4882a593Smuzhiyun Mitigation: Microcode          Processor is vulnerable and mitigation is in
134*4882a593Smuzhiyun                                effect.
135*4882a593Smuzhiyun Mitigation: TSX disabled       Processor is only vulnerable when TSX is
136*4882a593Smuzhiyun                                enabled while this system was booted with TSX
137*4882a593Smuzhiyun                                disabled.
138*4882a593Smuzhiyun Unknown: Dependent on
139*4882a593Smuzhiyun hypervisor status              Running on virtual guest processor that is
140*4882a593Smuzhiyun                                affected but with no way to know if host
141*4882a593Smuzhiyun                                processor is mitigated or vulnerable.
142*4882a593Smuzhiyun ============================== =============================================
143*4882a593Smuzhiyun
144*4882a593SmuzhiyunSRBDS Default mitigation
145*4882a593Smuzhiyun------------------------
146*4882a593SmuzhiyunThis new microcode serializes processor access during execution of RDRAND,
147*4882a593SmuzhiyunRDSEED ensures that the shared buffer is overwritten before it is released for
148*4882a593Smuzhiyunreuse.  Use the "srbds=off" kernel command line to disable the mitigation for
149*4882a593SmuzhiyunRDRAND and RDSEED.
150