[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ad5635d3477a14c8084ce85f2031308d3a9dc381.1663869838.git.isaku.yamahata@intel.com>
Date: Thu, 22 Sep 2022 11:20:41 -0700
From: isaku.yamahata@...el.com
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Marc Zyngier <maz@...nel.org>, Will Deacon <will@...nel.org>
Cc: isaku.yamahata@...el.com, isaku.yamahata@...il.com,
Kai Huang <kai.huang@...el.com>, Chao Gao <chao.gao@...el.com>,
Atish Patra <atishp@...shpatra.org>,
Shaokun Zhang <zhangshaokun@...ilicon.com>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Huang Ying <ying.huang@...el.com>,
Huacai Chen <chenhuacai@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Borislav Petkov <bp@...en8.de>
Subject: [PATCH v5 12/30] KVM: Add arch hook for suspend
From: Isaku Yamahata <isaku.yamahata@...el.com>
Factor out the logic on suspend event as arch callback. Later kvm/x86 will
override it.
Suggested-by: Sean Christopherson <seanjc@...gle.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
---
include/linux/kvm_host.h | 1 +
virt/kvm/kvm_main.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 084ee8a13e9f..861aad8812ff 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1435,6 +1435,7 @@ static inline void kvm_create_vcpu_debugfs(struct kvm_vcpu *vcpu) {}
#endif
int kvm_arch_reboot(int val);
+int kvm_arch_suspend(int usage_count);
int kvm_arch_hardware_enable(void);
void kvm_arch_hardware_disable(void);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 58385000b73f..0ebe43a695e5 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1148,6 +1148,17 @@ int __weak kvm_arch_reboot(int val)
return NOTIFY_OK;
}
+int __weak kvm_arch_suspend(int usage_count)
+{
+ if (usage_count)
+ /*
+ * Because kvm_suspend() is called with interrupt disabled, no
+ * need to disable preemption.
+ */
+ hardware_disable_nolock(NULL);
+ return 0;
+}
+
/*
* Called just after removing the VM from the vm_list, but before doing any
* other destruction.
@@ -5753,15 +5764,7 @@ static int kvm_suspend(void)
* locking.
*/
lockdep_assert_not_held(&kvm_lock);
-
- if (kvm_usage_count) {
- /*
- * Because kvm_suspend() is called with interrupt disabled, no
- * need to disable preemption.
- */
- hardware_disable_nolock(NULL);
- }
- return 0;
+ return kvm_arch_suspend(kvm_usage_count);
}
static void kvm_resume(void)
--
2.25.1
Powered by blists - more mailing lists