xen: restore vcpu_info mapping
authorJeremy Fitzhardinge <jeremy@goop.org>
Sat, 31 May 2008 00:33:02 +0000 (01:33 +0100)
committerIngo Molnar <mingo@elte.hu>
Mon, 2 Jun 2008 11:25:34 +0000 (13:25 +0200)
If we're using vcpu_info mapping, then make sure its restored on all
processors before relasing them from stop_machine.

The only complication is that if this fails, we can't continue because
we've already made assumptions that the mapping is available (baked in
calls to the _direct versions of the functions, for example).

Fortunately this can only happen with a 32-bit hypervisor, which may
possibly run out of mapping space.  On a 64-bit hypervisor, this is a
non-issue.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/xen/enlighten.c
arch/x86/xen/suspend.c
arch/x86/xen/xen-ops.h

index ed9f04b..8e6152e 100644 (file)
@@ -98,7 +98,7 @@ struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
  */
 static int have_vcpu_info_placement = 1;
 
-static void __init xen_vcpu_setup(int cpu)
+static void xen_vcpu_setup(int cpu)
 {
        struct vcpu_register_vcpu_info info;
        int err;
@@ -136,6 +136,34 @@ static void __init xen_vcpu_setup(int cpu)
        }
 }
 
+/*
+ * On restore, set the vcpu placement up again.
+ * If it fails, then we're in a bad state, since
+ * we can't back out from using it...
+ */
+void xen_vcpu_restore(void)
+{
+       if (have_vcpu_info_placement) {
+               int cpu;
+
+               for_each_online_cpu(cpu) {
+                       bool other_cpu = (cpu != smp_processor_id());
+
+                       if (other_cpu &&
+                           HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL))
+                               BUG();
+
+                       xen_vcpu_setup(cpu);
+
+                       if (other_cpu &&
+                           HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL))
+                               BUG();
+               }
+
+               BUG_ON(!have_vcpu_info_placement);
+       }
+}
+
 static void __init xen_banner(void)
 {
        printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
index 7620a16..7ab10f6 100644 (file)
@@ -26,6 +26,8 @@ void xen_pre_suspend(void)
 
 void xen_post_suspend(int suspend_cancelled)
 {
+       xen_setup_shared_info();
+
        if (suspend_cancelled) {
                xen_start_info->store_mfn =
                        pfn_to_mfn(xen_start_info->store_mfn);
@@ -35,8 +37,8 @@ void xen_post_suspend(int suspend_cancelled)
 #ifdef CONFIG_SMP
                xen_cpu_initialized_map = cpu_online_map;
 #endif
+               xen_vcpu_restore();
        }
 
-       xen_setup_shared_info();
 }
 
index a0503ac..a457e03 100644 (file)
@@ -26,6 +26,7 @@ char * __init xen_memory_setup(void);
 void __init xen_arch_setup(void);
 void __init xen_init_IRQ(void);
 void xen_enable_sysenter(void);
+void xen_vcpu_restore(void);
 
 void __init xen_build_dynamic_phys_to_machine(void);