lkml.org 
[lkml]   [2022]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v5 13/30] KVM: Add arch hook for resume event
Date
From: Isaku Yamahata <isaku.yamahata@intel.com>

Factor out the logic on resume event as arch callback. Later kvm/x86 will
override it.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
---
include/linux/kvm_host.h | 1 +
virt/kvm/kvm_main.c | 12 ++++++++----
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 861aad8812ff..1adbf74e3047 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1436,6 +1436,7 @@ static inline void kvm_create_vcpu_debugfs(struct kvm_vcpu *vcpu) {}

int kvm_arch_reboot(int val);
int kvm_arch_suspend(int usage_count);
+void kvm_arch_resume(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 0ebe43a695e5..1270f88c2a1e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1159,6 +1159,12 @@ int __weak kvm_arch_suspend(int usage_count)
return 0;
}

+void __weak kvm_arch_resume(int usage_count)
+{
+ if (usage_count)
+ hardware_enable_nolock(NULL);
+}
+
/*
* Called just after removing the VM from the vm_list, but before doing any
* other destruction.
@@ -5769,10 +5775,8 @@ static int kvm_suspend(void)

static void kvm_resume(void)
{
- if (kvm_usage_count) {
- lockdep_assert_not_held(&kvm_lock);
- hardware_enable_nolock(NULL);
- }
+ lockdep_assert_not_held(&kvm_lock);
+ kvm_arch_resume(kvm_usage_count);
}

static struct syscore_ops kvm_syscore_ops = {
--
2.25.1
\
 
 \ /
  Last update: 2022-09-22 20:22    [W:0.367 / U:1.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site