Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *
0004  * Copyright IBM Corp. 2008
0005  *
0006  * Authors: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
0007  */
0008 
0009 #ifndef __POWERPC_KVM_EXITTIMING_H__
0010 #define __POWERPC_KVM_EXITTIMING_H__
0011 
0012 #include <linux/kvm_host.h>
0013 
0014 #ifdef CONFIG_KVM_EXIT_TIMING
0015 void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
0016 void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
0017 int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
0018                     struct dentry *debugfs_dentry);
0019 
0020 static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
0021 {
0022     vcpu->arch.last_exit_type = type;
0023 }
0024 
0025 #else
0026 /* if exit timing is not configured there is no need to build the c file */
0027 static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
0028 static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
0029 static inline int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
0030                           struct dentry *debugfs_dentry)
0031 {
0032     return 0;
0033 }
0034 static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
0035 #endif /* CONFIG_KVM_EXIT_TIMING */
0036 
0037 /* account the exit in kvm_stats */
0038 static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
0039 {
0040     /* type has to be known at build time for optimization */
0041 
0042     /* The BUILD_BUG_ON below breaks in funny ways, commented out
0043      * for now ... -BenH
0044     BUILD_BUG_ON(!__builtin_constant_p(type));
0045     */
0046     switch (type) {
0047     case EXT_INTR_EXITS:
0048         vcpu->stat.ext_intr_exits++;
0049         break;
0050     case DEC_EXITS:
0051         vcpu->stat.dec_exits++;
0052         break;
0053     case EMULATED_INST_EXITS:
0054         vcpu->stat.emulated_inst_exits++;
0055         break;
0056     case DSI_EXITS:
0057         vcpu->stat.dsi_exits++;
0058         break;
0059     case ISI_EXITS:
0060         vcpu->stat.isi_exits++;
0061         break;
0062     case SYSCALL_EXITS:
0063         vcpu->stat.syscall_exits++;
0064         break;
0065     case DTLB_REAL_MISS_EXITS:
0066         vcpu->stat.dtlb_real_miss_exits++;
0067         break;
0068     case DTLB_VIRT_MISS_EXITS:
0069         vcpu->stat.dtlb_virt_miss_exits++;
0070         break;
0071     case MMIO_EXITS:
0072         vcpu->stat.mmio_exits++;
0073         break;
0074     case ITLB_REAL_MISS_EXITS:
0075         vcpu->stat.itlb_real_miss_exits++;
0076         break;
0077     case ITLB_VIRT_MISS_EXITS:
0078         vcpu->stat.itlb_virt_miss_exits++;
0079         break;
0080     case SIGNAL_EXITS:
0081         vcpu->stat.signal_exits++;
0082         break;
0083     case DBELL_EXITS:
0084         vcpu->stat.dbell_exits++;
0085         break;
0086     case GDBELL_EXITS:
0087         vcpu->stat.gdbell_exits++;
0088         break;
0089     }
0090 }
0091 
0092 /* wrapper to set exit time and account for it in kvm_stats */
0093 static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
0094 {
0095     kvmppc_set_exit_type(vcpu, type);
0096     kvmppc_account_exit_stat(vcpu, type);
0097 }
0098 
0099 #endif /* __POWERPC_KVM_EXITTIMING_H__ */