diff mbox

[1/2] KVM: VMX: fix invalid cpu passed to smp_call_function_single

Message ID 50B6093B.7040404@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong Nov. 28, 2012, 12:53 p.m. UTC
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(-)

Comments

Marcelo Tosatti Nov. 29, 2012, 12:06 a.m. UTC | #1
On Wed, Nov 28, 2012 at 08:53:15PM +0800, Xiao Guangrong wrote:
> 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(-)

Applied, thanks.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)