]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: SVM: fix suspend/resume support
authorJoerg Roedel <joerg.roedel@amd.com>
Wed, 2 Jul 2008 14:02:11 +0000 (16:02 +0200)
committerAvi Kivity <avi@qumranet.com>
Sun, 20 Jul 2008 09:42:37 +0000 (12:42 +0300)
On suspend the svm_hardware_disable function is called which frees all svm_data
variables. On resume they are not re-allocated. This patch removes the
deallocation of svm_data from the hardware_disable function to the
hardware_unsetup function which is not called on suspend.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/svm.c

index 238e8f3afaf42cf3a8f32d10ac474d9fd7814e24..858e29702232b5b3063fa6a191830422bd289d98 100644 (file)
@@ -272,19 +272,11 @@ static int has_svm(void)
 
 static void svm_hardware_disable(void *garbage)
 {
-       struct svm_cpu_data *svm_data
-               = per_cpu(svm_data, raw_smp_processor_id());
-
-       if (svm_data) {
-               uint64_t efer;
+       uint64_t efer;
 
-               wrmsrl(MSR_VM_HSAVE_PA, 0);
-               rdmsrl(MSR_EFER, efer);
-               wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
-               per_cpu(svm_data, raw_smp_processor_id()) = NULL;
-               __free_page(svm_data->save_area);
-               kfree(svm_data);
-       }
+       wrmsrl(MSR_VM_HSAVE_PA, 0);
+       rdmsrl(MSR_EFER, efer);
+       wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
 }
 
 static void svm_hardware_enable(void *garbage)
@@ -323,6 +315,19 @@ static void svm_hardware_enable(void *garbage)
               page_to_pfn(svm_data->save_area) << PAGE_SHIFT);
 }
 
+static void svm_cpu_uninit(int cpu)
+{
+       struct svm_cpu_data *svm_data
+               = per_cpu(svm_data, raw_smp_processor_id());
+
+       if (!svm_data)
+               return;
+
+       per_cpu(svm_data, raw_smp_processor_id()) = NULL;
+       __free_page(svm_data->save_area);
+       kfree(svm_data);
+}
+
 static int svm_cpu_init(int cpu)
 {
        struct svm_cpu_data *svm_data;
@@ -460,6 +465,11 @@ err:
 
 static __exit void svm_hardware_unsetup(void)
 {
+       int cpu;
+
+       for_each_online_cpu(cpu)
+               svm_cpu_uninit(cpu);
+
        __free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), IOPM_ALLOC_ORDER);
        iopm_base = 0;
 }