]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
KVM: MMU: fix mmu notifier invalidate handler for huge spte
authorAndrea Arcangeli <aarcange@redhat.com>
Fri, 16 Jul 2010 09:52:55 +0000 (11:52 +0200)
committerAvi Kivity <avi@redhat.com>
Mon, 2 Aug 2010 03:40:54 +0000 (06:40 +0300)
The index wasn't calculated correctly (off by one) for huge spte so KVM guest
was unstable with transparent hugepages.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reviewed-by: Reviewed-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/mmu.c

index 36c62f33513fb2d0f534c5bf63bfa709ab40d8a2..812770cddc8d5456f59056996531357cf9592c4f 100644 (file)
@@ -850,8 +850,12 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
                        ret = handler(kvm, &memslot->rmap[gfn_offset], data);
 
                        for (j = 0; j < KVM_NR_PAGE_SIZES - 1; ++j) {
-                               int idx = gfn_offset;
-                               idx /= KVM_PAGES_PER_HPAGE(PT_DIRECTORY_LEVEL + j);
+                               unsigned long idx;
+                               int sh;
+
+                               sh = KVM_HPAGE_GFN_SHIFT(PT_DIRECTORY_LEVEL+j);
+                               idx = ((memslot->base_gfn+gfn_offset) >> sh) -
+                                       (memslot->base_gfn >> sh);
                                ret |= handler(kvm,
                                        &memslot->lpage_info[j][idx].rmap_pde,
                                        data);