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: 46344 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1F5DB21584 for ; Thu, 26 Mar 2015 08:27:06 +0000 (UTC) Received: by wgqa9 with SMTP id a9sf2937750wgq.2 for ; Thu, 26 Mar 2015 01:27:05 -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=m3PWYSzHXSz0U5LhSl+I0eOVa59laUSd/82pYMx74F+xRxaOfasJOVWwtP7x5UoOVa BVq6IVWSal7n9dK3tn5i3dXk4wXMPKSwcSSyZdyOatngCSi/uCrPX7xDso7OidNV4q04 61np60OAAQKlPXHeE9Th5pZZkRb0xeND5QlU83V6PVXxQk4aW6E/mwZxLXdOpUvi8q+S 37ac8mvC5hYMhSeEnBhe5qW2jBt+qvVqgvPQBW5JOCHvFw6jiOKgyl84gVzA3dvhatOP EnXgmHta7qTNIm/M0k2bXmQQaDkYhOIpgNmNLGTcEq08oovURgkJc92nlSh7+UwmF/Am pAgg== X-Gm-Message-State: ALoCoQn12irUjGS5RojPzsd5oTzoli1LnG2F5mndJY1FLAITT4Nwd8QNlvydYshHEDNTQZlj2EJo X-Received: by 10.112.180.74 with SMTP id dm10mr3081005lbc.11.1427358425395; Thu, 26 Mar 2015 01:27:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.70 with SMTP id v6ls166417laz.2.gmail; Thu, 26 Mar 2015 01:27:05 -0700 (PDT) X-Received: by 10.112.85.10 with SMTP id d10mr9845095lbz.62.1427358425187; Thu, 26 Mar 2015 01:27:05 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id z6si3992108lbn.106.2015.03.26.01.27.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2015 01:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lahp7 with SMTP id p7so20598593lah.2 for ; Thu, 26 Mar 2015 01:27:05 -0700 (PDT) X-Received: by 10.152.121.33 with SMTP id lh1mr12253865lab.86.1427358425088; Thu, 26 Mar 2015 01:27:05 -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 k9csp455358lbq; Thu, 26 Mar 2015 01:27:04 -0700 (PDT) X-Received: by 10.69.17.231 with SMTP id gh7mr24204796pbd.169.1427358423355; Thu, 26 Mar 2015 01:27:03 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si4999132pdo.183.2015.03.26.01.27.01; Thu, 26 Mar 2015 01:27:03 -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 S1752171AbbCZI04 (ORCPT + 27 others); Thu, 26 Mar 2015 04:26:56 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:36510 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbbCZI0v (ORCPT ); Thu, 26 Mar 2015 04:26:51 -0400 Received: by pdbcz9 with SMTP id cz9so55776294pdb.3 for ; Thu, 26 Mar 2015 01:26:50 -0700 (PDT) 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 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: [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> 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.215.54 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