]>
Commit | Line | Data |
---|---|---|
e5d76626 GKH |
1 | From 32aa144fc32abfcbf7140f473dfbd94c5b9b4105 Mon Sep 17 00:00:00 2001 |
2 | From: Christian Borntraeger <borntraeger@de.ibm.com> | |
3 | Date: Fri, 15 Dec 2017 13:14:31 +0100 | |
4 | Subject: KVM: s390: fix cmma migration for multiple memory slots | |
5 | ||
6 | From: Christian Borntraeger <borntraeger@de.ibm.com> | |
7 | ||
8 | commit 32aa144fc32abfcbf7140f473dfbd94c5b9b4105 upstream. | |
9 | ||
10 | When multiple memory slots are present the cmma migration code | |
11 | does not allocate enough memory for the bitmap. The memory slots | |
12 | are sorted in reverse order, so we must use gfn and size of | |
13 | slot[0] instead of the last one. | |
14 | ||
15 | Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> | |
16 | Reviewed-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> | |
17 | Fixes: 190df4a212a7 (KVM: s390: CMMA tracking, ESSA emulation, migration mode) | |
18 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | |
19 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
20 | ||
21 | --- | |
22 | arch/s390/kvm/kvm-s390.c | 9 +++++---- | |
23 | 1 file changed, 5 insertions(+), 4 deletions(-) | |
24 | ||
25 | --- a/arch/s390/kvm/kvm-s390.c | |
26 | +++ b/arch/s390/kvm/kvm-s390.c | |
27 | @@ -794,11 +794,12 @@ static int kvm_s390_vm_start_migration(s | |
28 | ||
29 | if (kvm->arch.use_cmma) { | |
30 | /* | |
31 | - * Get the last slot. They should be sorted by base_gfn, so the | |
32 | - * last slot is also the one at the end of the address space. | |
33 | - * We have verified above that at least one slot is present. | |
34 | + * Get the first slot. They are reverse sorted by base_gfn, so | |
35 | + * the first slot is also the one at the end of the address | |
36 | + * space. We have verified above that at least one slot is | |
37 | + * present. | |
38 | */ | |
39 | - ms = slots->memslots + slots->used_slots - 1; | |
40 | + ms = slots->memslots; | |
41 | /* round up so we only use full longs */ | |
42 | ram_pages = roundup(ms->base_gfn + ms->npages, BITS_PER_LONG); | |
43 | /* allocate enough bytes to store all the bits */ |