hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/s390/kvm/kvm-s390.c
....@@ -2005,6 +2005,10 @@
20052005 ms = slots->memslots + slotidx;
20062006 ofs = 0;
20072007 }
2008
+
2009
+ if (cur_gfn < ms->base_gfn)
2010
+ ofs = 0;
2011
+
20082012 ofs = find_next_bit(kvm_second_dirty_bitmap(ms), ms->npages, ofs);
20092013 while ((slotidx > 0) && (ofs >= ms->npages)) {
20102014 slotidx--;
....@@ -5012,6 +5016,23 @@
50125016 /* When we are protected, we should not change the memory slots */
50135017 if (kvm_s390_pv_get_handle(kvm))
50145018 return -EINVAL;
5019
+
5020
+ if (!kvm->arch.migration_mode)
5021
+ return 0;
5022
+
5023
+ /*
5024
+ * Turn off migration mode when:
5025
+ * - userspace creates a new memslot with dirty logging off,
5026
+ * - userspace modifies an existing memslot (MOVE or FLAGS_ONLY) and
5027
+ * dirty logging is turned off.
5028
+ * Migration mode expects dirty page logging being enabled to store
5029
+ * its dirty bitmap.
5030
+ */
5031
+ if (change != KVM_MR_DELETE &&
5032
+ !(mem->flags & KVM_MEM_LOG_DIRTY_PAGES))
5033
+ WARN(kvm_s390_vm_stop_migration(kvm),
5034
+ "Failed to stop migration mode");
5035
+
50155036 return 0;
50165037 }
50175038