aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm_host.h
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2016-08-09 13:13:01 -0400
committerRadim Krčmář <rkrcmar@redhat.com>2016-08-12 06:01:27 -0400
commita28ebea2adc4a2bef5989a5a181ec238f59fbcad (patch)
tree2ce115dec973b4383b64a33a999b7396e9b8f8e8 /include/linux/kvm_host.h
parent023e9fddc3616b005c3753fc1bb6526388cd7a30 (diff)
KVM: Protect device ops->create and list_add with kvm->lock
KVM devices were manipulating list data structures without any form of synchronization, and some implementations of the create operations also suffered from a lack of synchronization. Now when we've split the xics create operation into create and init, we can hold the kvm->lock mutex while calling the create operation and when manipulating the devices list. The error path in the generic code gets slightly ugly because we have to take the mutex again and delete the device from the list, but holding the mutex during anon_inode_getfd or releasing/locking the mutex in the common non-error path seemed wrong. Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r--include/linux/kvm_host.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index d3c9b82812c3..9c28b4d4c90b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1113,6 +1113,12 @@ struct kvm_device {
1113/* create, destroy, and name are mandatory */ 1113/* create, destroy, and name are mandatory */
1114struct kvm_device_ops { 1114struct kvm_device_ops {
1115 const char *name; 1115 const char *name;
1116
1117 /*
1118 * create is called holding kvm->lock and any operations not suitable
1119 * to do while holding the lock should be deferred to init (see
1120 * below).
1121 */
1116 int (*create)(struct kvm_device *dev, u32 type); 1122 int (*create)(struct kvm_device *dev, u32 type);
1117 1123
1118 /* 1124 /*