History

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.

Christoffer Dall committed 10 years ago

Commit a28ebea1 parent 023e9fd5 files · +27 −17Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/kvm_host.h+6−0
@@ -1113,6 +1113,12 @@ struct kvm_device { · 1112 unmodified lines
11131113 /* create, destroy, and name are mandatory */
11141114 struct kvm_device_ops {
11151115 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+ */
11161122 int (*create)(struct kvm_device *dev, u32 type);
11171123
11181124 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t