.. | .. |
---|
2005 | 2005 | ms = slots->memslots + slotidx; |
---|
2006 | 2006 | ofs = 0; |
---|
2007 | 2007 | } |
---|
| 2008 | + |
---|
| 2009 | + if (cur_gfn < ms->base_gfn) |
---|
| 2010 | + ofs = 0; |
---|
| 2011 | + |
---|
2008 | 2012 | ofs = find_next_bit(kvm_second_dirty_bitmap(ms), ms->npages, ofs); |
---|
2009 | 2013 | while ((slotidx > 0) && (ofs >= ms->npages)) { |
---|
2010 | 2014 | slotidx--; |
---|
.. | .. |
---|
5012 | 5016 | /* When we are protected, we should not change the memory slots */ |
---|
5013 | 5017 | if (kvm_s390_pv_get_handle(kvm)) |
---|
5014 | 5018 | 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 | + |
---|
5015 | 5036 | return 0; |
---|
5016 | 5037 | } |
---|
5017 | 5038 | |
---|