Xen Security Advisory 320 v1 (CVE-2020-0543) - Special Register Buffer speculative side channel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Xen Security Advisory CVE-2020-0543 / XSA-320
Special Register Buffer speculative side channel
ISSUE DESCRIPTION
=================
This issue is related to the MDS and TAA vulnerabilities. Please see
https://xenbits.xen.org/xsa/advisory-297.html (MDS) and
https://xenbits.xen.org/xsa/advisory-305.html (TAA) for details.
Certain processor operations microarchitecturally need to read data from outside the physical core (e.g. to communicate with the random number generator). In some implementations, this operation is called a Special Register Read.
In some implementations, data are staged in a single shared buffer, and a full cache line at a time is returned to the core which made the Special Register Read. On parts vulnerable to MFBDS or TAA, an attacker may be able to access stale data requested by other cores in the system.
For more details, see:
https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00320.html
IMPACT
======
An attacker, which could include a malicious untrusted user process on a trusted guest, or an untrusted guest, can sample the contents of certain off-core accesses by other cores in the system.
This can include data whose use may depend on the secrecy of the value, such as data from the Random Number Generator (e.g. RDRAND/RDSEED instructions).
VULNERABLE SYSTEMS
==================
Systems running all versions of Xen are affected.
Only x86 processors are vulnerable.
ARM processors are not believed to be vulnerable.
Only Intel based processors are affected. Processors from other manufacturers (e.g. AMD) are not believed to be vulnerable.
Please consult the Intel Security Advisory for details on the affected processors.
MITIGATION
==========
There is no mitigation available.
RESOLUTION
==========
New microcode is being released on affected parts to work around the vulnerability. It may be available via a firmware update (consult your hardware vendor), or available for OS loading (consult your dom0 OS vendor).
On Xen 4.13 and later, OS microcode can be loaded at runtime. See
https://xenbits.xen.org/docs/latest/admin-guide/microcode-loading.html#runtime-microcode-loading
for details on the xen-ucode utility.
Loading the microcode, either at boot or at runtime, suffices to mitigate the issue, as protections are active by default. The mitigations do have an impact on latency of individual RDRAND/RDSEED instructions.
The patches below are for Xen, and offer boot time information, defaults selection, and opt-out controls. They are recommended to take, but not absolutely necessary for protection.
Note that patches for released versions are generally prepared to apply to the stable branches, and may not apply cleanly to the most recent release tarball. Downstreams are encouraged to update to the tip of the stable branch before applying these patches.
xsa320/xsa320-?.patch xen-unstable xsa320/xsa320-4.13-?.patch Xen 4.13.x xsa320/xsa320-4.12-?.patch Xen 4.12.x xsa320/xsa320-4.11-?.patch Xen 4.11.x xsa320/xsa320-4.10-?.patch Xen 4.10.x xsa320/xsa320-4.9-?.patch Xen 4.9.x
$ sha256sum xsa320*/* 84e4f66492042b08e69b0894ea7feb20c17c89a696cf95f05a8826fba4f26355 xsa320/xsa320-1.patch 5a3a06c72d0281fa1191ba18e39b836d2748400d9bf6a59dd45447850530c88b xsa320/xsa320-2.patch 759259ef88c980363d44e11d9c272f6a4a15918e5e6bcdfe971b1ce7ea160cd9 xsa320/xsa320-4.9-1.patch ebac2c011841c55c3c1e99d9e8afc53e56e54268d379ec8b904f6bfe6a1a5045 xsa320/xsa320-4.9-2.patch 5c622c74358ab21cbd27484c649f26df0f08e89ec333c346415bc51e35ba26c1 xsa320/xsa320-4.10-1.patch f112e34a6a4564a043926fc255a15c7e319001bd023a97ae2947228024e1c306 xsa320/xsa320-4.10-2.patch f24b51292be0cb5de80c6eff0b26983629dd48cc39ae5a331e2e38e15a6cf712 xsa320/xsa320-4.11-1.patch 03579810eaf2e9eeb1a82de4b50ff5c4b01e60b30ccf7609c9e3378ef576d81e xsa320/xsa320-4.11-2.patch 282537ffe2fd4332c0e061ddc537bea3e135a7bbd9253ec298becb49047323cf xsa320/xsa320-4.12-1.patch e4417429297354c233e8f5c261aff4888aae602f8c68897c09b16ea1aa44b1ca xsa320/xsa320-4.12-2.patch 611f2ab1a1c67e04767188d9803b6afd7d304e81a5b4f1eb1744d3e8a68ced66 xsa320/xsa320-4.13-1.patch cd1bc0071e72e2342ff4508ea3d937988694f4c03506b3afb3184f7d81aa1c86 xsa320/xsa320-4.13-2.patch $
NOTE REGARDING LACK OF EMBARGO
==============================
Despite an attempt to organise predisclosure, the discoverers ultimately did not authorise a predisclosure.
-----BEGIN PGP SIGNATURE-----
iQFABAEBCAAqFiEEI+MiLBRfRHX6gGCng/4UyVfoK9kFAl7fufEMHHBncEB4ZW4u b3JnAAoJEIP+FMlX6CvZCNgIALz6dLCvvznL7n3HFzYgKcelmOySjoZ52hJhg6ki N4C1AaPQmo1QPprycmuJ4uQIcLUP55Nh+h19V5PnRqSX1+7Qa8TXnv2TTpVK58fC JBfWBZ3xiXYdmaQOWYlJtD1Nq3vywA0LII9TZ7JdCUxjmPxn2y5ZOv6lRG6P9CVJ U+w3py0Zt32ZwYvVCbBPP49SdQmArH2BItEbGSQR5xeKnD/8Bx2/9odN0Mrnq5RQ euJxRled3nCGw6tWZJj3uYOy+dWWfmFwPFoFvI++zhrcwWGprcgjFuSGFbsGttMD ZB9+CZIJAHvgU4wu/B4SflHDgsmJS+iCmDR6e/NUlLohej0=
=w+E7
-----END PGP SIGNATURE-----
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: CPUID/MSR definitions for Special Register Buffer Data Sampling
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.pandoc +4 -4
@@ -504,10 +504,10 @@ accounting for hardware capabilities as enumerated via CPUID. Currently accepted: -The Speculation Control hardware features `md-clear`, `ibrsb`, `stibp`, `ibpb`, -`l1d-flush` and `ssbd` are used by default if available and applicable. They can -be ignored, e.g. `no-ibrsb`, at which point Xen won't use them itself, and -won't offer them to guests. +The Speculation Control hardware features `srbds-ctrl`, `md-clear`, `ibrsb`, +`stibp`, `ibpb`, `l1d-flush` and `ssbd` are used by default if available and +applicable. They can be ignored, e.g. `no-ibrsb`, at which point Xen won't +use them itself, and won't offer them to guests. `rdrand` can be used to override the default disabling of the feature on certain AMD systems. Its negative form can of course also be used to suppress use and
tools/libxl/libxl_cpuid.c +1 -0
@@ -214,6 +214,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"avx512-4vnniw",0x00000007, 0, CPUID_REG_EDX, 2, 1}, {"avx512-4fmaps",0x00000007, 0, CPUID_REG_EDX, 3, 1}, + {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, {"serialize", 0x00000007, 0, CPUID_REG_EDX, 14, 1}, {"cet-ibt", 0x00000007, 0, CPUID_REG_EDX, 20, 1},
tools/misc/xen-cpuid.c +1 -0
@@ -160,6 +160,7 @@ static const char *const str_7d0[32] = [ 2] = "avx512_4vnniw", [ 3] = "avx512_4fmaps", [ 4] = "fsrm", + /* 8 */ [ 9] = "srbds-ctrl", [10] = "md-clear", /* 12 */ [13] = "tsx-force-abort", [14] = "serialize",
xen/arch/x86/msr.c +2 -0
@@ -167,6 +167,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)case MSR_CORE_CAPABILITIES :case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :case MSR_U_CET :case MSR_S_CET : case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE:
@@ -327,6 +328,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)case MSR_TEST_CTRL :case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :case MSR_U_CET :case MSR_S_CET : case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE:
xen/arch/x86/spec_ctrl.c +2 -1
@@ -312,12 +312,13 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", (_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "", + (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL)) ? " SRBDS_CTRL" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPS_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPS_RDCL_NO) ? " RDCL_NO" : "",
xen/include/asm-x86/msr-index.h +3 -0
@@ -66,6 +66,9 @@#define TSX_CTRL_RTM_DISABLE (_AC(1, ULL) << 0)#define TSX_CTRL_CPUID_CLEAR (_AC(1, ULL) << 1) +#define MSR_MCU_OPT_CTRL 0x00000123 +#define MCU_OPT_CTRL_RNGDS_MITG_DIS (_AC(1, ULL) << 0) +#define MSR_U_CET 0x000006a0#define MSR_S_CET 0x000006a2#define CET_SHSTK_EN (_AC(1, ULL) << 0)
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -259,6 +259,7 @@ XEN_CPUFEATURE(AMD_PPIN, 8*32+23) /* Protected Processor Inventory Number/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A AVX512 Neural Network Instructions */ XEN_CPUFEATURE(AVX512_4FMAPS, 9*32+ 3) /*A AVX512 Multiply Accumulation Single Precision */ +XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT_CTRL and RNGDS_MITG_DIS. */ XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural buffers */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT */XEN_CPUFEATURE (SERIALIZE ,9 *32 +14 )/*a SERIALIZE insn */
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: Mitigate the Special Register Buffer Data Sampling sidechannel
See patch documentation and comments.
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.pandoc +7 -1
@@ -2048,7 +2048,7 @@ By default SSBD will be mitigated at runtime (i.e `ssbd=runtime`). ### spec-ctrl (x86) > `= List of [ <bool>, xen=<bool>, {pv,hvm,msr-sc,rsb,md-clear}=<bool>, > bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,eager-fpu, -> l1d-flush,branch-harden}=<bool> ]` +> l1d-flush,branch-harden,srb-lock}=<bool> ]` Controls for speculative execution sidechannel mitigations. By default, Xen will pick the most appropriate mitigations based on compiled in support,
@@ -2125,6 +2125,12 @@ If Xen is compiled with `CONFIG_SPECULATIVE_HARDEN_BRANCH`, the speculation barriers to protect selected conditional branches. By default, Xen will enable this mitigation. +On hardware supporting SRBDS_CTRL, the `srb-lock=` option can be used to force +or prevent Xen from protect the Special Register Buffer from leaking stale +data. By default, Xen will enable this mitigation, except on parts where MDS +is fixed and TAA is fixed/mitigated (in which case, there is believed to be no +way for an attacker to obtain the stale data). + ### sync_console > `= <boolean>`
xen/arch/x86/acpi/power.c +3 -0
@@ -296,6 +296,9 @@ static int enter_state(u32 state) ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);spec_ctrl_exit_idle (ci); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl); +/* (re)initialise SYSCALL/SYSENTER state, amongst other things. */ percpu_traps_init ();
xen/arch/x86/smpboot.c +5 -3
@@ -372,12 +372,14 @@ void start_secondary(void *unused)microcode_update_one (false);/* -* If MSR_SPEC_CTRL is available, apply Xen's default setting and discard -* any firmware settings. Note: MSR_SPEC_CTRL may only become available -* after loading microcode. +* If any speculative control MSRs are available, apply Xen's default +* settings. Note: These MSRs may only become available after loading +* microcode. */ if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl);tsx_init ();/* Needs microcode. May change HLE/RTM feature bits. */
xen/arch/x86/spec_ctrl.c +40 -1
83 lines not on this page · raw message
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -54,6 +54,8 @@ extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;*/ extern paddr_t l1tf_addr_mask, l1tf_safe_maddr; +extern uint64_t default_xen_mcu_opt_ctrl; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: CPUID/MSR definitions for Special Register Buffer Data Sampling
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.markdown +4 -4
@@ -456,10 +456,10 @@ accounting for hardware capabilities as enumerated via CPUID. Currently accepted: -The Speculation Control hardware features `md-clear`, `ibrsb`, `stibp`, `ibpb`, -`l1d-flush` and `ssbd` are used by default if available and applicable. They can -be ignored, e.g. `no-ibrsb`, at which point Xen won't use them itself, and -won't offer them to guests. +The Speculation Control hardware features `srbds-ctrl`, `md-clear`, `ibrsb`, +`stibp`, `ibpb`, `l1d-flush` and `ssbd` are used by default if available and +applicable. They can be ignored, e.g. `no-ibrsb`, at which point Xen won't +use them itself, and won't offer them to guests. ### cpuid\_mask\_cpu (AMD only) > `= fam_0f_rev_c | fam_0f_rev_d | fam_0f_rev_e | fam_0f_rev_f | fam_0f_rev_g | fam_10_rev_b | fam_10_rev_c | fam_11_rev_b`
tools/libxl/libxl_cpuid.c +1 -0
@@ -158,6 +158,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"de", 0x00000001, NA, CPUID_REG_EDX, 2, 1}, {"vme", 0x00000001, NA, CPUID_REG_EDX, 1, 1}, {"fpu", 0x00000001, NA, CPUID_REG_EDX, 0, 1}, + {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, {"ibrsb", 0x00000007, 0, CPUID_REG_EDX, 26, 1}, {"stibp", 0x00000007, 0, CPUID_REG_EDX, 27, 1},
tools/misc/xen-cpuid.c +2 -1
@@ -157,8 +157,9 @@ static const char *str_7d0[32] = [ 2] = "avx512_4vnniw", [ 3] = "avx512_4fmaps", - [4 ... 9] = "REZ", + [4 ... 7] = "REZ", + [ 8] = "REZ", [ 9] = "srbds-ctrl", [10] = "md-clear", [11] = "REZ", [12] = "REZ", [13] = "tsx-force-abort",
xen/arch/x86/cpuid.c +5 -0
@@ -58,6 +58,11 @@ static int __init parse_xen_cpuid(const char *s)if ( !val )setup_clear_cpu_cap (X86_FEATURE_SSBD ); } +else if ( (val =parse_boolean ("srbds-ctrl" , s, ss)) >=0 ) + { +if ( !val ) +setup_clear_cpu_cap (X86_FEATURE_SRBDS_CTRL ); + }else rc = -EINVAL ;
xen/arch/x86/hvm/hvm.c +2 -0
@@ -3445,6 +3445,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)/* Write-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ goto gp_fault;
@@ -3671,6 +3672,7 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,/* Read-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ goto gp_fault;
xen/arch/x86/spec_ctrl.c +2 -1
@@ -348,12 +348,13 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", (_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "", + (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL)) ? " SRBDS_CTRL" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPABILITIES_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPABILITIES_RDCL_NO) ? " RDCL_NO" : "",
xen/arch/x86/traps.c +2 -0
@@ -2655,6 +2655,7 @@ static int priv_op_read_msr(unsigned int reg, uint64_t *val,/* Write-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ break ;
@@ -2880,6 +2881,7 @@ static int priv_op_write_msr(unsigned int reg, uint64_t val,/* The MSR is read-only. */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ break ;
xen/include/asm-x86/msr-index.h +3 -0
@@ -176,6 +176,9 @@#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x490#define MSR_IA32_VMX_VMFUNC 0x491 +#define MSR_MCU_OPT_CTRL 0x00000123 +#define MCU_OPT_CTRL_RNGDS_MITG_DIS (_AC(1, ULL) << 0) +/* K7/K8 MSRs. Not complete. See the architecture manual for a more complete list. */ #define MSR_K7_EVNTSEL0 0xc0010000
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -241,6 +241,7 @@ XEN_CPUFEATURE(IBPB, 8*32+12) /*A IBPB support only (no IBRS, used by/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A AVX512 Neural Network Instructions */ XEN_CPUFEATURE(AVX512_4FMAPS, 9*32+ 3) /*A AVX512 Multiply Accumulation Single Precision */ +XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT_CTRL and RNGDS_MITG_DIS. */ XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural buffers */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT */XEN_CPUFEATURE (IBRSB ,9 *32 +26 )/*A IBRS and IBPB support (used by Intel) */
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: Mitigate the Special Register Buffer Data Sampling sidechannel
See patch documentation and comments.
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.markdown +7 -1
@@ -1704,7 +1704,7 @@ false disable the quirk workaround, which is also the default. ### spec-ctrl (x86) > `= List of [ <bool>, xen=<bool>, {pv,hvm,msr-sc,rsb,md-clear}=<bool>, > bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,eager-fpu, -> l1d-flush}=<bool> ]` +> l1d-flush,srb-lock}=<bool> ]` Controls for speculative execution sidechannel mitigations. By default, Xen will pick the most appropriate mitigations based on compiled in support,
@@ -1776,6 +1776,12 @@ Irrespective of Xen's setting, the feature is virtualised for HVM guests to use. By default, Xen will enable this mitigation on hardware believed to be vulnerable to L1TF. +On hardware supporting SRBDS_CTRL, the `srb-lock=` option can be used to force +or prevent Xen from protect the Special Register Buffer from leaking stale +data. By default, Xen will enable this mitigation, except on parts where MDS +is fixed and TAA is fixed/mitigated (in which case, there is believed to be no +way for an attacker to obtain the stale data). + ### sync\_console > `= <boolean>`
xen/arch/x86/acpi/power.c +3 -0
@@ -259,6 +259,9 @@ static int enter_state(u32 state) ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);spec_ctrl_exit_idle (ci); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl); + done:spin_debug_enable ();local_irq_restore (flags);
xen/arch/x86/smpboot.c +5 -3
@@ -356,12 +356,14 @@ void start_secondary(void *unused)microcode_resume_cpu (cpu);/* -* If MSR_SPEC_CTRL is available, apply Xen's default setting and discard -* any firmware settings. Note: MSR_SPEC_CTRL may only become available -* after loading microcode. +* If any speculative control MSRs are available, apply Xen's default +* settings. Note: These MSRs may only become available after loading +* microcode. */ if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl);tsx_init ();/* Needs microcode. May change HLE/RTM feature bits. */
xen/arch/x86/spec_ctrl.c +40 -1
83 lines not on this page · raw message
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -46,6 +46,8 @@ extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;*/ extern paddr_t l1tf_addr_mask, l1tf_safe_maddr; +extern uint64_t default_xen_mcu_opt_ctrl; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: CPUID/MSR definitions for Special Register Buffer Data Sampling
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.markdown +4 -4
@@ -496,10 +496,10 @@ accounting for hardware capabilities as enumerated via CPUID. Currently accepted: -The Speculation Control hardware features `md-clear`, `ibrsb`, `stibp`, `ibpb`, -`l1d-flush` and `ssbd` are used by default if available and applicable. They can -be ignored, e.g. `no-ibrsb`, at which point Xen won't use them itself, and -won't offer them to guests. +The Speculation Control hardware features `srbds-ctrl`, `md-clear`, `ibrsb`, +`stibp`, `ibpb`, `l1d-flush` and `ssbd` are used by default if available and +applicable. They can be ignored, e.g. `no-ibrsb`, at which point Xen won't +use them itself, and won't offer them to guests. ### cpuid\_mask\_cpu (AMD only) > `= fam_0f_rev_c | fam_0f_rev_d | fam_0f_rev_e | fam_0f_rev_f | fam_0f_rev_g | fam_10_rev_b | fam_10_rev_c | fam_11_rev_b`
tools/libxl/libxl_cpuid.c +1 -0
@@ -202,6 +202,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"avx512-4vnniw",0x00000007, 0, CPUID_REG_EDX, 2, 1}, {"avx512-4fmaps",0x00000007, 0, CPUID_REG_EDX, 3, 1}, + {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, {"ibrsb", 0x00000007, 0, CPUID_REG_EDX, 26, 1}, {"stibp", 0x00000007, 0, CPUID_REG_EDX, 27, 1},
tools/misc/xen-cpuid.c +2 -1
@@ -162,8 +162,9 @@ static const char *str_7d0[32] = [ 2] = "avx512_4vnniw", [ 3] = "avx512_4fmaps", - [4 ... 9] = "REZ", + [4 ... 7] = "REZ", + [ 8] = "REZ", [ 9] = "srbds-ctrl", [10] = "md-clear", [11] = "REZ", [12] = "REZ", [13] = "tsx-force-abort",
xen/arch/x86/cpuid.c +5 -0
@@ -58,6 +58,11 @@ static int __init parse_xen_cpuid(const char *s)if ( !val )setup_clear_cpu_cap (X86_FEATURE_SSBD ); } +else if ( (val =parse_boolean ("srbds-ctrl" , s, ss)) >=0 ) + { +if ( !val ) +setup_clear_cpu_cap (X86_FEATURE_SRBDS_CTRL ); + }else rc = -EINVAL ;
xen/arch/x86/msr.c +2 -0
@@ -135,6 +135,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)/* Write-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ goto gp_fault;
@@ -194,6 +195,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)/* Read-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ goto gp_fault;
xen/arch/x86/spec_ctrl.c +2 -1
@@ -349,12 +349,13 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", (_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "", + (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL)) ? " SRBDS_CTRL" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPS_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPS_RDCL_NO) ? " RDCL_NO" : "",
xen/include/asm-x86/msr-index.h +3 -0
@@ -177,6 +177,9 @@#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x490#define MSR_IA32_VMX_VMFUNC 0x491 +#define MSR_MCU_OPT_CTRL 0x00000123 +#define MCU_OPT_CTRL_RNGDS_MITG_DIS (_AC(1, ULL) << 0) +/* K7/K8 MSRs. Not complete. See the architecture manual for a more complete list. */ #define MSR_K7_EVNTSEL0 0xc0010000
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -242,6 +242,7 @@ XEN_CPUFEATURE(IBPB, 8*32+12) /*A IBPB support only (no IBRS, used by/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A AVX512 Neural Network Instructions */ XEN_CPUFEATURE(AVX512_4FMAPS, 9*32+ 3) /*A AVX512 Multiply Accumulation Single Precision */ +XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT_CTRL and RNGDS_MITG_DIS. */ XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural buffers */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT */XEN_CPUFEATURE (IBRSB ,9 *32 +26 )/*A IBRS and IBPB support (used by Intel) */
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: Mitigate the Special Register Buffer Data Sampling sidechannel
See patch documentation and comments.
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.markdown +7 -1
@@ -1809,7 +1809,7 @@ false disable the quirk workaround, which is also the default. ### spec-ctrl (x86) > `= List of [ <bool>, xen=<bool>, {pv,hvm,msr-sc,rsb,md-clear}=<bool>, > bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,eager-fpu, -> l1d-flush}=<bool> ]` +> l1d-flush,srb-lock}=<bool> ]` Controls for speculative execution sidechannel mitigations. By default, Xen will pick the most appropriate mitigations based on compiled in support,
@@ -1881,6 +1881,12 @@ Irrespective of Xen's setting, the feature is virtualised for HVM guests to use. By default, Xen will enable this mitigation on hardware believed to be vulnerable to L1TF. +On hardware supporting SRBDS_CTRL, the `srb-lock=` option can be used to force +or prevent Xen from protect the Special Register Buffer from leaking stale +data. By default, Xen will enable this mitigation, except on parts where MDS +is fixed and TAA is fixed/mitigated (in which case, there is believed to be no +way for an attacker to obtain the stale data). + ### sync\_console > `= <boolean>`
xen/arch/x86/acpi/power.c +3 -0
@@ -259,6 +259,9 @@ static int enter_state(u32 state) ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);spec_ctrl_exit_idle (ci); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl); + done:spin_debug_enable ();local_irq_restore (flags);
xen/arch/x86/smpboot.c +5 -3
@@ -363,12 +363,14 @@ void start_secondary(void *unused)microcode_resume_cpu (cpu);/* -* If MSR_SPEC_CTRL is available, apply Xen's default setting and discard -* any firmware settings. Note: MSR_SPEC_CTRL may only become available -* after loading microcode. +* If any speculative control MSRs are available, apply Xen's default +* settings. Note: These MSRs may only become available after loading +* microcode. */ if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl);tsx_init ();/* Needs microcode. May change HLE/RTM feature bits. */
xen/arch/x86/spec_ctrl.c +40 -1
83 lines not on this page · raw message
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -46,6 +46,8 @@ extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;*/ extern paddr_t l1tf_addr_mask, l1tf_safe_maddr; +extern uint64_t default_xen_mcu_opt_ctrl; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: CPUID/MSR definitions for Special Register Buffer Data Sampling
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.markdown +4 -4
@@ -489,10 +489,10 @@ accounting for hardware capabilities as enumerated via CPUID. Currently accepted: -The Speculation Control hardware features `md-clear`, `ibrsb`, `stibp`, `ibpb`, -`l1d-flush` and `ssbd` are used by default if available and applicable. They can -be ignored, e.g. `no-ibrsb`, at which point Xen won't use them itself, and -won't offer them to guests. +The Speculation Control hardware features `srbds-ctrl`, `md-clear`, `ibrsb`, +`stibp`, `ibpb`, `l1d-flush` and `ssbd` are used by default if available and +applicable. They can be ignored, e.g. `no-ibrsb`, at which point Xen won't +use them itself, and won't offer them to guests. ### cpuid\_mask\_cpu (AMD only) > `= fam_0f_rev_c | fam_0f_rev_d | fam_0f_rev_e | fam_0f_rev_f | fam_0f_rev_g | fam_10_rev_b | fam_10_rev_c | fam_11_rev_b`
tools/libxl/libxl_cpuid.c +1 -0
@@ -202,6 +202,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"avx512-4vnniw",0x00000007, 0, CPUID_REG_EDX, 2, 1}, {"avx512-4fmaps",0x00000007, 0, CPUID_REG_EDX, 3, 1}, + {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, {"ibrsb", 0x00000007, 0, CPUID_REG_EDX, 26, 1}, {"stibp", 0x00000007, 0, CPUID_REG_EDX, 27, 1},
tools/misc/xen-cpuid.c +1 -0
@@ -142,6 +142,7 @@ static const char *str_7d0[32] = { [ 2] = "avx512_4vnniw", [ 3] = "avx512_4fmaps", + /* 8 */ [ 9] = "srbds-ctrl", [10] = "md-clear", /* 12 */ [13] = "tsx-force-abort",
xen/arch/x86/cpuid.c +5 -0
@@ -58,6 +58,11 @@ static int __init parse_xen_cpuid(const char *s)if ( !val )setup_clear_cpu_cap (X86_FEATURE_SSBD ); } +else if ( (val =parse_boolean ("srbds-ctrl" , s, ss)) >=0 ) + { +if ( !val ) +setup_clear_cpu_cap (X86_FEATURE_SRBDS_CTRL ); + }else rc = -EINVAL ;
xen/arch/x86/msr.c +2 -0
@@ -154,6 +154,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)/* Write-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ goto gp_fault;
@@ -243,6 +244,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)/* Read-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :/* Not offered to guests. */ goto gp_fault;
xen/arch/x86/spec_ctrl.c +2 -1
@@ -365,12 +365,13 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", (_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "", + (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL)) ? " SRBDS_CTRL" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPS_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPS_RDCL_NO) ? " RDCL_NO" : "",
xen/include/asm-x86/msr-index.h +3 -0
@@ -177,6 +177,9 @@#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x490#define MSR_IA32_VMX_VMFUNC 0x491 +#define MSR_MCU_OPT_CTRL 0x00000123 +#define MCU_OPT_CTRL_RNGDS_MITG_DIS (_AC(1, ULL) << 0) +/* K7/K8 MSRs. Not complete. See the architecture manual for a more complete list. */ #define MSR_K7_EVNTSEL0 0xc0010000
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -242,6 +242,7 @@ XEN_CPUFEATURE(IBPB, 8*32+12) /*A IBPB support only (no IBRS, used by/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A AVX512 Neural Network Instructions */ XEN_CPUFEATURE(AVX512_4FMAPS, 9*32+ 3) /*A AVX512 Multiply Accumulation Single Precision */ +XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT_CTRL and RNGDS_MITG_DIS. */ XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural buffers */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT */XEN_CPUFEATURE (IBRSB ,9 *32 +26 )/*A IBRS and IBPB support (used by Intel) */
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: Mitigate the Special Register Buffer Data Sampling sidechannel
See patch documentation and comments.
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.markdown +7 -1
@@ -1858,7 +1858,7 @@ false disable the quirk workaround, which is also the default. ### spec-ctrl (x86) > `= List of [ <bool>, xen=<bool>, {pv,hvm,msr-sc,rsb,md-clear}=<bool>, > bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,eager-fpu, -> l1d-flush}=<bool> ]` +> l1d-flush,srb-lock}=<bool> ]` Controls for speculative execution sidechannel mitigations. By default, Xen will pick the most appropriate mitigations based on compiled in support,
@@ -1930,6 +1930,12 @@ Irrespective of Xen's setting, the feature is virtualised for HVM guests to use. By default, Xen will enable this mitigation on hardware believed to be vulnerable to L1TF. +On hardware supporting SRBDS_CTRL, the `srb-lock=` option can be used to force +or prevent Xen from protect the Special Register Buffer from leaking stale +data. By default, Xen will enable this mitigation, except on parts where MDS +is fixed and TAA is fixed/mitigated (in which case, there is believed to be no +way for an attacker to obtain the stale data). + ### sync\_console > `= <boolean>`
xen/arch/x86/acpi/power.c +3 -0
@@ -266,6 +266,9 @@ static int enter_state(u32 state) ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);spec_ctrl_exit_idle (ci); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl); + done:spin_debug_enable ();local_irq_restore (flags);
xen/arch/x86/smpboot.c +5 -3
@@ -369,12 +369,14 @@ void start_secondary(void *unused)microcode_resume_cpu (cpu);/* -* If MSR_SPEC_CTRL is available, apply Xen's default setting and discard -* any firmware settings. Note: MSR_SPEC_CTRL may only become available -* after loading microcode. +* If any speculative control MSRs are available, apply Xen's default +* settings. Note: These MSRs may only become available after loading +* microcode. */ if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl);tsx_init ();/* Needs microcode. May change HLE/RTM feature bits. */
xen/arch/x86/spec_ctrl.c +40 -1
83 lines not on this page · raw message
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -46,6 +46,8 @@ extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;*/ extern paddr_t l1tf_addr_mask, l1tf_safe_maddr; +extern uint64_t default_xen_mcu_opt_ctrl; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: CPUID/MSR definitions for Special Register Buffer Data Sampling
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.pandoc +4 -4
@@ -483,10 +483,10 @@ accounting for hardware capabilities as enumerated via CPUID. Currently accepted: -The Speculation Control hardware features `md-clear`, `ibrsb`, `stibp`, `ibpb`, -`l1d-flush` and `ssbd` are used by default if available and applicable. They can -be ignored, e.g. `no-ibrsb`, at which point Xen won't use them itself, and -won't offer them to guests. +The Speculation Control hardware features `srbds-ctrl`, `md-clear`, `ibrsb`, +`stibp`, `ibpb`, `l1d-flush` and `ssbd` are used by default if available and +applicable. They can be ignored, e.g. `no-ibrsb`, at which point Xen won't +use them itself, and won't offer them to guests. ### cpuid_mask_cpu > `= fam_0f_rev_[cdefg] | fam_10_rev_[bc] | fam_11_rev_b`
tools/libxl/libxl_cpuid.c +1 -0
@@ -203,6 +203,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"avx512-4vnniw",0x00000007, 0, CPUID_REG_EDX, 2, 1}, {"avx512-4fmaps",0x00000007, 0, CPUID_REG_EDX, 3, 1}, + {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, {"cet-ibt", 0x00000007, 0, CPUID_REG_EDX, 20, 1}, {"ibrsb", 0x00000007, 0, CPUID_REG_EDX, 26, 1},
tools/misc/xen-cpuid.c +1 -0
@@ -154,6 +154,7 @@ static const char *str_7d0[32] = [ 2] = "avx512_4vnniw", [ 3] = "avx512_4fmaps", [ 4] = "fsrm", + /* 8 */ [ 9] = "srbds-ctrl", [10] = "md-clear", /* 12 */ [13] = "tsx-force-abort",
xen/arch/x86/cpuid.c +5 -0
@@ -59,6 +59,11 @@ static int __init parse_xen_cpuid(const char *s)if ( !val )setup_clear_cpu_cap (X86_FEATURE_SSBD ); } +else if ( (val =parse_boolean ("srbds-ctrl" , s, ss)) >=0 ) + { +if ( !val ) +setup_clear_cpu_cap (X86_FEATURE_SRBDS_CTRL ); + }else rc = -EINVAL ;
xen/arch/x86/msr.c +2 -0
@@ -133,6 +133,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)/* Write-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :case MSR_U_CET :case MSR_S_CET : case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE:
@@ -273,6 +274,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)/* Read-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :case MSR_U_CET :case MSR_S_CET : case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE:
xen/arch/x86/spec_ctrl.c +2 -1
@@ -309,12 +309,13 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", (_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "", + (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL)) ? " SRBDS_CTRL" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPS_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPS_RDCL_NO) ? " RDCL_NO" : "",
xen/include/asm-x86/msr-index.h +3 -0
@@ -179,6 +179,9 @@#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x490#define MSR_IA32_VMX_VMFUNC 0x491 +#define MSR_MCU_OPT_CTRL 0x00000123 +#define MCU_OPT_CTRL_RNGDS_MITG_DIS (_AC(1, ULL) << 0) +#define MSR_U_CET 0x000006a0#define MSR_S_CET 0x000006a2#define MSR_PL0_SSP 0x000006a4
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -243,6 +243,7 @@ XEN_CPUFEATURE(IBPB, 8*32+12) /*A IBPB support only (no IBRS, used by/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A AVX512 Neural Network Instructions */ XEN_CPUFEATURE(AVX512_4FMAPS, 9*32+ 3) /*A AVX512 Multiply Accumulation Single Precision */ +XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT_CTRL and RNGDS_MITG_DIS. */ XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural buffers */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT */XEN_CPUFEATURE (CET_IBT ,9 *32 +20 )/* CET - Indirect Branch Tracking */
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: Mitigate the Special Register Buffer Data Sampling sidechannel
See patch documentation and comments.
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.pandoc +7 -1
@@ -1909,7 +1909,7 @@ By default SSBD will be mitigated at runtime (i.e `ssbd=runtime`). ### spec-ctrl (x86) > `= List of [ <bool>, xen=<bool>, {pv,hvm,msr-sc,rsb,md-clear}=<bool>, > bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,eager-fpu, -> l1d-flush}=<bool> ]` +> l1d-flush,srb-lock}=<bool> ]` Controls for speculative execution sidechannel mitigations. By default, Xen will pick the most appropriate mitigations based on compiled in support,
@@ -1981,6 +1981,12 @@ Irrespective of Xen's setting, the feature is virtualised for HVM guests to use. By default, Xen will enable this mitigation on hardware believed to be vulnerable to L1TF. +On hardware supporting SRBDS_CTRL, the `srb-lock=` option can be used to force +or prevent Xen from protect the Special Register Buffer from leaking stale +data. By default, Xen will enable this mitigation, except on parts where MDS +is fixed and TAA is fixed/mitigated (in which case, there is believed to be no +way for an attacker to obtain the stale data). + ### sync_console > `= <boolean>`
xen/arch/x86/acpi/power.c +3 -0
@@ -266,6 +266,9 @@ static int enter_state(u32 state) ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);spec_ctrl_exit_idle (ci); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl); + done:spin_debug_enable ();local_irq_restore (flags);
xen/arch/x86/smpboot.c +5 -3
@@ -369,12 +369,14 @@ void start_secondary(void *unused)microcode_resume_cpu (cpu);/* -* If MSR_SPEC_CTRL is available, apply Xen's default setting and discard -* any firmware settings. Note: MSR_SPEC_CTRL may only become available -* after loading microcode. +* If any speculative control MSRs are available, apply Xen's default +* settings. Note: These MSRs may only become available after loading +* microcode. */ if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl);tsx_init ();/* Needs microcode. May change HLE/RTM feature bits. */
xen/arch/x86/spec_ctrl.c +40 -1
83 lines not on this page · raw message
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -53,6 +53,8 @@ extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;*/ extern paddr_t l1tf_addr_mask, l1tf_safe_maddr; +extern uint64_t default_xen_mcu_opt_ctrl; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: CPUID/MSR definitions for Special Register Buffer Data Sampling
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.pandoc +4 -4
@@ -483,10 +483,10 @@ accounting for hardware capabilities as enumerated via CPUID. Currently accepted: -The Speculation Control hardware features `md-clear`, `ibrsb`, `stibp`, `ibpb`, -`l1d-flush` and `ssbd` are used by default if available and applicable. They can -be ignored, e.g. `no-ibrsb`, at which point Xen won't use them itself, and -won't offer them to guests. +The Speculation Control hardware features `srbds-ctrl`, `md-clear`, `ibrsb`, +`stibp`, `ibpb`, `l1d-flush` and `ssbd` are used by default if available and +applicable. They can be ignored, e.g. `no-ibrsb`, at which point Xen won't +use them itself, and won't offer them to guests. ### cpuid_mask_cpu > `= fam_0f_rev_[cdefg] | fam_10_rev_[bc] | fam_11_rev_b`
tools/libxl/libxl_cpuid.c +1 -0
@@ -213,6 +213,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"avx512-4vnniw",0x00000007, 0, CPUID_REG_EDX, 2, 1}, {"avx512-4fmaps",0x00000007, 0, CPUID_REG_EDX, 3, 1}, + {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, {"cet-ibt", 0x00000007, 0, CPUID_REG_EDX, 20, 1}, {"ibrsb", 0x00000007, 0, CPUID_REG_EDX, 26, 1},
tools/misc/xen-cpuid.c +1 -0
@@ -157,6 +157,7 @@ static const char *const str_7d0[32] = [ 2] = "avx512_4vnniw", [ 3] = "avx512_4fmaps", [ 4] = "fsrm", + /* 8 */ [ 9] = "srbds-ctrl", [10] = "md-clear", /* 12 */ [13] = "tsx-force-abort",
xen/arch/x86/msr.c +2 -0
@@ -134,6 +134,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)/* Write-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :case MSR_U_CET :case MSR_S_CET : case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE:
@@ -288,6 +289,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)/* Read-only */ case MSR_TSX_FORCE_ABORT :case MSR_TSX_CTRL : +case MSR_MCU_OPT_CTRL :case MSR_U_CET :case MSR_S_CET : case MSR_PL0_SSP ... MSR_INTERRUPT_SSP_TABLE:
xen/arch/x86/spec_ctrl.c +2 -1
@@ -312,12 +312,13 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)printk ("Speculative mitigation facilities:\n" );/* Hardware features which pertain to speculative mitigations. */ - printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + printk(" Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB)) ? " IBRS/IBPB" : "", (_7d0 & cpufeat_mask(X86_FEATURE_STIBP)) ? " STIBP" : "", (_7d0 & cpufeat_mask(X86_FEATURE_L1D_FLUSH)) ? " L1D_FLUSH" : "", (_7d0 & cpufeat_mask(X86_FEATURE_SSBD)) ? " SSBD" : "", (_7d0 & cpufeat_mask(X86_FEATURE_MD_CLEAR)) ? " MD_CLEAR" : "", + (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL)) ? " SRBDS_CTRL" : "", (e8b & cpufeat_mask(X86_FEATURE_IBPB)) ? " IBPB" : "", (caps & ARCH_CAPS_IBRS_ALL) ? " IBRS_ALL" : "", (caps & ARCH_CAPS_RDCL_NO) ? " RDCL_NO" : "",
xen/include/asm-x86/msr-index.h +3 -0
@@ -179,6 +179,9 @@#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x490#define MSR_IA32_VMX_VMFUNC 0x491 +#define MSR_MCU_OPT_CTRL 0x00000123 +#define MCU_OPT_CTRL_RNGDS_MITG_DIS (_AC(1, ULL) << 0) +#define MSR_U_CET 0x000006a0#define MSR_S_CET 0x000006a2#define MSR_PL0_SSP 0x000006a4
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -252,6 +252,7 @@ XEN_CPUFEATURE(IBPB, 8*32+12) /*A IBPB support only (no IBRS, used by/* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */ XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A AVX512 Neural Network Instructions */ XEN_CPUFEATURE(AVX512_4FMAPS, 9*32+ 3) /*A AVX512 Multiply Accumulation Single Precision */ +XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT_CTRL and RNGDS_MITG_DIS. */ XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural buffers */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT */XEN_CPUFEATURE (CET_IBT ,9 *32 +20 )/* CET - Indirect Branch Tracking */
From: Andrew Cooper <[email protected]>
Subject: x86/spec-ctrl: Mitigate the Special Register Buffer Data Sampling sidechannel
See patch documentation and comments.
This is part of XSA-320 / CVE-2020-0543
docs/misc/xen-command-line.pandoc +7 -1
@@ -1991,7 +1991,7 @@ By default SSBD will be mitigated at runtime (i.e `ssbd=runtime`). ### spec-ctrl (x86) > `= List of [ <bool>, xen=<bool>, {pv,hvm,msr-sc,rsb,md-clear}=<bool>, > bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,eager-fpu, -> l1d-flush,branch-harden}=<bool> ]` +> l1d-flush,branch-harden,srb-lock}=<bool> ]` Controls for speculative execution sidechannel mitigations. By default, Xen will pick the most appropriate mitigations based on compiled in support,
@@ -2068,6 +2068,12 @@ If Xen is compiled with `CONFIG_SPECULATIVE_HARDEN_BRANCH`, the speculation barriers to protect selected conditional branches. By default, Xen will enable this mitigation. +On hardware supporting SRBDS_CTRL, the `srb-lock=` option can be used to force +or prevent Xen from protect the Special Register Buffer from leaking stale +data. By default, Xen will enable this mitigation, except on parts where MDS +is fixed and TAA is fixed/mitigated (in which case, there is believed to be no +way for an attacker to obtain the stale data). + ### sync_console > `= <boolean>`
xen/arch/x86/acpi/power.c +3 -0
@@ -295,6 +295,9 @@ static int enter_state(u32 state) ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);spec_ctrl_exit_idle (ci); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl); + done:spin_debug_enable ();local_irq_restore (flags);
xen/arch/x86/smpboot.c +5 -3
@@ -361,12 +361,14 @@ void start_secondary(void *unused)microcode_update_one (false);/* -* If MSR_SPEC_CTRL is available, apply Xen's default setting and discard -* any firmware settings. Note: MSR_SPEC_CTRL may only become available -* after loading microcode. +* If any speculative control MSRs are available, apply Xen's default +* settings. Note: These MSRs may only become available after loading +* microcode. */ if (boot_cpu_has (X86_FEATURE_IBRSB ) )wrmsrl (MSR_SPEC_CTRL , default_xen_spec_ctrl); +if (boot_cpu_has (X86_FEATURE_SRBDS_CTRL ) ) +wrmsrl (MSR_MCU_OPT_CTRL , default_xen_mcu_opt_ctrl);tsx_init ();/* Needs microcode. May change HLE/RTM feature bits. */
xen/arch/x86/spec_ctrl.c +40 -1
83 lines not on this page · raw message
xen/include/asm-x86/spec_ctrl.h +2 -0
@@ -54,6 +54,8 @@ extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;*/ extern paddr_t l1tf_addr_mask, l1tf_safe_maddr; +extern uint64_t default_xen_mcu_opt_ctrl; +static inline void init_shadow_spec_ctrl_state (void ) {struct cpu_info *info =get_cpu_info ();