[PATCH 3/4] x86/speculation: Implement PSF mitigation support
From: Ramakrishna Saripalli
Date: Wed Apr 21 2021 - 05:01:50 EST
From: Ramakrishna Saripalli <rk.saripalli@xxxxxxx>
Implement support for PSF mitigation via a kernel parameter.
Kernel parameter predict_store_fwd has the following values
- off. PSF mitigation is enabled which means the feature is disabled.
- on. PSF mitigation is not enabled. This is also the default behavior.
Signed-off-by: Ramakrishna Saripalli<rk.saripalli@xxxxxxx>
---
arch/x86/kernel/cpu/amd.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 347a956f71ca..88aac52eeb1b 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1170,3 +1170,22 @@ void set_dr_addr_mask(unsigned long mask, int dr)
break;
}
}
+
+static int __init psf_cmdline(char *str)
+{
+ if (!boot_cpu_has(X86_FEATURE_PSFD))
+ return 0;
+
+ if (!str)
+ return -EINVAL;
+
+ if (!strcmp(str, "off")) {
+ x86_spec_ctrl_base |= SPEC_CTRL_PSFD;
+ wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
+ setup_clear_cpu_cap(X86_FEATURE_PSFD);
+ }
+
+ return 0;
+}
+
+early_param("predict_store_fwd", psf_cmdline);
--
2.25.1