Explorar o código

KVM: MMU: Fix rmap_write_protect() hugepage iteration bug

rmap_next() does not work correctly after rmap_remove(), as it expects
the rmap chains not to change during iteration.  Fix (for now) by restarting
iteration from the beginning.

Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti %!s(int64=17) %!d(string=hai) anos
pai
achega
6597ca09e6
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      arch/x86/kvm/mmu.c

+ 1 - 0
arch/x86/kvm/mmu.c

@@ -640,6 +640,7 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
 			rmap_remove(kvm, spte);
 			rmap_remove(kvm, spte);
 			--kvm->stat.lpages;
 			--kvm->stat.lpages;
 			set_shadow_pte(spte, shadow_trap_nonpresent_pte);
 			set_shadow_pte(spte, shadow_trap_nonpresent_pte);
+			spte = NULL;
 			write_protected = 1;
 			write_protected = 1;
 		}
 		}
 		spte = rmap_next(kvm, rmapp, spte);
 		spte = rmap_next(kvm, rmapp, spte);