diff options
author | Radim Krčmář <rkrcmar@redhat.com> | 2018-01-06 11:26:37 -0500 |
---|---|---|
committer | Radim Krčmář <rkrcmar@redhat.com> | 2018-01-06 11:26:37 -0500 |
commit | bb4945e60dd0b5afb0e92bc8006ce560948fbc39 (patch) | |
tree | f36c0f1d00219c376d8ce3ada92e32ba0ec97eb9 | |
parent | 0cb5b30698fdc8f6b4646012e3acb4ddce430788 (diff) | |
parent | c2cf265d860882b51a200e4a7553c17827f2b730 (diff) |
Merge tag 'kvm-s390-master-4.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux
KVM: s390: fixes for cmma migration
Two fixes for potential bitmap overruns in the cmma migration
code.
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 9 | ||||
-rw-r--r-- | arch/s390/kvm/priv.c | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index ec8b68e97d3c..2c93cbbcd15e 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -792,11 +792,12 @@ static int kvm_s390_vm_start_migration(struct kvm *kvm) | |||
792 | 792 | ||
793 | if (kvm->arch.use_cmma) { | 793 | if (kvm->arch.use_cmma) { |
794 | /* | 794 | /* |
795 | * Get the last slot. They should be sorted by base_gfn, so the | 795 | * Get the first slot. They are reverse sorted by base_gfn, so |
796 | * last slot is also the one at the end of the address space. | 796 | * the first slot is also the one at the end of the address |
797 | * We have verified above that at least one slot is present. | 797 | * space. We have verified above that at least one slot is |
798 | * present. | ||
798 | */ | 799 | */ |
799 | ms = slots->memslots + slots->used_slots - 1; | 800 | ms = slots->memslots; |
800 | /* round up so we only use full longs */ | 801 | /* round up so we only use full longs */ |
801 | ram_pages = roundup(ms->base_gfn + ms->npages, BITS_PER_LONG); | 802 | ram_pages = roundup(ms->base_gfn + ms->npages, BITS_PER_LONG); |
802 | /* allocate enough bytes to store all the bits */ | 803 | /* allocate enough bytes to store all the bits */ |
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c index 572496c688cc..0714bfa56da0 100644 --- a/arch/s390/kvm/priv.c +++ b/arch/s390/kvm/priv.c | |||
@@ -1006,7 +1006,7 @@ static inline int do_essa(struct kvm_vcpu *vcpu, const int orc) | |||
1006 | cbrlo[entries] = gfn << PAGE_SHIFT; | 1006 | cbrlo[entries] = gfn << PAGE_SHIFT; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | if (orc) { | 1009 | if (orc && gfn < ms->bitmap_size) { |
1010 | /* increment only if we are really flipping the bit to 1 */ | 1010 | /* increment only if we are really flipping the bit to 1 */ |
1011 | if (!test_and_set_bit(gfn, ms->pgste_bitmap)) | 1011 | if (!test_and_set_bit(gfn, ms->pgste_bitmap)) |
1012 | atomic64_inc(&ms->dirty_pages); | 1012 | atomic64_inc(&ms->dirty_pages); |