aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-02-27 06:48:14 -0500
committerThomas Gleixner <tglx@linutronix.de>2019-03-06 15:52:13 -0500
commit650b68a0622f933444a6d66936abb3103029413b (patch)
tree04546d2bf324a808655a05e15cad21aacf779391
parent04dcbdb8057827b043b3c71aa397c4c63e67d086 (diff)
x86/kvm/vmx: Add MDS protection when L1D Flush is not active
CPUs which are affected by L1TF and MDS mitigate MDS with the L1D Flush on VMENTER when updated microcode is installed. If a CPU is not affected by L1TF or if the L1D Flush is not in use, then MDS mitigation needs to be invoked explicitly. For these cases, follow the host mitigation state and invoke the MDS mitigation before VMENTER. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Borislav Petkov <bp@suse.de> Reviewed-by: Jon Masters <jcm@redhat.com> Tested-by: Jon Masters <jcm@redhat.com>
-rw-r--r--arch/x86/kernel/cpu/bugs.c1
-rw-r--r--arch/x86/kvm/vmx/vmx.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index dbb45014de1b..29ed8e8dfee2 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -65,6 +65,7 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
65 65
66/* Control MDS CPU buffer clear before returning to user space */ 66/* Control MDS CPU buffer clear before returning to user space */
67DEFINE_STATIC_KEY_FALSE(mds_user_clear); 67DEFINE_STATIC_KEY_FALSE(mds_user_clear);
68EXPORT_SYMBOL_GPL(mds_user_clear);
68 69
69void __init check_bugs(void) 70void __init check_bugs(void)
70{ 71{
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 30a6bcd735ec..544bd24a9c1e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6369,8 +6369,11 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
6369 evmcs_rsp = static_branch_unlikely(&enable_evmcs) ? 6369 evmcs_rsp = static_branch_unlikely(&enable_evmcs) ?
6370 (unsigned long)&current_evmcs->host_rsp : 0; 6370 (unsigned long)&current_evmcs->host_rsp : 0;
6371 6371
6372 /* L1D Flush includes CPU buffer clear to mitigate MDS */
6372 if (static_branch_unlikely(&vmx_l1d_should_flush)) 6373 if (static_branch_unlikely(&vmx_l1d_should_flush))
6373 vmx_l1d_flush(vcpu); 6374 vmx_l1d_flush(vcpu);
6375 else if (static_branch_unlikely(&mds_user_clear))
6376 mds_clear_cpu_buffers();
6374 6377
6375 asm( 6378 asm(
6376 /* Store host registers */ 6379 /* Store host registers */