[Devel] [PATCH rh7 08/11] Port diff-arch-x86-disable-cpuid-faulting-on-reboot-and-cpu-offline

Vladimir Davydov vdavydov at virtuozzo.com
Fri Oct 16 09:22:52 PDT 2015


Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: arch: x86: disable cpuid faulting on reboot and cpu offline
Date: Wed, 10 Dec 2014 17:07:04 +0300

Disable cpuid faulting before loading a new kernel by kexec in case the
new kernel does not support this feature.

https://jira.sw.ru/browse/PSBM-30548

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
=============================================================================

https://jira.sw.ru/browse/PSBM-33638

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 arch/x86/kernel/cpuid_fault.c | 29 ++++++++++++++++++++++++++++-
 kernel/sched/core.c           |  3 +++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpuid_fault.c b/arch/x86/kernel/cpuid_fault.c
index fdfbf942f2a1..36fbfdf0f3ec 100644
--- a/arch/x86/kernel/cpuid_fault.c
+++ b/arch/x86/kernel/cpuid_fault.c
@@ -5,6 +5,8 @@
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/notifier.h>
+#include <linux/reboot.h>
 #include <linux/ve.h>
 #include <asm/uaccess.h>
 
@@ -26,7 +28,7 @@ struct cpuid_override_table {
 	struct cpuid_override_entry entries[MAX_CPUID_OVERRIDE_ENTRIES];
 };
 
-static struct cpuid_override_table __rcu *cpuid_override;
+static struct cpuid_override_table __rcu *cpuid_override __read_mostly;
 static DEFINE_SPINLOCK(cpuid_override_lock);
 
 #define cpuid_override_active		(!!rcu_access_pointer(cpuid_override))
@@ -264,6 +266,29 @@ static struct file_operations proc_cpuid_override_ops = {
 	.write   = cpuid_override_write,
 };
 
+static void disable_cpuid_faulting_fn(void *unused)
+{
+	set_cpuid_faulting(false);
+}
+
+static int cpuid_faulting_reboot_notify(struct notifier_block *nb,
+					unsigned long code, void *unused)
+{
+	if (code == SYS_RESTART) {
+		/*
+		 * Disable cpuid faulting before loading a new kernel by kexec
+		 * in case the new kernel does not support this feature.
+		 */
+		cpuid_override_update(NULL);
+		on_each_cpu(disable_cpuid_faulting_fn, NULL, 1);
+	}
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block cpuid_faulting_reboot_nb = {
+	.notifier_call = cpuid_faulting_reboot_notify,
+};
+
 static int __init cpuid_fault_init(void)
 {
 	struct proc_dir_entry *proc;
@@ -271,6 +296,8 @@ static int __init cpuid_fault_init(void)
 	if (!cpu_has_cpuid_faulting)
 		return 0;
 
+	register_reboot_notifier(&cpuid_faulting_reboot_nb);
+
 	proc = proc_create("cpuid_override", 0644, proc_vz_dir,
 			   &proc_cpuid_override_ops);
 	if (!proc)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 57649dd6a6a0..07f10904d504 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5394,6 +5394,9 @@ void idle_task_exit(void)
 	if (mm != &init_mm)
 		switch_mm(mm, &init_mm, current);
 	mmdrop(mm);
+
+	/* disable cpuid faulting when a cpu goes offline */
+	set_cpuid_faulting(false);
 }
 
 /*
-- 
2.1.4




More information about the Devel mailing list