[Devel] [PATCH RHEL7 COMMIT] arch/x86: disable cpuid faulting on reboot and cpu offline

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 20 09:00:22 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.9
------>
commit bf0c0fd8313aa40814ffae8dcd5d0655ce9c5cc2
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Tue Oct 20 20:00:22 2015 +0400

    arch/x86: disable cpuid faulting on reboot and cpu offline
    
    Port diff-arch-x86-disable-cpuid-faulting-on-reboot-and-cpu-offline
    
    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 fdfbf94..36fbfdf 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 57649dd..07f1090 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);
 }
 
 /*



More information about the Devel mailing list