Skip to content

Commit

Permalink
KVM: VMX: fix invalid cpu passed to smp_call_function_single
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Xiao Guangrong authored and Marcelo Tosatti committed Nov 29, 2012
1 parent 859f845 commit e6c7d32
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e6c7d32

Please sign in to comment.