]> Pileus Git - ~andy/linux/blobdiff - arch/x86/xen/enlighten.c
xen/vcpu: Fix vcpu restore path.
[~andy/linux] / arch / x86 / xen / enlighten.c
index a90c3bb58bed0634047d8c5f79cea610f351d0d8..138e5667409a3415492e860c8cfa708028d6d467 100644 (file)
@@ -193,10 +193,11 @@ void xen_vcpu_restore(void)
 {
        int cpu;
 
-       for_each_online_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                bool other_cpu = (cpu != smp_processor_id());
+               bool is_up = HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL);
 
-               if (other_cpu &&
+               if (other_cpu && is_up &&
                    HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL))
                        BUG();
 
@@ -205,7 +206,7 @@ void xen_vcpu_restore(void)
                if (have_vcpu_info_placement)
                        xen_vcpu_setup(cpu);
 
-               if (other_cpu &&
+               if (other_cpu && is_up &&
                    HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL))
                        BUG();
        }
@@ -223,6 +224,21 @@ static void __init xen_banner(void)
               version >> 16, version & 0xffff, extra.extraversion,
               xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
 }
+/* Check if running on Xen version (major, minor) or later */
+bool
+xen_running_on_version_or_later(unsigned int major, unsigned int minor)
+{
+       unsigned int version;
+
+       if (!xen_domain())
+               return false;
+
+       version = HYPERVISOR_xen_version(XENVER_version, NULL);
+       if ((((version >> 16) == major) && ((version & 0xffff) >= minor)) ||
+               ((version >> 16) > major))
+               return true;
+       return false;
+}
 
 #define CPUID_THERM_POWER_LEAF 6
 #define APERFMPERF_PRESENT 0
@@ -287,8 +303,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 
 static bool __init xen_check_mwait(void)
 {
-#if defined(CONFIG_ACPI) && !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) && \
-       !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
+#ifdef CONFIG_ACPI
        struct xen_platform_op op = {
                .cmd                    = XENPF_set_processor_pminfo,
                .u.set_pminfo.id        = -1,
@@ -309,6 +324,13 @@ static bool __init xen_check_mwait(void)
        if (!xen_initial_domain())
                return false;
 
+       /*
+        * When running under platform earlier than Xen4.2, do not expose
+        * mwait, to avoid the risk of loading native acpi pad driver
+        */
+       if (!xen_running_on_version_or_later(4, 2))
+               return false;
+
        ax = 1;
        cx = 0;
 
@@ -1557,7 +1579,7 @@ static void __init xen_hvm_init_shared_info(void)
 
 static void __init init_hvm_pv_info(void)
 {
-       uint32_t eax, ebx, ecx, edx, pages, msr, base;
+       uint32_t ecx, edx, pages, msr, base;
        u64 pfn;
 
        base = xen_cpuid_base();