]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: mark memory slots as rcu
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 6 Jul 2017 14:17:14 +0000 (16:17 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Fri, 7 Jul 2017 13:24:17 +0000 (15:24 +0200)
we access the memslots array via srcu. Mark it as such and
use the right access functions also for the freeing of
memory slots.

Found by sparse:
./include/linux/kvm_host.h:565:16: error: incompatible types in
comparison expression (different address spaces)

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index 6a164f9eb02c159bb03558bf9bbf5293406f83ad..b3ca77a96b2d7520f37007f3ab0746e229d4616e 100644 (file)
@@ -390,7 +390,7 @@ struct kvm {
        spinlock_t mmu_lock;
        struct mutex slots_lock;
        struct mm_struct *mm; /* userspace tied to this vm */
-       struct kvm_memslots *memslots[KVM_ADDRESS_SPACE_NUM];
+       struct kvm_memslots __rcu *memslots[KVM_ADDRESS_SPACE_NUM];
        struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
 
        /*
index d76e822f89291a00002cd2f5ff83afe6777584a5..6e6d4edf0e92311d7c48ca18aab53603d56fe3bc 100644 (file)
@@ -707,7 +707,8 @@ out_err_no_disable:
        for (i = 0; i < KVM_NR_BUSES; i++)
                kfree(rcu_access_pointer(kvm->buses[i]));
        for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++)
-               kvm_free_memslots(kvm, kvm->memslots[i]);
+               kvm_free_memslots(kvm,
+                       rcu_dereference_protected(kvm->memslots[i], 1));
        kvm_arch_free_vm(kvm);
        mmdrop(current->mm);
        return ERR_PTR(r);
@@ -756,7 +757,8 @@ static void kvm_destroy_vm(struct kvm *kvm)
        kvm_arch_destroy_vm(kvm);
        kvm_destroy_devices(kvm);
        for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++)
-               kvm_free_memslots(kvm, kvm->memslots[i]);
+               kvm_free_memslots(kvm,
+                       rcu_dereference_protected(kvm->memslots[i], 1));
        cleanup_srcu_struct(&kvm->irq_srcu);
        cleanup_srcu_struct(&kvm->srcu);
        kvm_arch_free_vm(kvm);