xref: /linux/arch/powerpc/kvm/timing.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1d94d71cbSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
273e75b41SHollis Blanchard /*
373e75b41SHollis Blanchard  *
473e75b41SHollis Blanchard  * Copyright IBM Corp. 2008
573e75b41SHollis Blanchard  *
673e75b41SHollis Blanchard  * Authors: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
773e75b41SHollis Blanchard  */
873e75b41SHollis Blanchard 
973e75b41SHollis Blanchard #ifndef __POWERPC_KVM_EXITTIMING_H__
1073e75b41SHollis Blanchard #define __POWERPC_KVM_EXITTIMING_H__
1173e75b41SHollis Blanchard 
1273e75b41SHollis Blanchard #include <linux/kvm_host.h>
1373e75b41SHollis Blanchard 
1473e75b41SHollis Blanchard #ifdef CONFIG_KVM_EXIT_TIMING
1573e75b41SHollis Blanchard void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
1673e75b41SHollis Blanchard void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
17*faf01aefSAlexey Kardashevskiy int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
18*faf01aefSAlexey Kardashevskiy 				    struct dentry *debugfs_dentry);
1973e75b41SHollis Blanchard 
kvmppc_set_exit_type(struct kvm_vcpu * vcpu,int type)2073e75b41SHollis Blanchard static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
2173e75b41SHollis Blanchard {
2273e75b41SHollis Blanchard 	vcpu->arch.last_exit_type = type;
2373e75b41SHollis Blanchard }
2473e75b41SHollis Blanchard 
2573e75b41SHollis Blanchard #else
2673e75b41SHollis Blanchard /* if exit timing is not configured there is no need to build the c file */
kvmppc_init_timing_stats(struct kvm_vcpu * vcpu)2773e75b41SHollis Blanchard static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
kvmppc_update_timing_stats(struct kvm_vcpu * vcpu)2873e75b41SHollis Blanchard static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu * vcpu,struct dentry * debugfs_dentry)29*faf01aefSAlexey Kardashevskiy static inline int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
30*faf01aefSAlexey Kardashevskiy 						  struct dentry *debugfs_dentry)
31*faf01aefSAlexey Kardashevskiy {
32*faf01aefSAlexey Kardashevskiy 	return 0;
33*faf01aefSAlexey Kardashevskiy }
kvmppc_set_exit_type(struct kvm_vcpu * vcpu,int type)3473e75b41SHollis Blanchard static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
3573e75b41SHollis Blanchard #endif /* CONFIG_KVM_EXIT_TIMING */
3673e75b41SHollis Blanchard 
3773e75b41SHollis Blanchard /* account the exit in kvm_stats */
kvmppc_account_exit_stat(struct kvm_vcpu * vcpu,int type)387b701591SHollis Blanchard static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
3973e75b41SHollis Blanchard {
4073e75b41SHollis Blanchard 	/* type has to be known at build time for optimization */
4138634e67SBenjamin Herrenschmidt 
4238634e67SBenjamin Herrenschmidt 	/* The BUILD_BUG_ON below breaks in funny ways, commented out
4338634e67SBenjamin Herrenschmidt 	 * for now ... -BenH
44c0a187e1SHollis Blanchard 	BUILD_BUG_ON(!__builtin_constant_p(type));
4538634e67SBenjamin Herrenschmidt 	*/
4673e75b41SHollis Blanchard 	switch (type) {
4773e75b41SHollis Blanchard 	case EXT_INTR_EXITS:
4873e75b41SHollis Blanchard 		vcpu->stat.ext_intr_exits++;
4973e75b41SHollis Blanchard 		break;
5073e75b41SHollis Blanchard 	case DEC_EXITS:
5173e75b41SHollis Blanchard 		vcpu->stat.dec_exits++;
5273e75b41SHollis Blanchard 		break;
5373e75b41SHollis Blanchard 	case EMULATED_INST_EXITS:
5473e75b41SHollis Blanchard 		vcpu->stat.emulated_inst_exits++;
5573e75b41SHollis Blanchard 		break;
5673e75b41SHollis Blanchard 	case DSI_EXITS:
5773e75b41SHollis Blanchard 		vcpu->stat.dsi_exits++;
5873e75b41SHollis Blanchard 		break;
5973e75b41SHollis Blanchard 	case ISI_EXITS:
6073e75b41SHollis Blanchard 		vcpu->stat.isi_exits++;
6173e75b41SHollis Blanchard 		break;
6273e75b41SHollis Blanchard 	case SYSCALL_EXITS:
6373e75b41SHollis Blanchard 		vcpu->stat.syscall_exits++;
6473e75b41SHollis Blanchard 		break;
6573e75b41SHollis Blanchard 	case DTLB_REAL_MISS_EXITS:
6673e75b41SHollis Blanchard 		vcpu->stat.dtlb_real_miss_exits++;
6773e75b41SHollis Blanchard 		break;
6873e75b41SHollis Blanchard 	case DTLB_VIRT_MISS_EXITS:
6973e75b41SHollis Blanchard 		vcpu->stat.dtlb_virt_miss_exits++;
7073e75b41SHollis Blanchard 		break;
7173e75b41SHollis Blanchard 	case MMIO_EXITS:
7273e75b41SHollis Blanchard 		vcpu->stat.mmio_exits++;
7373e75b41SHollis Blanchard 		break;
7473e75b41SHollis Blanchard 	case ITLB_REAL_MISS_EXITS:
7573e75b41SHollis Blanchard 		vcpu->stat.itlb_real_miss_exits++;
7673e75b41SHollis Blanchard 		break;
7773e75b41SHollis Blanchard 	case ITLB_VIRT_MISS_EXITS:
7873e75b41SHollis Blanchard 		vcpu->stat.itlb_virt_miss_exits++;
7973e75b41SHollis Blanchard 		break;
8073e75b41SHollis Blanchard 	case SIGNAL_EXITS:
8173e75b41SHollis Blanchard 		vcpu->stat.signal_exits++;
8273e75b41SHollis Blanchard 		break;
83d30f6e48SScott Wood 	case DBELL_EXITS:
84d30f6e48SScott Wood 		vcpu->stat.dbell_exits++;
85d30f6e48SScott Wood 		break;
86d30f6e48SScott Wood 	case GDBELL_EXITS:
87d30f6e48SScott Wood 		vcpu->stat.gdbell_exits++;
88d30f6e48SScott Wood 		break;
8973e75b41SHollis Blanchard 	}
9073e75b41SHollis Blanchard }
9173e75b41SHollis Blanchard 
9273e75b41SHollis Blanchard /* wrapper to set exit time and account for it in kvm_stats */
kvmppc_account_exit(struct kvm_vcpu * vcpu,int type)937b701591SHollis Blanchard static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
9473e75b41SHollis Blanchard {
9573e75b41SHollis Blanchard 	kvmppc_set_exit_type(vcpu, type);
967b701591SHollis Blanchard 	kvmppc_account_exit_stat(vcpu, type);
9773e75b41SHollis Blanchard }
9873e75b41SHollis Blanchard 
9973e75b41SHollis Blanchard #endif /* __POWERPC_KVM_EXITTIMING_H__ */
100