162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciSRBDS - Special Register Buffer Data Sampling
462306a36Sopenharmony_ci=============================================
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciSRBDS is a hardware vulnerability that allows MDS
762306a36Sopenharmony_ciDocumentation/admin-guide/hw-vuln/mds.rst techniques to
862306a36Sopenharmony_ciinfer values returned from special register accesses.  Special register
962306a36Sopenharmony_ciaccesses are accesses to off core registers.  According to Intel's evaluation,
1062306a36Sopenharmony_cithe special register reads that have a security expectation of privacy are
1162306a36Sopenharmony_ciRDRAND, RDSEED and SGX EGETKEY.
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciWhen RDRAND, RDSEED and EGETKEY instructions are used, the data is moved
1462306a36Sopenharmony_cito the core through the special register mechanism that is susceptible
1562306a36Sopenharmony_cito MDS attacks.
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciAffected processors
1862306a36Sopenharmony_ci-------------------
1962306a36Sopenharmony_ciCore models (desktop, mobile, Xeon-E3) that implement RDRAND and/or RDSEED may
2062306a36Sopenharmony_cibe affected.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciA processor is affected by SRBDS if its Family_Model and stepping is
2362306a36Sopenharmony_ciin the following list, with the exception of the listed processors
2462306a36Sopenharmony_ciexporting MDS_NO while Intel TSX is available yet not enabled. The
2562306a36Sopenharmony_cilatter class of processors are only affected when Intel TSX is enabled
2662306a36Sopenharmony_ciby software using TSX_CTRL_MSR otherwise they are not affected.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci  =============  ============  ========
2962306a36Sopenharmony_ci  common name    Family_Model  Stepping
3062306a36Sopenharmony_ci  =============  ============  ========
3162306a36Sopenharmony_ci  IvyBridge      06_3AH        All
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci  Haswell        06_3CH        All
3462306a36Sopenharmony_ci  Haswell_L      06_45H        All
3562306a36Sopenharmony_ci  Haswell_G      06_46H        All
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci  Broadwell_G    06_47H        All
3862306a36Sopenharmony_ci  Broadwell      06_3DH        All
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci  Skylake_L      06_4EH        All
4162306a36Sopenharmony_ci  Skylake        06_5EH        All
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci  Kabylake_L     06_8EH        <= 0xC
4462306a36Sopenharmony_ci  Kabylake       06_9EH        <= 0xD
4562306a36Sopenharmony_ci  =============  ============  ========
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciRelated CVEs
4862306a36Sopenharmony_ci------------
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciThe following CVE entry is related to this SRBDS issue:
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci    ==============  =====  =====================================
5362306a36Sopenharmony_ci    CVE-2020-0543   SRBDS  Special Register Buffer Data Sampling
5462306a36Sopenharmony_ci    ==============  =====  =====================================
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciAttack scenarios
5762306a36Sopenharmony_ci----------------
5862306a36Sopenharmony_ciAn unprivileged user can extract values returned from RDRAND and RDSEED
5962306a36Sopenharmony_ciexecuted on another core or sibling thread using MDS techniques.
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciMitigation mechanism
6362306a36Sopenharmony_ci--------------------
6462306a36Sopenharmony_ciIntel will release microcode updates that modify the RDRAND, RDSEED, and
6562306a36Sopenharmony_ciEGETKEY instructions to overwrite secret special register data in the shared
6662306a36Sopenharmony_cistaging buffer before the secret data can be accessed by another logical
6762306a36Sopenharmony_ciprocessor.
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciDuring execution of the RDRAND, RDSEED, or EGETKEY instructions, off-core
7062306a36Sopenharmony_ciaccesses from other logical processors will be delayed until the special
7162306a36Sopenharmony_ciregister read is complete and the secret data in the shared staging buffer is
7262306a36Sopenharmony_cioverwritten.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciThis has three effects on performance:
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#. RDRAND, RDSEED, or EGETKEY instructions have higher latency.
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#. Executing RDRAND at the same time on multiple logical processors will be
7962306a36Sopenharmony_ci   serialized, resulting in an overall reduction in the maximum RDRAND
8062306a36Sopenharmony_ci   bandwidth.
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#. Executing RDRAND, RDSEED or EGETKEY will delay memory accesses from other
8362306a36Sopenharmony_ci   logical processors that miss their core caches, with an impact similar to
8462306a36Sopenharmony_ci   legacy locked cache-line-split accesses.
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ciThe microcode updates provide an opt-out mechanism (RNGDS_MITG_DIS) to disable
8762306a36Sopenharmony_cithe mitigation for RDRAND and RDSEED instructions executed outside of Intel
8862306a36Sopenharmony_ciSoftware Guard Extensions (Intel SGX) enclaves. On logical processors that
8962306a36Sopenharmony_cidisable the mitigation using this opt-out mechanism, RDRAND and RDSEED do not
9062306a36Sopenharmony_citake longer to execute and do not impact performance of sibling logical
9162306a36Sopenharmony_ciprocessors memory accesses. The opt-out mechanism does not affect Intel SGX
9262306a36Sopenharmony_cienclaves (including execution of RDRAND or RDSEED inside an enclave, as well
9362306a36Sopenharmony_cias EGETKEY execution).
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ciIA32_MCU_OPT_CTRL MSR Definition
9662306a36Sopenharmony_ci--------------------------------
9762306a36Sopenharmony_ciAlong with the mitigation for this issue, Intel added a new thread-scope
9862306a36Sopenharmony_ciIA32_MCU_OPT_CTRL MSR, (address 0x123). The presence of this MSR and
9962306a36Sopenharmony_ciRNGDS_MITG_DIS (bit 0) is enumerated by CPUID.(EAX=07H,ECX=0).EDX[SRBDS_CTRL =
10062306a36Sopenharmony_ci9]==1. This MSR is introduced through the microcode update.
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ciSetting IA32_MCU_OPT_CTRL[0] (RNGDS_MITG_DIS) to 1 for a logical processor
10362306a36Sopenharmony_cidisables the mitigation for RDRAND and RDSEED executed outside of an Intel SGX
10462306a36Sopenharmony_cienclave on that logical processor. Opting out of the mitigation for a
10562306a36Sopenharmony_ciparticular logical processor does not affect the RDRAND and RDSEED mitigations
10662306a36Sopenharmony_cifor other logical processors.
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ciNote that inside of an Intel SGX enclave, the mitigation is applied regardless
10962306a36Sopenharmony_ciof the value of RNGDS_MITG_DS.
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ciMitigation control on the kernel command line
11262306a36Sopenharmony_ci---------------------------------------------
11362306a36Sopenharmony_ciThe kernel command line allows control over the SRBDS mitigation at boot time
11462306a36Sopenharmony_ciwith the option "srbds=".  The option for this is:
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci  ============= =============================================================
11762306a36Sopenharmony_ci  off           This option disables SRBDS mitigation for RDRAND and RDSEED on
11862306a36Sopenharmony_ci                affected platforms.
11962306a36Sopenharmony_ci  ============= =============================================================
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciSRBDS System Information
12262306a36Sopenharmony_ci------------------------
12362306a36Sopenharmony_ciThe Linux kernel provides vulnerability status information through sysfs.  For
12462306a36Sopenharmony_ciSRBDS this can be accessed by the following sysfs file:
12562306a36Sopenharmony_ci/sys/devices/system/cpu/vulnerabilities/srbds
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciThe possible values contained in this file are:
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci ============================== =============================================
13062306a36Sopenharmony_ci Not affected                   Processor not vulnerable
13162306a36Sopenharmony_ci Vulnerable                     Processor vulnerable and mitigation disabled
13262306a36Sopenharmony_ci Vulnerable: No microcode       Processor vulnerable and microcode is missing
13362306a36Sopenharmony_ci                                mitigation
13462306a36Sopenharmony_ci Mitigation: Microcode          Processor is vulnerable and mitigation is in
13562306a36Sopenharmony_ci                                effect.
13662306a36Sopenharmony_ci Mitigation: TSX disabled       Processor is only vulnerable when TSX is
13762306a36Sopenharmony_ci                                enabled while this system was booted with TSX
13862306a36Sopenharmony_ci                                disabled.
13962306a36Sopenharmony_ci Unknown: Dependent on
14062306a36Sopenharmony_ci hypervisor status              Running on virtual guest processor that is
14162306a36Sopenharmony_ci                                affected but with no way to know if host
14262306a36Sopenharmony_ci                                processor is mitigated or vulnerable.
14362306a36Sopenharmony_ci ============================== =============================================
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ciSRBDS Default mitigation
14662306a36Sopenharmony_ci------------------------
14762306a36Sopenharmony_ciThis new microcode serializes processor access during execution of RDRAND,
14862306a36Sopenharmony_ciRDSEED ensures that the shared buffer is overwritten before it is released for
14962306a36Sopenharmony_cireuse.  Use the "srbds=off" kernel command line to disable the mitigation for
15062306a36Sopenharmony_ciRDRAND and RDSEED.
151