From patchwork Thu Mar 26 08:25:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 6096831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B876CBF90F for ; Thu, 26 Mar 2015 08:32:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD98A203EC for ; Thu, 26 Mar 2015 08:32:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EAED22010C for ; Thu, 26 Mar 2015 08:32:12 +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 1Yb3A3-0002h8-6x; Thu, 26 Mar 2015 08:29:07 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb38G-0001m9-QX for linux-arm-kernel@bombadil.infradead.org; Thu, 26 Mar 2015 08:27:17 +0000 Received: from mail-pd0-f178.google.com ([209.85.192.178]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb38D-0003cR-8Z for linux-arm-kernel@lists.infradead.org; Thu, 26 Mar 2015 08:27:14 +0000 Received: by pdbni2 with SMTP id ni2so55860853pdb.1 for ; Thu, 26 Mar 2015 01:26:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9BcsgzZgf0v8HMg8/RAfNwopoEXiWfS7NqvlKOjTHKQ=; b=RWOOeuXbvfrFmOaeSvB2VE7lwTi+30buiSXHE/KlKaV/G9PknU2bumelU3C1o+WqKa 9gR/Nihj7zgjxGi9oRckzT6Im0pqd3Meq18ORtgaY5SGaO31ZEO43srIk3A/1aXrvLY0 h/N/3WjsNJCl7tknP5txWtSm0LCtLslzY5lQLgs7VPKB6DQtFKEkwvwxKBwIjLPxVFhT teUiesRRAdFrxaZ5RgxvWk2S41pu1zfIvAlMy647GF9c3wADOXdu3FkcAk5P2wRyPgW5 +uQYDKmnbVQPi28STy2gIQ3Qt2VAR/lxDuuFm8cfnUaFIbX9ZD7q3OE7B3c1kLUJcyLR 63qw== X-Gm-Message-State: ALoCoQnh9D4+xa8C9MeT2NpbEgYX/JWYIsITsNpFJg/IwfNPIkW3vwMbrYe/ZQmtQmzzw6QyNd2q X-Received: by 10.66.140.69 with SMTP id re5mr24813412pab.105.1427358410717; Thu, 26 Mar 2015 01:26:50 -0700 (PDT) Received: from localhost.localdomain (61-205-2-129m5.grp1.mineo.jp. [61.205.2.129]) by mx.google.com with ESMTPSA id xz1sm4722152pbb.47.2015.03.26.01.26.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2015 01:26:49 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, mark.rutland@arm.com Subject: [RFC v2 2/5] arm64: kvm: allow EL2 context to be reset on shutdown Date: Thu, 26 Mar 2015 17:25:23 +0900 Message-Id: <1427358326-3708-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427358326-3708-1-git-send-email-takahiro.akashi@linaro.org> References: <1427358326-3708-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150326_082713_449458_79211908 X-CRM114-Status: GOOD ( 17.44 ) X-Spam-Score: -2.6 (--) Cc: linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, geoff@infradead.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , broonie@kernel.org, david.griego@linaro.org, christoffer.dall@linaro.org, freddy77@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 current kvm implementation keeps EL2 vector table installed even when the system is shut down. This prevents kexec from putting the system with kvm back into EL2 when starting a new kernel. This patch resolves this issue by calling a cpu tear-down function via reboot notifier, kvm_reboot_notify(), which is invoked by kernel_restart_prepare() in kernel_kexec(). While kvm has a generic hook, kvm_reboot(), we can't use it here because a cpu teardown function will not be invoked, under current implementation, if no guest vm has been created by kvm_create_vm(). Please note that kvm_usage_count is zero in this case. We'd better, in the future, implement cpu hotplug support and put the arch-specific initialization into kvm_arch_hardware_enable/disable(). This way, we would be able to revert this patch. Signed-off-by: AKASHI Takahiro --- arch/arm/kvm/arm.c | 21 +++++++++++++++++++++ arch/arm64/kvm/Kconfig | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 39df694..f64713e 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1100,6 +1101,23 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr) return NULL; } +static int kvm_reboot_notify(struct notifier_block *nb, + unsigned long val, void *v) +{ + /* + * Reset each CPU in EL2 to initial state. + */ + on_each_cpu(kvm_cpu_reset, NULL, 1); + + return NOTIFY_DONE; +} + +static struct notifier_block kvm_reboot_nb = { + .notifier_call = kvm_reboot_notify, + .next = NULL, + .priority = 0, /* FIXME */ +}; + /** * Initialize Hyp-mode and memory mappings on all CPUs. */ @@ -1138,6 +1156,9 @@ int kvm_arch_init(void *opaque) hyp_cpu_pm_init(); kvm_coproc_table_init(); + + register_reboot_notifier(&kvm_reboot_nb); + return 0; out_err: cpu_notifier_register_done(); diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index 30ae7a7..f5590c8 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -18,7 +18,6 @@ if VIRTUALIZATION config KVM bool "Kernel-based Virtual Machine (KVM) support" - depends on !KEXEC select MMU_NOTIFIER select PREEMPT_NOTIFIERS select ANON_INODES