2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 * Copyright IBM Corp. 2008
17 * Authors: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
20 #ifndef __POWERPC_KVM_EXITTIMING_H__
21 #define __POWERPC_KVM_EXITTIMING_H__
23 #include <linux/kvm_host.h>
24 #include <asm/kvm_host.h>
26 #ifdef CONFIG_KVM_EXIT_TIMING
27 void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
28 void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
29 void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id);
30 void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu);
32 static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
34 vcpu->arch.last_exit_type = type;
38 /* if exit timing is not configured there is no need to build the c file */
39 static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
40 static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
41 static inline void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu,
43 static inline void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu) {}
44 static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
45 #endif /* CONFIG_KVM_EXIT_TIMING */
47 /* account the exit in kvm_stats */
48 static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
50 /* type has to be known at build time for optimization */
51 BUILD_BUG_ON(__builtin_constant_p(type));
54 vcpu->stat.ext_intr_exits++;
57 vcpu->stat.dec_exits++;
59 case EMULATED_INST_EXITS:
60 vcpu->stat.emulated_inst_exits++;
63 vcpu->stat.dcr_exits++;
66 vcpu->stat.dsi_exits++;
69 vcpu->stat.isi_exits++;
72 vcpu->stat.syscall_exits++;
74 case DTLB_REAL_MISS_EXITS:
75 vcpu->stat.dtlb_real_miss_exits++;
77 case DTLB_VIRT_MISS_EXITS:
78 vcpu->stat.dtlb_virt_miss_exits++;
81 vcpu->stat.mmio_exits++;
83 case ITLB_REAL_MISS_EXITS:
84 vcpu->stat.itlb_real_miss_exits++;
86 case ITLB_VIRT_MISS_EXITS:
87 vcpu->stat.itlb_virt_miss_exits++;
90 vcpu->stat.signal_exits++;
95 /* wrapper to set exit time and account for it in kvm_stats */
96 static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
98 kvmppc_set_exit_type(vcpu, type);
99 kvmppc_account_exit_stat(vcpu, type);
102 #endif /* __POWERPC_KVM_EXITTIMING_H__ */