+/*
+ * Takes kvm->slots_arch_lock, and releases it only if
+ * invalid_slot allocation or kvm_prepare_memory_region failed.
+*/
+/* Must be called with kvm->slots_arch_lock held, but releases it. */s/but/and/. Even better, "and releases it before returning". "But" tells the reader that something strange is going on, "and" tells it that something simple is going on.
+static void kvm_finish_memslot(struct kvm *kvm,
+ struct kvm_internal_memory_region_list *batch)
+{
+ struct kvm_memory_slot *invalid_slot = batch->invalid;
+ struct kvm_memory_slot *old = batch->old;
+ struct kvm_memory_slot *new = batch->new;
+ enum kvm_mr_change change = batch->change;
/*
* For DELETE and MOVE, the working slot is now active as the INVALID
@@ -1883,6 +1898,18 @@ static int kvm_set_memslot(struct kvm *kvm,
* responsible for knowing that new->arch may be stale.
*/
kvm_commit_memory_region(kvm, batch);
+}
+
+static int kvm_set_memslot(struct kvm *kvm,
+ struct kvm_internal_memory_region_list *batch)
+{
+ int r;
+
+ r = kvm_prepare_memslot(kvm, batch);
+ if (r)
+ return r;
+
+ kvm_finish_memslot(kvm, batch);
return 0;