From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Mon, 24 Feb 2014 13:59:32 -0300
Subject: KVM: MMU: drop read-only large sptes when creating lower level sptes
Git-commit: 404381c5839d67aa0c275ad1da96ef3d3928ca2c
Patch-mainline: v3.14-rc5
References: bsc#1117665

Read-only large sptes can be created due to read-only faults as
follows:

- QEMU pagetable entry that maps guest memory is read-only
due to COW.
- Guest read faults such memory, COW is not broken, because
it is a read-only fault.
- Enable dirty logging, large spte not nuked because it is read-only.
- Write-fault on such memory causes guest to loop endlessly
(which must go down to level 1 because dirty logging is enabled).

Fix by dropping large spte when necessary.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
---
 arch/x86/kvm/mmu.c | 1 +
 1 file changed, 1 insertion(+)

--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2294,6 +2294,7 @@ static int __direct_map(struct kvm_vcpu
 			break;
 		}
 
+		drop_large_spte(vcpu, iterator.sptep);
 		if (*iterator.sptep == shadow_trap_nonpresent_pte) {
 			u64 base_addr = iterator.addr;
 
