Merge tag 'kvm-ppc-fixes-4.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorRadim Krčmář <rkrcmar@redhat.com>
Tue, 4 Sep 2018 19:12:46 +0000 (21:12 +0200)
committerRadim Krčmář <rkrcmar@redhat.com>
Tue, 4 Sep 2018 19:12:46 +0000 (21:12 +0200)
PPC KVM fixes for 4.19

Two small fixes for KVM on POWER machines; one fixes a bug where pages
might not get marked dirty, causing guest memory corruption on migration,
and the other fixes a bug causing reads from guest memory to use the
wrong guest real address for very large HPT guests (>256G of memory),
leading to failures in instruction emulation.

1  2 
arch/powerpc/kvm/book3s_64_mmu_hv.c
arch/powerpc/kvm/book3s_64_mmu_radix.c

index 3c0e8fb2b773ebaf3bdfe404b2909d2d5ed48b4a,4c08f42f6406b3790c1152ef21e01b2a75a4d3cb..68e14afecac85b1d1fd0eff661f6a3aabe0217a6
@@@ -29,6 -29,7 +29,6 @@@
  #include <linux/file.h>
  #include <linux/debugfs.h>
  
 -#include <asm/tlbflush.h>
  #include <asm/kvm_ppc.h>
  #include <asm/kvm_book3s.h>
  #include <asm/book3s/64/mmu-hash.h>
@@@ -358,7 -359,7 +358,7 @@@ static int kvmppc_mmu_book3s_64_hv_xlat
        unsigned long pp, key;
        unsigned long v, orig_v, gr;
        __be64 *hptep;
-       int index;
+       long int index;
        int virtmode = vcpu->arch.shregs.msr & (data ? MSR_DR : MSR_IR);
  
        if (kvm_is_radix(vcpu->kvm))
index 0af1c0aea1fe659fca4723e17a02cc17eb8fa08f,7efc42538ccf6b0bb11e182fa955c91fd35c92de..fd6e8c13685f4c0223749647ad04c34a71ad4589
@@@ -66,7 -66,10 +66,7 @@@ int kvmppc_mmu_radix_xlate(struct kvm_v
        bits = root & RPDS_MASK;
        root = root & RPDB_MASK;
  
 -      /* P9 DD1 interprets RTS (radix tree size) differently */
        offset = rts + 31;
 -      if (cpu_has_feature(CPU_FTR_POWER9_DD1))
 -              offset -= 3;
  
        /* current implementations only support 52-bit space */
        if (offset != 52)
@@@ -157,7 -160,17 +157,7 @@@ static unsigned long kvmppc_radix_updat
                                      unsigned long clr, unsigned long set,
                                      unsigned long addr, unsigned int shift)
  {
 -      unsigned long old = 0;
 -
 -      if (!(clr & _PAGE_PRESENT) && cpu_has_feature(CPU_FTR_POWER9_DD1) &&
 -          pte_present(*ptep)) {
 -              /* have to invalidate it first */
 -              old = __radix_pte_update(ptep, _PAGE_PRESENT, 0);
 -              kvmppc_radix_tlbie_page(kvm, addr, shift);
 -              set |= _PAGE_PRESENT;
 -              old &= _PAGE_PRESENT;
 -      }
 -      return __radix_pte_update(ptep, clr, set) | old;
 +      return __radix_pte_update(ptep, clr, set);
  }
  
  void kvmppc_radix_set_pte_at(struct kvm *kvm, unsigned long addr,
@@@ -725,10 -738,10 +725,10 @@@ int kvm_unmap_radix(struct kvm *kvm, st
                                              gpa, shift);
                kvmppc_radix_tlbie_page(kvm, gpa, shift);
                if ((old & _PAGE_DIRTY) && memslot->dirty_bitmap) {
-                       unsigned long npages = 1;
+                       unsigned long psize = PAGE_SIZE;
                        if (shift)
-                               npages = 1ul << (shift - PAGE_SHIFT);
-                       kvmppc_update_dirty_map(memslot, gfn, npages);
+                               psize = 1ul << shift;
+                       kvmppc_update_dirty_map(memslot, gfn, psize);
                }
        }
        return 0;