]> git.hungrycats.org Git - linux/commitdiff
KVM: MMU: handle large host sptes on invlpg/resync
authorMarcelo Tosatti <mtosatti@redhat.com>
Mon, 23 Mar 2009 20:51:33 +0000 (17:51 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 2 May 2009 17:57:10 +0000 (10:57 -0700)
(cherry picked from 87917239204d67a316cb89751750f86c9ed3640b)

The invlpg and sync walkers lack knowledge of large host sptes,
descending to non-existant pagetable level.

Stop at directory level in such case.

Fixes SMP Windows XP with hugepages.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/mmu.c
arch/x86/kvm/paging_tmpl.h

index 0d2918632b88d522fce53dfba67dc1cc02d95706..c3c0191b37ff711be4e7d75579b801f9c3c2ce7c 100644 (file)
@@ -981,7 +981,7 @@ static int mmu_unsync_walk(struct kvm_mmu_page *sp,
        for_each_unsync_children(sp->unsync_child_bitmap, i) {
                u64 ent = sp->spt[i];
 
-               if (is_shadow_present_pte(ent)) {
+               if (is_shadow_present_pte(ent) && !is_large_pte(ent)) {
                        struct kvm_mmu_page *child;
                        child = page_header(ent & PT64_BASE_ADDR_MASK);
 
index 84eee43bbe742b005bd1825b0cdac24ba5efffbb..9b5355ef980fa2145959418b3e6124751706005c 100644 (file)
@@ -467,9 +467,13 @@ static int FNAME(shadow_invlpg_entry)(struct kvm_shadow_walk *_sw,
                                      u64 *sptep, int level)
 {
 
-       if (level == PT_PAGE_TABLE_LEVEL) {
-               if (is_shadow_present_pte(*sptep))
+       if (level == PT_PAGE_TABLE_LEVEL ||
+           ((level == PT_DIRECTORY_LEVEL) && is_large_pte(*sptep))) {
+               if (is_shadow_present_pte(*sptep)) {
                        rmap_remove(vcpu->kvm, sptep);
+                       if (is_large_pte(*sptep))
+                               --vcpu->kvm->stat.lpages;
+               }
                set_shadow_pte(sptep, shadow_trap_nonpresent_pte);
                return 1;
        }