• C
    KVM: Take vcpu->mutex outside vcpu_load · ec7660cc
    Christoffer Dall 提交于
    As we're about to call vcpu_load() from architecture-specific
    implementations of the KVM vcpu ioctls, but yet we access data
    structures protected by the vcpu->mutex in the generic code, factor
    this logic out from vcpu_load().
    
    x86 is the only architecture which calls vcpu_load() outside of the main
    vcpu ioctl function, and these calls will no longer take the vcpu mutex
    following this patch.  However, with the exception of
    kvm_arch_vcpu_postcreate (see below), the callers are either in the
    creation or destruction path of the VCPU, which means there cannot be
    any concurrent access to the data structure, because the file descriptor
    is not yet accessible, or is already gone.
    
    kvm_arch_vcpu_postcreate makes the newly created vcpu potentially
    accessible by other in-kernel threads through the kvm->vcpus array, and
    we therefore take the vcpu mutex in this case directly.
    Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
    Reviewed-by: NCornelia Huck <cohuck@redhat.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    ec7660cc
kvm_host.h 35.4 KB