diff options
-rw-r--r-- | arch/x86/kvm/debugfs.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c index bb5e9f635dde..c19c7ede9bd6 100644 --- a/arch/x86/kvm/debugfs.c +++ b/arch/x86/kvm/debugfs.c | |||
@@ -8,13 +8,62 @@ | |||
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | #include <linux/kvm_host.h> | 10 | #include <linux/kvm_host.h> |
11 | #include <linux/debugfs.h> | ||
11 | 12 | ||
12 | bool kvm_arch_has_vcpu_debugfs(void) | 13 | bool kvm_arch_has_vcpu_debugfs(void) |
13 | { | 14 | { |
14 | return false; | 15 | return true; |
15 | } | 16 | } |
16 | 17 | ||
18 | static int vcpu_get_tsc_offset(void *data, u64 *val) | ||
19 | { | ||
20 | struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data; | ||
21 | *val = vcpu->arch.tsc_offset; | ||
22 | return 0; | ||
23 | } | ||
24 | |||
25 | DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_offset_fops, vcpu_get_tsc_offset, NULL, "%lld\n"); | ||
26 | |||
27 | static int vcpu_get_tsc_scaling_ratio(void *data, u64 *val) | ||
28 | { | ||
29 | struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data; | ||
30 | *val = vcpu->arch.tsc_scaling_ratio; | ||
31 | return 0; | ||
32 | } | ||
33 | |||
34 | DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_fops, vcpu_get_tsc_scaling_ratio, NULL, "%llu\n"); | ||
35 | |||
36 | static int vcpu_get_tsc_scaling_frac_bits(void *data, u64 *val) | ||
37 | { | ||
38 | *val = kvm_tsc_scaling_ratio_frac_bits; | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, vcpu_get_tsc_scaling_frac_bits, NULL, "%llu\n"); | ||
43 | |||
17 | int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu) | 44 | int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu) |
18 | { | 45 | { |
46 | struct dentry *ret; | ||
47 | |||
48 | ret = debugfs_create_file("tsc-offset", 0444, | ||
49 | vcpu->debugfs_dentry, | ||
50 | vcpu, &vcpu_tsc_offset_fops); | ||
51 | if (!ret) | ||
52 | return -ENOMEM; | ||
53 | |||
54 | 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 | |||
66 | } | ||
67 | |||
19 | return 0; | 68 | return 0; |
20 | } | 69 | } |