hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/x86/kvm/debugfs.c
....@@ -1,19 +1,21 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Kernel-based Virtual Machine driver for Linux
34 *
45 * Copyright 2016 Red Hat, Inc. and/or its affiliates.
5
- *
6
- * This work is licensed under the terms of the GNU GPL, version 2. See
7
- * the COPYING file in the top-level directory.
8
- *
96 */
107 #include <linux/kvm_host.h>
118 #include <linux/debugfs.h>
9
+#include "lapic.h"
1210
13
-bool kvm_arch_has_vcpu_debugfs(void)
11
+static int vcpu_get_timer_advance_ns(void *data, u64 *val)
1412 {
15
- return true;
13
+ struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
14
+ *val = vcpu->arch.apic->lapic_timer.timer_advance_ns;
15
+ return 0;
1616 }
17
+
18
+DEFINE_SIMPLE_ATTRIBUTE(vcpu_timer_advance_ns_fops, vcpu_get_timer_advance_ns, NULL, "%llu\n");
1719
1820 static int vcpu_get_tsc_offset(void *data, u64 *val)
1921 {
....@@ -41,29 +43,22 @@
4143
4244 DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n");
4345
44
-int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu)
46
+void kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
4547 {
46
- struct dentry *ret;
48
+ debugfs_create_file("tsc-offset", 0444, debugfs_dentry, vcpu,
49
+ &vcpu_tsc_offset_fops);
4750
48
- ret = debugfs_create_file("tsc-offset", 0444,
49
- vcpu->debugfs_dentry,
50
- vcpu, &vcpu_tsc_offset_fops);
51
- if (!ret)
52
- return -ENOMEM;
51
+ if (lapic_in_kernel(vcpu))
52
+ debugfs_create_file("lapic_timer_advance_ns", 0444,
53
+ debugfs_dentry, vcpu,
54
+ &vcpu_timer_advance_ns_fops);
5355
5456 if (kvm_has_tsc_control) {
55
- ret = debugfs_create_file("tsc-scaling-ratio", 0444,
56
- vcpu->debugfs_dentry,
57
- vcpu, &vcpu_tsc_scaling_fops);
58
- if (!ret)
59
- return -ENOMEM;
60
- ret = debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444,
61
- vcpu->debugfs_dentry,
62
- vcpu, &vcpu_tsc_scaling_frac_fops);
63
- if (!ret)
64
- return -ENOMEM;
65
-
57
+ debugfs_create_file("tsc-scaling-ratio", 0444,
58
+ debugfs_dentry, vcpu,
59
+ &vcpu_tsc_scaling_fops);
60
+ debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444,
61
+ debugfs_dentry, vcpu,
62
+ &vcpu_tsc_scaling_frac_fops);
6663 }
67
-
68
- return 0;
6964 }