kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: VMX: fix invalid cpu passed to smp_call_function_single
@ 2012-11-28 12:53 Xiao Guangrong
  2012-11-28 12:54 ` [PATCH 2/2] KVM: VMX: fix memory order between loading vmcs and clearing vmcs Xiao Guangrong
  2012-11-29  0:06 ` [PATCH 1/2] KVM: VMX: fix invalid cpu passed to smp_call_function_single Marcelo Tosatti
  0 siblings, 2 replies; 7+ messages in thread
From: Xiao Guangrong @ 2012-11-28 12:53 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, Gleb Natapov, LKML, KVM

In loaded_vmcs_clear, loaded_vmcs->cpu is the fist parameter passed to
smp_call_function_single, if the target cpu is downing (doing cpu hot remove),
loaded_vmcs->cpu can become -1 then -1 is passed to smp_call_function_single

It can be triggered when vcpu is being destroyed, loaded_vmcs_clear is called
in the preemptionable context

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/vmx.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 6599e45..29e8f42 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1007,9 +1007,11 @@ static void __loaded_vmcs_clear(void *arg)

 static void loaded_vmcs_clear(struct loaded_vmcs *loaded_vmcs)
 {
-	if (loaded_vmcs->cpu != -1)
-		smp_call_function_single(
-			loaded_vmcs->cpu, __loaded_vmcs_clear, loaded_vmcs, 1);
+	int cpu = loaded_vmcs->cpu;
+
+	if (cpu != -1)
+		smp_call_function_single(cpu,
+			 __loaded_vmcs_clear, loaded_vmcs, 1);
 }

 static inline void vpid_sync_vcpu_single(struct vcpu_vmx *vmx)
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-11-29 23:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28 12:53 [PATCH 1/2] KVM: VMX: fix invalid cpu passed to smp_call_function_single Xiao Guangrong
2012-11-28 12:54 ` [PATCH 2/2] KVM: VMX: fix memory order between loading vmcs and clearing vmcs Xiao Guangrong
2012-11-29  0:04   ` Marcelo Tosatti
2012-11-29  2:04     ` Xiao Guangrong
2012-11-29  3:06     ` Xiao Guangrong
2012-11-29 23:15   ` Marcelo Tosatti
2012-11-29  0:06 ` [PATCH 1/2] KVM: VMX: fix invalid cpu passed to smp_call_function_single Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).