]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
KVM: Fix hotplug of CPUs
authorZachary Amsden <zamsden@redhat.com>
Tue, 29 Sep 2009 21:38:37 +0000 (11:38 -1000)
committerAvi Kivity <avi@redhat.com>
Thu, 3 Dec 2009 07:32:13 +0000 (09:32 +0200)
Both VMX and SVM require per-cpu memory allocation, which is done at module
init time, for only online cpus.

Backend was not allocating enough structure for all possible CPUs, so
new CPUs coming online could not be hardware enabled.

Signed-off-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c

index d1036ce8917e985dea5f28d80c58e2692a5c1241..02a4269be645cf0f44f5fb21e71f2bca45974b5f 100644 (file)
@@ -482,7 +482,7 @@ static __init int svm_hardware_setup(void)
                kvm_enable_efer_bits(EFER_SVME);
        }
 
-       for_each_online_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                r = svm_cpu_init(cpu);
                if (r)
                        goto err;
@@ -516,7 +516,7 @@ static __exit void svm_hardware_unsetup(void)
 {
        int cpu;
 
-       for_each_online_cpu(cpu)
+       for_each_possible_cpu(cpu)
                svm_cpu_uninit(cpu);
 
        __free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), IOPM_ALLOC_ORDER);
index a187570e48379d6aa3fb170c3a7094e31023a287..97f4265cda3852107590edec2482a925b296d307 100644 (file)
@@ -1350,15 +1350,17 @@ static void free_kvm_area(void)
 {
        int cpu;
 
-       for_each_online_cpu(cpu)
+       for_each_possible_cpu(cpu) {
                free_vmcs(per_cpu(vmxarea, cpu));
+               per_cpu(vmxarea, cpu) = NULL;
+       }
 }
 
 static __init int alloc_kvm_area(void)
 {
        int cpu;
 
-       for_each_online_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                struct vmcs *vmcs;
 
                vmcs = alloc_vmcs_cpu(cpu);