From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] fixup! arm64: kvm: allows kvm cpu hotplug
Date: Tue, 20 Oct 2015 16:58:27 +0900 [thread overview]
Message-ID: <1445327907-23274-3-git-send-email-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <1445327907-23274-1-git-send-email-takahiro.akashi@linaro.org>
Without this patch, kvm cannot start a guest when cpuidle is enabled
if the hardware does not retain cpu state (EL2) in idle state.
This patch re-initailizes EL2 state at CPU_PM_EXIT by calling
kvm_arch_hardware_enable() if and only if kvm has been initialized
before CPU_PM_ENTER, that is, if any vcpus have been created.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
arch/arm/kvm/arm.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 0871809..fbff638 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -60,6 +60,8 @@ static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
static u8 kvm_next_vmid;
static DEFINE_SPINLOCK(kvm_vmid_lock);
+static DEFINE_PER_CPU(unsigned char, kvm_arm_hardware_enabled);
+
static void kvm_arm_set_running_vcpu(struct kvm_vcpu *vcpu)
{
BUG_ON(preemptible());
@@ -955,12 +957,27 @@ static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
unsigned long cmd,
void *v)
{
- if (cmd == CPU_PM_EXIT && kvm_arm_get_running_vcpu()) {
- kvm_arch_hardware_enable();
+ switch (cmd) {
+ case CPU_PM_ENTER:
+ if (__hyp_get_vectors() != hyp_default_vectors)
+ __this_cpu_write(kvm_arm_hardware_enabled, 1);
+ else
+ __this_cpu_write(kvm_arm_hardware_enabled, 0);
+ /*
+ * don't call kvm_arch_hardware_disable() in case of
+ * CPU_PM_ENTER because it does't actually save any state.
+ */
+
+ return NOTIFY_OK;
+ case CPU_PM_EXIT:
+ if (__this_cpu_read(kvm_arm_hardware_enabled))
+ kvm_arch_hardware_enable();
+
return NOTIFY_OK;
- }
- return NOTIFY_DONE;
+ default:
+ return NOTIFY_DONE;
+ }
}
static struct notifier_block hyp_init_cpu_pm_nb = {
--
1.7.9.5
next prev parent reply other threads:[~2015-10-20 7:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 7:58 [PATCH 0/2] arm64: kexec/kdump fixes for v10 AKASHI Takahiro
2015-10-20 7:58 ` [PATCH 1/2] fixup! arm64: kdump: implement machine_crash_shutdown() AKASHI Takahiro
2015-10-20 7:58 ` AKASHI Takahiro [this message]
2015-10-20 16:22 ` [PATCH 2/2] fixup! arm64: kvm: allows kvm cpu hotplug James Morse
2015-10-20 19:05 ` [PATCH 0/2] arm64: kexec/kdump fixes for v10 Geoff Levand
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=1445327907-23274-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).