Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 1896

kernel-2.6.18-238.el5.src.rpm

From: Kei Tokunaga <ktokunag@redhat.com>
Date: Sat, 12 Jan 2008 16:35:12 -0500
Subject: [misc] enabling a non-hotplug cpu should cause panic
Message-id: 47893290.30900@redhat.com
O-Subject: [RHEL5.2 PATCH] Panic if user enable a cpu which is not prepared for hotplug
Bugzilla: 426508

bz426508
https://bugzilla.redhat.com/show_bug.cgi?id=426508

If a cpu going to be enabled, the cpu should be on cpu_possible_map
or else there are no resources reserved for the cpu. (On some arch,
we can specify how many extra set of resources should be prepared by
setting additional_cpus=X boot option.)
However there was no code to check that the cpu is on the map or not.
This will result in a system panic since the cpu being enabled will
try to access its own resources (ex. per-cpu memory) but none of them
are available.

This patch checks if the cpu being enabled is in cpu_possible_map or
not.  If it is not, outputs error messages and aborts the operation,
so a system panic can be avoided.

This patch was backported from upstream for 2.6.18-53 and has the
effect for ia64, x86_64, and s390.  We tested it on ia64 and confirmed
that the patch was built on all platforms on brew.

Thanks,
Kei

CPU HOTPLUG: avoid hotadd when proper possible_map isn't specified

cpu-hot-add should be fail if cpu is not set in cpu_possible_map.  If go
ahead, the system will panic soon.

Especially, arch which requires additional_cpus= parameter should handle
this.  Tested on ia64.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Acked-by: Rik van Riel <riel@redhat.com>

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 272254f..54a8ae9 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -242,6 +242,15 @@ out_notify:
 int __devinit cpu_up(unsigned int cpu)
 {
 	int err = 0;
+	if (!cpu_isset(cpu, cpu_possible_map)) {
+		printk(KERN_ERR "can't online cpu %d because it is not "
+			"configured as may-hotadd at boot time\n", cpu);
+#if defined(CONFIG_IA64) || defined(CONFIG_X86_64) || defined(CONFIG_S390)
+		printk(KERN_ERR "please check additional_cpus= boot "
+				"parameter\n");
+#endif
+		return -EINVAL;
+	}
 
 	mutex_lock(&cpu_add_remove_lock);
 	if (cpu_hotplug_disabled)