KVM: arm/arm64: Handle CPU_PM_ENTER_FAILED

"Linux Kernel Mailing List" <[email protected]> Sat, 10 Feb 2018 22:00:24 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/58d6b15e9da5042a99c9c30ad725792e4569150e
Commit:     58d6b15e9da5042a99c9c30ad725792e4569150e
Parent:     0482b50546b12e82346903500af081ed329f915c
Refname:    refs/heads/master
Author:     James Morse <[email protected]>
AuthorDate: Mon Jan 22 18:19:06 2018 +0000
Committer:  Christoffer Dall <[email protected]>
CommitDate: Tue Jan 23 16:47:15 2018 +0100

    KVM: arm/arm64: Handle CPU_PM_ENTER_FAILED
    
    cpu_pm_enter() calls the pm notifier chain with CPU_PM_ENTER, then if
    there is a failure: CPU_PM_ENTER_FAILED.
    
    When KVM receives CPU_PM_ENTER it calls cpu_hyp_reset() which will
    return us to the hyp-stub. If we subsequently get a CPU_PM_ENTER_FAILED,
    KVM does nothing, leaving the CPU running with the hyp-stub, at odds
    with kvm_arm_hardware_enabled.
    
    Add CPU_PM_ENTER_FAILED as a fallthrough for CPU_PM_EXIT, this reloads
    KVM based on kvm_arm_hardware_enabled. This is safe even if CPU_PM_ENTER
    never gets as far as KVM, as cpu_hyp_reinit() calls cpu_hyp_reset()
    to make sure the hyp-stub is loaded before reloading KVM.
    
    Fixes: 67f691976662 ("arm64: kvm: allows kvm cpu hotplug")
    Cc: <[email protected]> # v4.7+
    CC: Lorenzo Pieralisi <[email protected]>
    Reviewed-by: Christoffer Dall <[email protected]>
    Signed-off-by: James Morse <[email protected]>
    Signed-off-by: Christoffer Dall <[email protected]>
---
 virt/kvm/arm/arm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index 59d8e04c19fa..639dca0c0560 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -1262,6 +1262,7 @@ static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
 			cpu_hyp_reset();
 
 		return NOTIFY_OK;
+	case CPU_PM_ENTER_FAILED:
 	case CPU_PM_EXIT:
 		if (__this_cpu_read(kvm_arm_hardware_enabled))
 			/* The hardware was enabled before suspend. */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html