1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright IBM Corp. 2008
9 #ifndef __POWERPC_KVM_EXITTIMING_H__
10 #define __POWERPC_KVM_EXITTIMING_H__
12 #include <linux/kvm_host.h>
14 #ifdef CONFIG_KVM_EXIT_TIMING
15 void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
16 void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
17 int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
18 struct dentry *debugfs_dentry);
20 static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
22 vcpu->arch.last_exit_type = type;
26 /* if exit timing is not configured there is no need to build the c file */
27 static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
28 static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
29 static inline int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
30 struct dentry *debugfs_dentry)
34 static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
35 #endif /* CONFIG_KVM_EXIT_TIMING */
37 /* account the exit in kvm_stats */
38 static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
40 /* type has to be known at build time for optimization */
42 /* The BUILD_BUG_ON below breaks in funny ways, commented out
44 BUILD_BUG_ON(!__builtin_constant_p(type));
48 vcpu->stat.ext_intr_exits++;
51 vcpu->stat.dec_exits++;
53 case EMULATED_INST_EXITS:
54 vcpu->stat.emulated_inst_exits++;
57 vcpu->stat.dsi_exits++;
60 vcpu->stat.isi_exits++;
63 vcpu->stat.syscall_exits++;
65 case DTLB_REAL_MISS_EXITS:
66 vcpu->stat.dtlb_real_miss_exits++;
68 case DTLB_VIRT_MISS_EXITS:
69 vcpu->stat.dtlb_virt_miss_exits++;
72 vcpu->stat.mmio_exits++;
74 case ITLB_REAL_MISS_EXITS:
75 vcpu->stat.itlb_real_miss_exits++;
77 case ITLB_VIRT_MISS_EXITS:
78 vcpu->stat.itlb_virt_miss_exits++;
81 vcpu->stat.signal_exits++;
84 vcpu->stat.dbell_exits++;
87 vcpu->stat.gdbell_exits++;
92 /* wrapper to set exit time and account for it in kvm_stats */
93 static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
95 kvmppc_set_exit_type(vcpu, type);
96 kvmppc_account_exit_stat(vcpu, type);
99 #endif /* __POWERPC_KVM_EXITTIMING_H__ */