lkml.org 
[lkml]   [2019]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 04/15] kvm: x86: Add per-VM APICv state debugfs
Date
Currently, there is no way to tell whether APICv is active
on a particular VM. This often cause confusion since APICv
can be deactivated at runtime.

Introduce a debugfs entry to report APICv state of a VM.
This creates a read-only file:

/sys/kernel/debug/kvm/70860-14/apicv-state

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
arch/x86/kvm/debugfs.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c
index d62852c..bd9fd25 100644
--- a/arch/x86/kvm/debugfs.c
+++ b/arch/x86/kvm/debugfs.c
@@ -48,8 +48,30 @@ static int vcpu_get_tsc_scaling_frac_bits(void *data, u64 *val)

DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n");

+static int kvm_get_apicv_state(void *data, u64 *val)
+{
+ struct kvm *kvm = (struct kvm *)data;
+
+ mutex_lock(&kvm->arch.apicv_lock);
+ *val = kvm->arch.apicv_state;
+ mutex_unlock(&kvm->arch.apicv_lock);
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(apicv_state_fops, kvm_get_apicv_state, NULL, "%llu\n");
+
int kvm_arch_create_vm_debugfs(struct kvm *kvm)
{
+ struct dentry *ret;
+
+ if (kvm_x86_ops->get_enable_apicv(kvm)) {
+ ret = debugfs_create_file("apicv-state", 0444,
+ kvm->debugfs_dentry,
+ kvm, &apicv_state_fops);
+ if (!ret)
+ return -ENOMEM;
+ }
+
return 0;
}

--
1.8.3.1
\
 
 \ /
  Last update: 2019-08-15 18:28    [W:0.917 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site