From patchwork Thu Apr 2 05:40:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 46701 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0E94F216D1 for ; Thu, 2 Apr 2015 05:41:21 +0000 (UTC) Received: by lbbug6 with SMTP id ug6sf14940347lbb.3 for ; Wed, 01 Apr 2015 22:41:20 -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=+62SguYwE9jztt6oUy8U2ZZuOh7/hqmj0dmwNEROvrQ=; b=iu0OhTKetpY4ovEgki2MbWJXc8xpx2Fxk0uVCX75V8N83r7N9unFfpkyeEo8Qm8+a4 imGkopklm0wINo/edrIU6zQYw22IW2Rdzc7vswaoE5G9I0TsV6md06YO60h667dvk2vp aIFGg8j71ChQ4PzOuOp5/CNhNEN0log4HJ7xX76X7AuOaUZ1yp0HEKRChiCYcQm8iTbX E+W7ghPb7ETsKcJcRTniH7RzGcNIwpWG6KjuTN4COO9BmnIegIhqszR3wBi3iyxGCR3J r0KC0czMeSJKADbM6qmIu9ZA6yqGM4Qx89aSl9zxyOLNmvlrZtZAWabxPVbqKAYC/L0Q bj2g== X-Gm-Message-State: ALoCoQl95Uql/BKWQQ2tthzlrdN52tnVTZF3xAjbKaxuCQcdX5o91MbdhbwXLpFrFYnBq7X2sSz9 X-Received: by 10.152.19.67 with SMTP id c3mr10347746lae.7.1427953280010; Wed, 01 Apr 2015 22:41:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.200 with SMTP id d8ls146653laa.34.gmail; Wed, 01 Apr 2015 22:41:19 -0700 (PDT) X-Received: by 10.112.167.228 with SMTP id zr4mr7780919lbb.113.1427953279836; Wed, 01 Apr 2015 22:41:19 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id x8si3329248lax.123.2015.04.01.22.41.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 22:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lboc7 with SMTP id c7so51735981lbo.1 for ; Wed, 01 Apr 2015 22:41:19 -0700 (PDT) X-Received: by 10.152.197.34 with SMTP id ir2mr12398687lac.36.1427953279267; Wed, 01 Apr 2015 22:41:19 -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.57.201 with SMTP id k9csp1110276lbq; Wed, 1 Apr 2015 22:41:18 -0700 (PDT) X-Received: by 10.68.240.40 with SMTP id vx8mr50847796pbc.27.1427953277180; Wed, 01 Apr 2015 22:41:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ry1si5920419pab.199.2015.04.01.22.41.15; Wed, 01 Apr 2015 22:41:17 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1752673AbbDBFlM (ORCPT + 27 others); Thu, 2 Apr 2015 01:41:12 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:36795 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752484AbbDBFlG (ORCPT ); Thu, 2 Apr 2015 01:41:06 -0400 Received: by pdea3 with SMTP id a3so27183549pde.3 for ; Wed, 01 Apr 2015 22:41:06 -0700 (PDT) X-Received: by 10.66.167.232 with SMTP id zr8mr83432272pab.23.1427953266461; Wed, 01 Apr 2015 22:41:06 -0700 (PDT) Received: from localhost.localdomain (61-205-5-51m5.grp1.mineo.jp. [61.205.5.51]) by mx.google.com with ESMTPSA id hb6sm3854757pbd.88.2015.04.01.22.41.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 22:41:05 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, mark.rutland@arm.com Cc: christoffer.dall@linaro.org, geoff@infradead.org, broonie@kernel.org, david.griego@linaro.org, freddy77@gmail.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [v3 2/5] arm64: kvm: allow EL2 context to be reset on shutdown Date: Thu, 2 Apr 2015 14:40:13 +0900 Message-Id: <1427953216-11737-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427953216-11737-1-git-send-email-takahiro.akashi@linaro.org> References: <1427953216-11737-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@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.178 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: , 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