KVM: VMX: fix tlb flush with invalid root
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Sat, 3 Jul 2010 08:02:42 +0000 (16:02 +0800)
committerAvi Kivity <avi@redhat.com>
Mon, 2 Aug 2010 03:40:16 +0000 (06:40 +0300)
Commit 341d9b535b6c simplify reload logic while entry guest mode, it
can avoid unnecessary sync-root if KVM_REQ_MMU_RELOAD and
KVM_REQ_MMU_SYNC both set.

But, it cause a issue that when we handle 'KVM_REQ_TLB_FLUSH', the
root is invalid, it is triggered during my test:

Kernel BUG at ffffffffa00212b8 [verbose debug info unavailable]
......

Fixed by directly return if the root is not ready.

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c
arch/x86/kvm/vmx.c

index 50c79b9f5c3889039dee07576615bcf5b16e78a4..502e53f999cf28a25cc2b00f1766bd1ffb2f9ed2 100644 (file)
@@ -40,6 +40,8 @@
                                  0xFFFFFF0000000000ULL)
 
 #define INVALID_PAGE (~(hpa_t)0)
+#define VALID_PAGE(x) ((x) != INVALID_PAGE)
+
 #define UNMAPPED_GVA (~(gpa_t)0)
 
 /* KVM Hugepage definitions for x86 */
index a20fd613acfe5afd1a65cf14d11c30c25be9b324..70cdf6876b5f92397820bc7d9c65529333f413cc 100644 (file)
@@ -92,8 +92,6 @@ module_param(oos_shadow, bool, 0644);
 #define PT_FIRST_AVAIL_BITS_SHIFT 9
 #define PT64_SECOND_AVAIL_BITS_SHIFT 52
 
-#define VALID_PAGE(x) ((x) != INVALID_PAGE)
-
 #define PT64_LEVEL_BITS 9
 
 #define PT64_LEVEL_SHIFT(level) \
index 4dfb1dc09c88541621fc89a5a6a2d0596d209e3b..2fdcc9819f36bc5faab15853a984af16587c0de5 100644 (file)
@@ -1828,8 +1828,11 @@ static void exit_lmode(struct kvm_vcpu *vcpu)
 static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
 {
        vpid_sync_context(to_vmx(vcpu));
-       if (enable_ept)
+       if (enable_ept) {
+               if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
+                       return;
                ept_sync_context(construct_eptp(vcpu->arch.mmu.root_hpa));
+       }
 }
 
 static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu)