2 * Kernel-based Virtual Machine driver for Linux
4 * Copyright 2016 Red Hat, Inc. and/or its affiliates.
6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory.
10 #include <linux/kvm_host.h>
11 #include <linux/debugfs.h>
13 bool kvm_arch_has_vcpu_debugfs(void)
18 static int vcpu_get_tsc_offset(void *data
, u64
*val
)
20 struct kvm_vcpu
*vcpu
= (struct kvm_vcpu
*) data
;
21 *val
= vcpu
->arch
.tsc_offset
;
25 DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_offset_fops
, vcpu_get_tsc_offset
, NULL
, "%lld\n");
27 static int vcpu_get_tsc_scaling_ratio(void *data
, u64
*val
)
29 struct kvm_vcpu
*vcpu
= (struct kvm_vcpu
*) data
;
30 *val
= vcpu
->arch
.tsc_scaling_ratio
;
34 DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_fops
, vcpu_get_tsc_scaling_ratio
, NULL
, "%llu\n");
36 static int vcpu_get_tsc_scaling_frac_bits(void *data
, u64
*val
)
38 *val
= kvm_tsc_scaling_ratio_frac_bits
;
42 DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops
, vcpu_get_tsc_scaling_frac_bits
, NULL
, "%llu\n");
44 int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu
*vcpu
)
48 ret
= debugfs_create_file("tsc-offset", 0444,
50 vcpu
, &vcpu_tsc_offset_fops
);
54 if (kvm_has_tsc_control
) {
55 ret
= debugfs_create_file("tsc-scaling-ratio", 0444,
57 vcpu
, &vcpu_tsc_scaling_fops
);
60 ret
= debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444,
62 vcpu
, &vcpu_tsc_scaling_frac_fops
);