[RFC PATCH v4 8/9] kvm, vmx: Add atomic synchronization with CPU Hotplug
preempt_disable() will no longer help prevent CPUs from going offline, once stop_machine() gets removed from the CPU offline path. So use get/put_online_cpus_atomic() in vmx_vcpu_load() to prevent CPUs from going offline while clearing vmcs. Reported-by: Michael Wang Debugged-by: Xiao Guangrong Signed-off-by: Srivatsa S. Bhat --- arch/x86/kvm/vmx.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f858159..d8a4cf1 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1519,10 +1519,14 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) struct vcpu_vmx *vmx = to_vmx(vcpu); u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); - if (!vmm_exclusive) + if (!vmm_exclusive) { kvm_cpu_vmxon(phys_addr); - else if (vmx->loaded_vmcs->cpu != cpu) + } else if (vmx->loaded_vmcs->cpu != cpu) { + /* Prevent any CPU from going offline */ + get_online_cpus_atomic(); loaded_vmcs_clear(vmx->loaded_vmcs); + put_online_cpus_atomic(); + } if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) { per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH v4 8/9] kvm, vmx: Add atomic synchronization with CPU Hotplug
preempt_disable() will no longer help prevent CPUs from going offline, once stop_machine() gets removed from the CPU offline path. So use get/put_online_cpus_atomic() in vmx_vcpu_load() to prevent CPUs from going offline while clearing vmcs. Reported-by: Michael Wang wang...@linux.vnet.ibm.com Debugged-by: Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com --- arch/x86/kvm/vmx.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f858159..d8a4cf1 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1519,10 +1519,14 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) struct vcpu_vmx *vmx = to_vmx(vcpu); u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); - if (!vmm_exclusive) + if (!vmm_exclusive) { kvm_cpu_vmxon(phys_addr); - else if (vmx-loaded_vmcs-cpu != cpu) + } else if (vmx-loaded_vmcs-cpu != cpu) { + /* Prevent any CPU from going offline */ + get_online_cpus_atomic(); loaded_vmcs_clear(vmx-loaded_vmcs); + put_online_cpus_atomic(); + } if (per_cpu(current_vmcs, cpu) != vmx-loaded_vmcs-vmcs) { per_cpu(current_vmcs, cpu) = vmx-loaded_vmcs-vmcs; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/