[RFC PATCH 11/56] x86/bugs: Reset MMIO mitigations

David Kaplan posted 56 patches 3 months, 4 weeks ago
[RFC PATCH 11/56] x86/bugs: Reset MMIO mitigations
Posted by David Kaplan 3 months, 4 weeks ago
Add function to reset MMIO mitigations back to their boot-time defaults.

Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
 arch/x86/kernel/cpu/bugs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 5668a8b8821b..9139c8187913 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -787,6 +787,16 @@ static void __init mmio_apply_mitigation(void)
 		cpu_smt_disable(false);
 }
 
+#ifdef CONFIG_DYNAMIC_MITIGATIONS
+static void mmio_reset_mitigation(void)
+{
+	static_branch_disable(&cpu_buf_vm_clear);
+	static_branch_disable(&cpu_buf_idle_clear);
+	mmio_mitigation = IS_ENABLED(CONFIG_MITIGATION_MMIO_STALE_DATA) ?
+		MMIO_MITIGATION_AUTO : MMIO_MITIGATION_OFF;
+}
+#endif
+
 static int __init mmio_stale_data_parse_cmdline(char *str)
 {
 	if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))
@@ -3902,5 +3912,6 @@ void arch_cpu_reset_mitigations(void)
 	ssb_reset_mitigation();
 	l1tf_reset_mitigation();
 	mds_reset_mitigation();
+	mmio_reset_mitigation();
 }
 #endif
-- 
2.34.1
Re: [RFC PATCH 11/56] x86/bugs: Reset MMIO mitigations
Posted by Borislav Petkov 1 week, 6 days ago
On Mon, Oct 13, 2025 at 09:33:59AM -0500, David Kaplan wrote:
> Add function to reset MMIO mitigations back to their boot-time defaults.
> 
> Signed-off-by: David Kaplan <david.kaplan@amd.com>
> ---
>  arch/x86/kernel/cpu/bugs.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 5668a8b8821b..9139c8187913 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -787,6 +787,16 @@ static void __init mmio_apply_mitigation(void)
>  		cpu_smt_disable(false);
>  }
>  
> +#ifdef CONFIG_DYNAMIC_MITIGATIONS
> +static void mmio_reset_mitigation(void)
> +{
> +	static_branch_disable(&cpu_buf_vm_clear);

This needs to be

	setup_clear_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF_VM_MMIO);

I believe, after:

f6106d41ec84 ("x86/bugs: Use an x86 feature to track the MMIO Stale Data mitigation")

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette