From patchwork Mon Mar 23 11:53:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 46182 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95EFD214B0 for ; Mon, 23 Mar 2015 11:55:28 +0000 (UTC) Received: by lams18 with SMTP id s18sf26810526lam.2 for ; Mon, 23 Mar 2015 04:55:27 -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=T8jULzF4Hz9uBc0Iax0llKgapjn9cOjFDLFQQ/+Vnls=; b=MBJegcJm5hoe5aS2mCiQpcsv3H9+iYXBK1osInJ2ZQ0IZLcNIRMoU8VLgUxtOnFRTB HaQVM+OmdLKxzQWK/w04jRPhEqzwwJ2UUstlTKAVTX59Mc+qBtIP1Yv/Z8t27JvsQcHE 0gsM7Oz3q59hjmzby6lVN7vKg1U+T4zpHTtKh/GxH9GqTcCpAy9TyzItpIiAgXEB+KtE IqbrM8yvMgZ3XcTL9jfQ6XeULuGXfggXVnc7UnUvI1Z/nlLBSjea7JqGR3xeA7sLlrJW MNTUvWEhf++CQefrGgUeQHv+UkZH46EimdStYGlPdn26AlgpBqde9WKj663MWYDj6aIF gucw== X-Gm-Message-State: ALoCoQmfeiH7juIl5AdbvlMUraPMXQSQcMiWdqvPtj4ixb98aTHgrTeqtRRIB2n2QNyvx7bgVpcy X-Received: by 10.112.97.37 with SMTP id dx5mr674101lbb.16.1427111727591; Mon, 23 Mar 2015 04:55:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.243.37 with SMTP id wv5ls688456lac.60.gmail; Mon, 23 Mar 2015 04:55:27 -0700 (PDT) X-Received: by 10.152.30.66 with SMTP id q2mr9152560lah.54.1427111727293; Mon, 23 Mar 2015 04:55:27 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id xl4si518026lac.1.2015.03.23.04.55.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 04:55:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lagg8 with SMTP id g8so132001845lag.1 for ; Mon, 23 Mar 2015 04:55:27 -0700 (PDT) X-Received: by 10.112.155.196 with SMTP id vy4mr4835145lbb.56.1427111727199; Mon, 23 Mar 2015 04:55:27 -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 k9csp776164lbq; Mon, 23 Mar 2015 04:55:26 -0700 (PDT) X-Received: by 10.70.38.136 with SMTP id g8mr211639813pdk.80.1427111723712; Mon, 23 Mar 2015 04:55:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id af4si766853pbc.122.2015.03.23.04.55.20; Mon, 23 Mar 2015 04:55:23 -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 S1752648AbbCWLzP (ORCPT + 27 others); Mon, 23 Mar 2015 07:55:15 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35993 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752288AbbCWLzH (ORCPT ); Mon, 23 Mar 2015 07:55:07 -0400 Received: by padcy3 with SMTP id cy3so189508983pad.3 for ; Mon, 23 Mar 2015 04:55:07 -0700 (PDT) X-Received: by 10.66.187.97 with SMTP id fr1mr12026232pac.157.1427111707077; Mon, 23 Mar 2015 04:55:07 -0700 (PDT) Received: from localhost.localdomain (61-205-5-195m5.grp1.mineo.jp. [61.205.5.195]) by mx.google.com with ESMTPSA id ok8sm799377pdb.66.2015.03.23.04.55.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Mar 2015 04:55: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: [RFC 2/4] arm64: kexec: fix kvm issue Date: Mon, 23 Mar 2015 20:53:57 +0900 Message-Id: <1427111639-4575-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427111639-4575-1-git-send-email-takahiro.akashi@linaro.org> References: <1427111639-4575-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.50 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 35c8bc0..b879cf6 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1103,6 +1104,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. */ @@ -1141,6 +1159,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