From eae5ecb5b9043812968fae7ad9d74bf5e7a50245 Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi@qumranet.com>
Date: Sun, 30 Sep 2007 10:50:12 +0200
Subject: [PATCH] KVM: VMX: Don't clear the vmcs if the vcpu is not loaded on
 any processor

Noted by Eddie Dong.

Signed-off-by: Avi Kivity <avi@qumranet.com>
---
 drivers/kvm/vmx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 27a3318fa6c..cc2844203c2 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -225,7 +225,9 @@ static void __vcpu_clear(void *arg)
 
 static void vcpu_clear(struct vcpu_vmx *vmx)
 {
-	if (vmx->vcpu.cpu != raw_smp_processor_id() && vmx->vcpu.cpu != -1)
+	if (vmx->vcpu.cpu == -1)
+		return;
+	if (vmx->vcpu.cpu != raw_smp_processor_id())
 		smp_call_function_single(vmx->vcpu.cpu, __vcpu_clear,
 					 vmx, 0, 1);
 	else
-- 
2.20.1