[v1,Part2,5/5] x86/microcode: Provide an option to override minrev enforcement
Commit Message
Minimum Required Revision (minrev) is enforced strictly. All new patches
will have a minrev that is not zero. But there might be a transition time
for some that need this enforcement to be relaxed.
When the override is enabled, the kernel will be tainted.
Provide a debugfs variable to override the minrev enforcement.
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Cc: x86 <x86@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Thomas Gleixner (Intel) <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Stefan Talpalaru <stefantalpalaru@yahoo.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Peter Zilstra (Intel) <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>
---
This patch is optional.
---
arch/x86/include/asm/microcode.h | 2 ++
arch/x86/kernel/cpu/microcode/core.c | 13 ++++++++++++-
arch/x86/kernel/cpu/microcode/intel.c | 8 ++++++++
3 files changed, 22 insertions(+), 1 deletion(-)
@@ -16,6 +16,8 @@ struct ucode_patch {
extern struct list_head microcode_cache;
+extern bool override_minrev;
+
struct cpu_signature {
unsigned int sig;
unsigned int pf;
@@ -24,6 +24,7 @@
#include <linux/miscdevice.h>
#include <linux/capability.h>
#include <linux/firmware.h>
+#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/mutex.h>
@@ -44,7 +45,9 @@
#define DRIVER_VERSION "2.2"
static struct microcode_ops *microcode_ops;
+static struct dentry *dentry_ucode;
static bool dis_ucode_ldr = true;
+bool override_minrev;
bool initrd_gone;
@@ -497,7 +500,11 @@ static ssize_t reload_store(struct device *dev,
pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n");
pr_err("You should switch to early loading, if possible.\n");
ret = -EINVAL;
- goto put;
+
+ if (!override_minrev)
+ goto put;
+
+ pr_err("Overriding minrev\n");
}
tmp_ret = microcode_ops->request_microcode_fw(bsp, µcode_pdev->dev);
@@ -688,7 +695,11 @@ static int __init microcode_init(void)
cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
mc_cpu_online, mc_cpu_down_prep);
+ dentry_ucode = debugfs_create_dir("microcode", NULL);
+ debugfs_create_bool("override_minrev", 0644, dentry_ucode, &override_minrev);
+
pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);
+ pr_info("Override minrev %s\n", override_minrev ? "enabled" : "disabled");
return 0;
@@ -141,6 +141,14 @@ static int is_lateload_safe(struct microcode_header_intel *mc_header)
{
struct ucode_cpu_info uci;
+ /*
+ * If minrev is bypassed via debugfs, then allow late-load.
+ */
+ if (override_minrev) {
+ pr_info("Bypassing minrev enforcement via debugfs\n");
+ return 0;
+ }
+
/*
* When late-loading, ensure the header declares a minimum revision
* required to perform a late-load.