[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251013143444.3999-57-david.kaplan@amd.com>
Date: Mon, 13 Oct 2025 09:34:44 -0500
From: David Kaplan <david.kaplan@....com>
To: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>, Ingo Molnar
<mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>,
<x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>
CC: Alexander Graf <graf@...zon.com>, Boris Ostrovsky
<boris.ostrovsky@...cle.com>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 56/56] x86/debug: Show static branch config in debugfs
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@....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
Powered by blists - more mailing lists