--- a/drivers/xen/xenbus/xenbus_probe.c	2009-07-15 08:42:09.000000000 +0800
+++ b/drivers/xen/xenbus/xenbus_probe.c	2009-07-15 08:42:25.000000000 +0800
@@ -1138,7 +1138,7 @@ static int xsd_port_read(char *page, cha
 }
 #endif /* CONFIG_PROC_FS && CONFIG_XEN_PRIVILEGED_GUEST */
 
-static int __init xenbus_probe_init(void)
+int xenbus_probe_init(void)
 {
 	int err = 0;
 	unsigned long page = 0L;
@@ -1259,7 +1259,6 @@ err:
 }
 
 #ifdef CONFIG_XEN
-postcore_initcall(xenbus_probe_init);
 
 MODULE_LICENSE("Dual BSD/GPL");
 #else
--- a/drivers/xen/core/smpboot.c	2009-07-15 08:33:55.000000000 +0800
+++ b/drivers/xen/core/smpboot.c	2009-07-15 08:49:13.000000000 +0800
@@ -44,6 +44,8 @@ extern void smp_trap_init(trap_info_t *)
 extern void cpu_idle(void);
 
 extern void fixup_irqs(cpumask_t);
+extern int setup_vcpu_hotplug_event(void);
+extern int xenbus_probe_init(void);
 
 /* Number of siblings per CPU package */
 int smp_num_siblings = 1;
@@ -360,12 +362,11 @@ void __devinit smp_prepare_boot_cpu(void
  * But do it early enough to catch critical for_each_present_cpu() loops
  * in i386-specific code.
  */
-static int __init initialize_cpu_present_map(void)
+static int initialize_cpu_present_map(void)
 {
 	cpu_present_map = cpu_possible_map;
 	return 0;
 }
-core_initcall(initialize_cpu_present_map);
 
 static void
 remove_siblinginfo(int cpu)
@@ -468,3 +469,14 @@ int setup_profiling_timer(unsigned int m
 	return -EINVAL;
 }
 #endif
+
+void __init xen_vcpu_init(void)
+{
+#ifdef CONFIG_XEN
+	xenbus_probe_init();
+#ifdef CONFIG_HOTPLUG_CPU
+	initialize_cpu_present_map();
+	setup_vcpu_hotplug_event();
+#endif
+#endif
+}
--- a/drivers/xen/core/cpu_hotplug.c	2009-07-15 08:34:02.000000000 +0800
+++ b/drivers/xen/core/cpu_hotplug.c	2009-07-15 08:40:49.000000000 +0800
@@ -102,7 +102,7 @@ static int setup_cpu_watcher(struct noti
 	return NOTIFY_DONE;
 }
 
-static int __init setup_vcpu_hotplug_event(void)
+int setup_vcpu_hotplug_event(void)
 {
 	static struct notifier_block hotplug_cpu = {
 		.notifier_call = smpboot_cpu_notify };
@@ -118,8 +118,6 @@ static int __init setup_vcpu_hotplug_eve
 	return 0;
 }
 
-arch_initcall(setup_vcpu_hotplug_event);
-
 int smp_suspend(void)
 {
 	int cpu, err;
--- a/init/main.c	2009-07-15 08:33:31.000000000 +0800
+++ b/init/main.c	2009-07-15 08:45:10.000000000 +0800
@@ -105,6 +105,10 @@ static inline void acpi_early_init(void)
 extern void tc_init(void);
 #endif
 
+#ifdef CONFIG_XEN
+extern void xen_vcpu_init();
+#endif
+
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);
 
@@ -732,9 +736,17 @@ static void __init do_basic_setup(void)
 {
 	/* drivers will send hotplug events */
 	init_workqueues();
+#ifndef CONFIG_XEN
 	usermodehelper_init();
 
 	driver_init();
+#else
+	/* Have to initialize vcpus before do user process schedule,
+	   or vcpu init switch_pt() will race to switch_mm() */
+	driver_init();
+	xen_vcpu_init();
+	usermodehelper_init();
+#endif
 
 #ifdef CONFIG_SYSCTL
 	sysctl_init();
