From: Thomas Gleixner Date: Thu, 28 Mar 2019 17:57:19 +0000 (-0400) Subject: x86/kvm/vmx: Add MDS protection when L1D Flush is not active X-Git-Tag: v4.1.12-124.31.3~191 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=65330260d1ef142cc110c802896fae0a3c7c5aa7;p=users%2Fjedix%2Flinux-maple.git x86/kvm/vmx: Add MDS protection when L1D Flush is not active commit 650b68a0622f933444a6d66936abb3103029413b upstream 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 Reviewed-by: Greg Kroah-Hartman Reviewed-by: Frederic Weisbecker Reviewed-by: Borislav Petkov Reviewed-by: Jon Masters Tested-by: Jon Masters (cherry picked from commit f0da457fb20b9f321adb8acce0c287eff6f850d1) Orabug: 29526900 CVE: CVE-2018-12126 CVE: CVE-2018-12130 CVE: CVE-2018-12127 Signed-off-by: Kanth Ghatraju Reviewed-by: Mihai Carabas Reviewed-by: Boris Ostrovsky Conflicts: Changes from bugs.c imported to bugs_64.c --- diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c index 49900fa752f8..cf9bfe883a87 100644 --- a/arch/x86/kernel/cpu/bugs_64.c +++ b/arch/x86/kernel/cpu/bugs_64.c @@ -171,6 +171,7 @@ u64 x86_amd_ls_cfg_ssbd_mask; /* Control MDS CPU buffer clear before returning to user space */ DEFINE_STATIC_KEY_FALSE(mds_user_clear); +EXPORT_SYMBOL_GPL(mds_user_clear); void __init check_bugs(void) { diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 250b28fcb9ba..c51b472c6147 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8558,6 +8558,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) if (unlikely(static_key_enabled(&vmx_l1d_should_flush))) vmx_l1d_flush(vcpu); + else if (static_branch_unlikely(&mds_user_clear)) + mds_clear_cpu_buffers(); asm( /* Store host registers */