Create a debugfs interface showing the current enablement status of the
static branches related to mitigations. This will be used by user-space
testing tools to verify mitigation configuration.
Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/cpu/bugs.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 8365448b3aef..eeb7d50332cf 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -4099,12 +4099,44 @@ static const struct file_operations dfs_thunk_ops = {
.release = single_release,
};
+static int static_branch_debug_show(struct seq_file *m, void *p)
+{
+ if (static_key_enabled((struct static_key *)m->private))
+ seq_puts(m, "enabled\n");
+ else
+ seq_puts(m, "disabled\n");
+
+ return 0;
+}
+
+static int static_branch_debug_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, static_branch_debug_show, inode->i_private);
+}
+
+static const struct file_operations dfs_static_branch_ops = {
+ .open = static_branch_debug_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int __init mitigations_debugfs_init(void)
{
struct dentry *dir;
dir = debugfs_create_dir("mitigations", arch_debugfs_dir);
debugfs_create_file("x86_return_thunk", 0400, dir, NULL, &dfs_thunk_ops);
+ debugfs_create_file("switch_mm_cond_ibpb", 0400, dir,
+ &switch_mm_cond_ibpb, &dfs_static_branch_ops);
+ debugfs_create_file("switch_mm_always_ibpb", 0400, dir,
+ &switch_mm_always_ibpb, &dfs_static_branch_ops);
+ debugfs_create_file("switch_vcpu_ibpb", 0400, dir,
+ &switch_vcpu_ibpb, &dfs_static_branch_ops);
+ debugfs_create_file("cpu_buf_idle_clear", 0400, dir,
+ &cpu_buf_idle_clear, &dfs_static_branch_ops);
+ debugfs_create_file("cpu_buf_vm_clear", 0400, dir,
+ &cpu_buf_vm_clear, &dfs_static_branch_ops);
return 0;
}
--
2.34.1