Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32aa144f authored by Christian Borntraeger's avatar Christian Borntraeger
Browse files

KVM: s390: fix cmma migration for multiple memory slots



When multiple memory slots are present the cmma migration code
does not allocate enough memory for the bitmap. The memory slots
are sorted in reverse order, so we must use gfn and size of
slot[0] instead of the last one.

Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: default avatarClaudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # 4.13+
Fixes: 190df4a2 (KVM: s390: CMMA tracking, ESSA emulation, migration mode)
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
parent ca76ec9c
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -792,11 +792,12 @@ static int kvm_s390_vm_start_migration(struct kvm *kvm)


	if (kvm->arch.use_cmma) {
	if (kvm->arch.use_cmma) {
		/*
		/*
		 * Get the last slot. They should be sorted by base_gfn, so the
		 * Get the first slot. They are reverse sorted by base_gfn, so
		 * last slot is also the one at the end of the address space.
		 * the first slot is also the one at the end of the address
		 * We have verified above that at least one slot is present.
		 * space. We have verified above that at least one slot is
		 * present.
		 */
		 */
		ms = slots->memslots + slots->used_slots - 1;
		ms = slots->memslots;
		/* round up so we only use full longs */
		/* round up so we only use full longs */
		ram_pages = roundup(ms->base_gfn + ms->npages, BITS_PER_LONG);
		ram_pages = roundup(ms->base_gfn + ms->npages, BITS_PER_LONG);
		/* allocate enough bytes to store all the bits */
		/* allocate enough bytes to store all the bits */