From patchwork Thu Jul 9 09:23:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 6754351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 53CD29F2F0 for ; Thu, 9 Jul 2015 09:26:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 743572058E for ; Thu, 9 Jul 2015 09:26:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E9FA20585 for ; Thu, 9 Jul 2015 09:26:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZD83Z-0007NM-8H; Thu, 09 Jul 2015 09:23:49 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZD83X-0007Bu-0Y for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2015 09:23:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE4A875; Thu, 9 Jul 2015 02:23:49 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 60CFD3F23A; Thu, 9 Jul 2015 02:23:23 -0700 (PDT) From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: kvm: prevent freeing boot_hyp_pgd when CPU_PM is selected Date: Thu, 9 Jul 2015 10:23:55 +0100 Message-Id: <1436433835-26030-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.2.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150709_022347_059357_390798F8 X-CRM114-Status: UNSURE ( 9.69 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.6 (-------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Lorenzo Pieralisi , Christoffer Dall , Sudeep Holla MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The boot_hyp_pgd is required to install HYP context through cpu_init_hyp_mode, on cold-boot for primary and secondary cpus, but also on the warm-boot path for secondaries (ie when a CPU is hotplugged in). On platforms with power management capabilities (eg suspend to RAM or idle-states that allow the core to enter deep idle where core is shutdown on power down entry), the boot_hyp_pgd is required to restore HYP context too upon CPU_PM notification, so the boot_hyp_pgd must not be freed to guarantee a proper HYP context restore, which in turn ensures proper core resume from low-power. This patch adds an additional guard to free_boot_hyp_pgd() to remove its call from the kernel if CPU_PM is enabled, so that on platforms where HOTPLUG_CPU is disabled (eg UP), CPU_PM operations (suspend and CPUidle) are still guaranteed to function. Signed-off-by: Lorenzo Pieralisi Cc: Christoffer Dall Cc: Marc Zyngier Cc: Sudeep Holla Acked-by: Christoffer Dall --- arch/arm/kvm/arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index bc738d2..5e050c2 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -1068,7 +1068,7 @@ static int init_hyp_mode(void) if (err) goto out_free_mappings; -#ifndef CONFIG_HOTPLUG_CPU +#if !defined(CONFIG_HOTPLUG_CPU) && !defined(CONFIG_CPU_PM) free_boot_hyp_pgd(); #endif