From patchwork Fri Apr 24 05:27:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47500 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 859E920553 for ; Fri, 24 Apr 2015 05:30:52 +0000 (UTC) Received: by lbos2 with SMTP id s2sf8836723lbo.2 for ; Thu, 23 Apr 2015 22:30:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Iy3DVPLF5c6HaAwOFjCBEj/elEZLTDJPHUaTrnRhs5M=; b=d2rGX3s3vNxuZ/usPyy5kHSAae7Df2umcYnqHC3NsAAsvuoD2hOujf9OuBmXb/t9SH dKTShMPTO5ARj/Qh30bpbcg376S8KQHFRnk+cXQrvkME7cKuIUdveib/Kt06KtOVgRMV SFxWOb+a+/149IoGBs9xpwuxfb+ANp0jCPV9ypuvD+sHQgKIOwk4EKWOI5ebjfUI5B0b mQCl9BCwkrl/x9YbvXtr2BLQNn804SfmsotBCV0JURfK84mauUrfmh+EukhXEHmWKIGx mVKO5pgAP2rcGecnTMW4TMIg8fOrOIFkrGSX+QneURFR4SZLDIg9q6xD6ToJa9qGSw5W awLw== X-Gm-Message-State: ALoCoQm+ttD6If2tgbfr5vPhKrzIkEmcixy7ao994ON0YfomAWmCY1JoomqiFnPlA2SXCL6txRK4 X-Received: by 10.180.11.101 with SMTP id p5mr156616wib.3.1429853451407; Thu, 23 Apr 2015 22:30:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.70 with SMTP id le6ls456376lac.50.gmail; Thu, 23 Apr 2015 22:30:51 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr5423825lbb.36.1429853451246; Thu, 23 Apr 2015 22:30:51 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ut15si7466538lbb.101.2015.04.23.22.30.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbzk7 with SMTP id zk7so28595031lbb.0 for ; Thu, 23 Apr 2015 22:30:51 -0700 (PDT) X-Received: by 10.152.19.199 with SMTP id h7mr5623056lae.32.1429853451144; Thu, 23 Apr 2015 22:30:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp977363lbt; Thu, 23 Apr 2015 22:30:50 -0700 (PDT) X-Received: by 10.66.102.34 with SMTP id fl2mr11609451pab.40.1429853449323; Thu, 23 Apr 2015 22:30:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.30.48; Thu, 23 Apr 2015 22:30:49 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754518AbbDXFas (ORCPT + 2 others); Fri, 24 Apr 2015 01:30:48 -0400 Received: from mail-oi0-f51.google.com ([209.85.218.51]:35427 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754417AbbDXFar (ORCPT ); Fri, 24 Apr 2015 01:30:47 -0400 Received: by oign205 with SMTP id n205so32375678oig.2 for ; Thu, 23 Apr 2015 22:30:47 -0700 (PDT) X-Received: by 10.202.78.66 with SMTP id c63mr5452478oib.0.1429853446992; Thu, 23 Apr 2015 22:30:46 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id ke9sm6080913obb.9.2015.04.23.22.30.44 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:30:45 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Lorenzo Pieralisi Subject: [PATCH for 3.12.y stable 15/63] arm: kvm: implement CPU PM notifier Date: Fri, 24 Apr 2015 13:27:13 +0800 Message-Id: <1429853281-6136-16-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Lorenzo Pieralisi commit 1fcf7ce0c60213994269fb59569ec161eb6e08d6 upstream. Upon CPU shutdown and consequent warm-reboot, the hypervisor CPU state must be re-initialized. This patch implements a CPU PM notifier that upon warm-boot calls a KVM hook to reinitialize properly the hypervisor state so that the CPU can be safely resumed. Acked-by: Marc Zyngier Acked-by: Christoffer Dall Signed-off-by: Lorenzo Pieralisi Signed-off-by: Shannon Zhao --- arch/arm/kvm/arm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 78ee10b..64ec98b 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -857,6 +858,33 @@ static struct notifier_block hyp_init_cpu_nb = { .notifier_call = hyp_init_cpu_notify, }; +#ifdef CONFIG_CPU_PM +static int hyp_init_cpu_pm_notifier(struct notifier_block *self, + unsigned long cmd, + void *v) +{ + if (cmd == CPU_PM_EXIT) { + cpu_init_hyp_mode(NULL); + return NOTIFY_OK; + } + + return NOTIFY_DONE; +} + +static struct notifier_block hyp_init_cpu_pm_nb = { + .notifier_call = hyp_init_cpu_pm_notifier, +}; + +static void __init hyp_cpu_pm_init(void) +{ + cpu_pm_register_notifier(&hyp_init_cpu_pm_nb); +} +#else +static inline void hyp_cpu_pm_init(void) +{ +} +#endif + /** * Inits Hyp-mode on all online CPUs */ @@ -1017,6 +1045,8 @@ int kvm_arch_init(void *opaque) goto out_err; } + hyp_cpu_pm_init(); + kvm_coproc_table_init(); return 0; out_err: