From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 2/5] arm64: kvm: allow EL2 context to be reset on shutdown
Date: Thu, 26 Mar 2015 17:25:23 +0900 [thread overview]
Message-ID: <1427358326-3708-3-git-send-email-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <1427358326-3708-1-git-send-email-takahiro.akashi@linaro.org>
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 <takahiro.akashi@linaro.org>
---
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 <linux/vmalloc.h>
#include <linux/fs.h>
#include <linux/mman.h>
+#include <linux/reboot.h>
#include <linux/sched.h>
#include <linux/kvm.h>
#include <trace/events/kvm.h>
@@ -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
--
1.7.9.5
next prev parent reply other threads:[~2015-03-26 8:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 8:25 [RFC v2 0/5] arm64: kvm: reset hyp context for kexec AKASHI Takahiro
2015-03-26 8:25 ` [RFC v2 1/5] arm64: kvm: add a cpu tear-down function AKASHI Takahiro
2015-03-26 8:25 ` AKASHI Takahiro [this message]
2015-03-26 8:25 ` [RFC v2 3/5] arm64: kvm: add cpu reset hook for cpu hotplug AKASHI Takahiro
2015-03-26 8:25 ` [RFC v2 4/5] arm64: kvm: add cpu reset at module exit AKASHI Takahiro
2015-03-26 8:25 ` [RFC v2 5/5] arm: kvm: add stub implementation for kvm_cpu_reset() AKASHI Takahiro
2015-03-27 15:31 ` [RFC v2 0/5] arm64: kvm: reset hyp context for kexec Kyle McMartin
2015-03-27 15:37 ` Marc Zyngier
2015-03-27 17:40 ` Kyle McMartin
2015-03-27 17:50 ` Marc Zyngier
2015-03-30 1:39 ` AKASHI Takahiro
2015-03-30 7:16 ` Marc Zyngier
2015-03-30 8:54 ` AKASHI Takahiro
2015-03-31 6:04 ` AKASHI Takahiro
2015-03-31 7:31 ` Marc Zyngier
2015-04-01 5:06 ` AKASHI Takahiro
2015-04-01 9:05 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427358326-3708-3-git-send-email-takahiro.akashi@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).