From patchwork Wed Dec 5 18:44:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 1842731 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 92A44DF266 for ; Wed, 5 Dec 2012 18:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754028Ab2LESqT (ORCPT ); Wed, 5 Dec 2012 13:46:19 -0500 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:55161 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753734Ab2LESqR (ORCPT ); Wed, 5 Dec 2012 13:46:17 -0500 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Dec 2012 04:43:16 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 6 Dec 2012 04:43:13 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 8CCE1357804C; Thu, 6 Dec 2012 05:46:11 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qB5IZMR859965466; Thu, 6 Dec 2012 05:35:22 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qB5Ik8U7004271; Thu, 6 Dec 2012 05:46:11 +1100 Received: from srivatsabhat.in.ibm.com ([9.79.249.130]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qB5Ik2TA004192; Thu, 6 Dec 2012 05:46:03 +1100 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v2 09/10] kvm, vmx: Add full atomic synchronization with CPU Hotplug To: tglx@linutronix.de, peterz@infradead.org, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, vincent.guittot@linaro.org, tj@kernel.org, oleg@redhat.com Cc: sbw@mit.edu, amit.kucheria@linaro.org, rostedt@goodmis.org, rjw@sisk.pl, srivatsa.bhat@linux.vnet.ibm.com, wangyun@linux.vnet.ibm.com, xiaoguangrong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 06 Dec 2012 00:14:44 +0530 Message-ID: <20121205184439.3750.75187.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20121205184041.3750.64945.stgit@srivatsabhat.in.ibm.com> References: <20121205184041.3750.64945.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12120518-7014-0000-0000-0000024D8414 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_full() in vmx_vcpu_load() to prevent CPUs from going offline while clearing vmcs. Here we truly need full-synchronization with CPU hotplug (and not just an unchanging cpu_online_mask), because we want to prevent race with the CPU_DYING callback from kvm. 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(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f858159..23c1063 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_full(); loaded_vmcs_clear(vmx->loaded_vmcs); + put_online_cpus_atomic_full(); + } if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) { per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs;