]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.10/x86-mmio-disable-kvm-mitigation-when-x86_feature_clear_cpu_buf-is-set.patch
5.10-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.10 / x86-mmio-disable-kvm-mitigation-when-x86_feature_clear_cpu_buf-is-set.patch
1 From stable+bounces-27549-greg=kroah.com@vger.kernel.org Tue Mar 12 23:41:17 2024
2 From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
3 Date: Tue, 12 Mar 2024 15:41:07 -0700
4 Subject: x86/mmio: Disable KVM mitigation when X86_FEATURE_CLEAR_CPU_BUF is set
5 To: stable@vger.kernel.org
6 Cc: Dave Hansen <dave.hansen@linux.intel.com>
7 Message-ID: <20240312-delay-verw-backport-5-10-y-v2-8-ad081ccd89ca@linux.intel.com>
8 Content-Disposition: inline
9
10 From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
11
12 commit e95df4ec0c0c9791941f112db699fae794b9862a upstream.
13
14 Currently MMIO Stale Data mitigation for CPUs not affected by MDS/TAA is
15 to only deploy VERW at VMentry by enabling mmio_stale_data_clear static
16 branch. No mitigation is needed for kernel->user transitions. If such
17 CPUs are also affected by RFDS, its mitigation may set
18 X86_FEATURE_CLEAR_CPU_BUF to deploy VERW at kernel->user and VMentry.
19 This could result in duplicate VERW at VMentry.
20
21 Fix this by disabling mmio_stale_data_clear static branch when
22 X86_FEATURE_CLEAR_CPU_BUF is enabled.
23
24 Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
25 Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
26 Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 ---
29 arch/x86/kernel/cpu/bugs.c | 14 ++++++++++++--
30 1 file changed, 12 insertions(+), 2 deletions(-)
31
32 --- a/arch/x86/kernel/cpu/bugs.c
33 +++ b/arch/x86/kernel/cpu/bugs.c
34 @@ -419,6 +419,13 @@ static void __init mmio_select_mitigatio
35 if (boot_cpu_has_bug(X86_BUG_MDS) || (boot_cpu_has_bug(X86_BUG_TAA) &&
36 boot_cpu_has(X86_FEATURE_RTM)))
37 setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
38 +
39 + /*
40 + * X86_FEATURE_CLEAR_CPU_BUF could be enabled by other VERW based
41 + * mitigations, disable KVM-only mitigation in that case.
42 + */
43 + if (boot_cpu_has(X86_FEATURE_CLEAR_CPU_BUF))
44 + static_branch_disable(&mmio_stale_data_clear);
45 else
46 static_branch_enable(&mmio_stale_data_clear);
47
48 @@ -495,8 +502,11 @@ static void __init md_clear_update_mitig
49 taa_mitigation = TAA_MITIGATION_VERW;
50 taa_select_mitigation();
51 }
52 - if (mmio_mitigation == MMIO_MITIGATION_OFF &&
53 - boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA)) {
54 + /*
55 + * MMIO_MITIGATION_OFF is not checked here so that mmio_stale_data_clear
56 + * gets updated correctly as per X86_FEATURE_CLEAR_CPU_BUF state.
57 + */
58 + if (boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA)) {
59 mmio_mitigation = MMIO_MITIGATION_VERW;
60 mmio_select_mitigation();
61 }