1669e846eSSanjay Lal /* 2669e846eSSanjay Lal * This file is subject to the terms and conditions of the GNU General Public 3669e846eSSanjay Lal * License. See the file "COPYING" in the main directory of this archive 4669e846eSSanjay Lal * for more details. 5669e846eSSanjay Lal * 6669e846eSSanjay Lal * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 7669e846eSSanjay Lal * Authors: Sanjay Lal <sanjayl@kymasys.com> 8669e846eSSanjay Lal */ 9669e846eSSanjay Lal 10669e846eSSanjay Lal #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) 11669e846eSSanjay Lal #define _TRACE_KVM_H 12669e846eSSanjay Lal 13669e846eSSanjay Lal #include <linux/tracepoint.h> 14669e846eSSanjay Lal 15669e846eSSanjay Lal #undef TRACE_SYSTEM 16669e846eSSanjay Lal #define TRACE_SYSTEM kvm 17669e846eSSanjay Lal #define TRACE_INCLUDE_PATH . 18669e846eSSanjay Lal #define TRACE_INCLUDE_FILE trace 19669e846eSSanjay Lal 2093258604SJames Hogan /* 2193258604SJames Hogan * Tracepoints for VM enters 2293258604SJames Hogan */ 23fb6cec14SJames Hogan DECLARE_EVENT_CLASS(kvm_transition, 2493258604SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu), 2593258604SJames Hogan TP_ARGS(vcpu), 2693258604SJames Hogan TP_STRUCT__entry( 2793258604SJames Hogan __field(unsigned long, pc) 2893258604SJames Hogan ), 2993258604SJames Hogan 3093258604SJames Hogan TP_fast_assign( 3193258604SJames Hogan __entry->pc = vcpu->arch.pc; 3293258604SJames Hogan ), 3393258604SJames Hogan 3493258604SJames Hogan TP_printk("PC: 0x%08lx", 3593258604SJames Hogan __entry->pc) 3693258604SJames Hogan ); 3793258604SJames Hogan 38fb6cec14SJames Hogan DEFINE_EVENT(kvm_transition, kvm_enter, 3993258604SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu), 40fb6cec14SJames Hogan TP_ARGS(vcpu)); 4193258604SJames Hogan 42fb6cec14SJames Hogan DEFINE_EVENT(kvm_transition, kvm_reenter, 4393258604SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu), 44fb6cec14SJames Hogan TP_ARGS(vcpu)); 4593258604SJames Hogan 46fb6cec14SJames Hogan DEFINE_EVENT(kvm_transition, kvm_out, 47fb6cec14SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu), 48fb6cec14SJames Hogan TP_ARGS(vcpu)); 4993258604SJames Hogan 501e09e86aSJames Hogan /* The first 32 exit reasons correspond to Cause.ExcCode */ 511e09e86aSJames Hogan #define KVM_TRACE_EXIT_INT 0 521e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMOD 1 531e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMISS_LD 2 541e09e86aSJames Hogan #define KVM_TRACE_EXIT_TLBMISS_ST 3 551e09e86aSJames Hogan #define KVM_TRACE_EXIT_ADDRERR_LD 4 561e09e86aSJames Hogan #define KVM_TRACE_EXIT_ADDRERR_ST 5 571e09e86aSJames Hogan #define KVM_TRACE_EXIT_SYSCALL 8 581e09e86aSJames Hogan #define KVM_TRACE_EXIT_BREAK_INST 9 591e09e86aSJames Hogan #define KVM_TRACE_EXIT_RESVD_INST 10 601e09e86aSJames Hogan #define KVM_TRACE_EXIT_COP_UNUSABLE 11 611e09e86aSJames Hogan #define KVM_TRACE_EXIT_TRAP_INST 13 621e09e86aSJames Hogan #define KVM_TRACE_EXIT_MSA_FPE 14 631e09e86aSJames Hogan #define KVM_TRACE_EXIT_FPE 15 641e09e86aSJames Hogan #define KVM_TRACE_EXIT_MSA_DISABLED 21 651e09e86aSJames Hogan /* Further exit reasons */ 661e09e86aSJames Hogan #define KVM_TRACE_EXIT_WAIT 32 671e09e86aSJames Hogan #define KVM_TRACE_EXIT_CACHE 33 681e09e86aSJames Hogan #define KVM_TRACE_EXIT_SIGNAL 34 69*a7244920SJames Hogan /* 32 exit reasons correspond to GuestCtl0.GExcCode (VZ) */ 70*a7244920SJames Hogan #define KVM_TRACE_EXIT_GEXCCODE_BASE 64 71*a7244920SJames Hogan #define KVM_TRACE_EXIT_GPSI 64 /* 0 */ 72*a7244920SJames Hogan #define KVM_TRACE_EXIT_GSFC 65 /* 1 */ 73*a7244920SJames Hogan #define KVM_TRACE_EXIT_HC 66 /* 2 */ 74*a7244920SJames Hogan #define KVM_TRACE_EXIT_GRR 67 /* 3 */ 75*a7244920SJames Hogan #define KVM_TRACE_EXIT_GVA 72 /* 8 */ 76*a7244920SJames Hogan #define KVM_TRACE_EXIT_GHFC 73 /* 9 */ 77*a7244920SJames Hogan #define KVM_TRACE_EXIT_GPA 74 /* 10 */ 781e09e86aSJames Hogan 791e09e86aSJames Hogan /* Tracepoints for VM exits */ 801e09e86aSJames Hogan #define kvm_trace_symbol_exit_types \ 811e09e86aSJames Hogan { KVM_TRACE_EXIT_INT, "Interrupt" }, \ 821e09e86aSJames Hogan { KVM_TRACE_EXIT_TLBMOD, "TLB Mod" }, \ 831e09e86aSJames Hogan { KVM_TRACE_EXIT_TLBMISS_LD, "TLB Miss (LD)" }, \ 841e09e86aSJames Hogan { KVM_TRACE_EXIT_TLBMISS_ST, "TLB Miss (ST)" }, \ 851e09e86aSJames Hogan { KVM_TRACE_EXIT_ADDRERR_LD, "Address Error (LD)" }, \ 861e09e86aSJames Hogan { KVM_TRACE_EXIT_ADDRERR_ST, "Address Err (ST)" }, \ 871e09e86aSJames Hogan { KVM_TRACE_EXIT_SYSCALL, "System Call" }, \ 881e09e86aSJames Hogan { KVM_TRACE_EXIT_BREAK_INST, "Break Inst" }, \ 891e09e86aSJames Hogan { KVM_TRACE_EXIT_RESVD_INST, "Reserved Inst" }, \ 901e09e86aSJames Hogan { KVM_TRACE_EXIT_COP_UNUSABLE, "COP0/1 Unusable" }, \ 911e09e86aSJames Hogan { KVM_TRACE_EXIT_TRAP_INST, "Trap Inst" }, \ 921e09e86aSJames Hogan { KVM_TRACE_EXIT_MSA_FPE, "MSA FPE" }, \ 931e09e86aSJames Hogan { KVM_TRACE_EXIT_FPE, "FPE" }, \ 941e09e86aSJames Hogan { KVM_TRACE_EXIT_MSA_DISABLED, "MSA Disabled" }, \ 951e09e86aSJames Hogan { KVM_TRACE_EXIT_WAIT, "WAIT" }, \ 961e09e86aSJames Hogan { KVM_TRACE_EXIT_CACHE, "CACHE" }, \ 97*a7244920SJames Hogan { KVM_TRACE_EXIT_SIGNAL, "Signal" }, \ 98*a7244920SJames Hogan { KVM_TRACE_EXIT_GPSI, "GPSI" }, \ 99*a7244920SJames Hogan { KVM_TRACE_EXIT_GSFC, "GSFC" }, \ 100*a7244920SJames Hogan { KVM_TRACE_EXIT_HC, "HC" }, \ 101*a7244920SJames Hogan { KVM_TRACE_EXIT_GRR, "GRR" }, \ 102*a7244920SJames Hogan { KVM_TRACE_EXIT_GVA, "GVA" }, \ 103*a7244920SJames Hogan { KVM_TRACE_EXIT_GHFC, "GHFC" }, \ 104*a7244920SJames Hogan { KVM_TRACE_EXIT_GPA, "GPA" } 105669e846eSSanjay Lal 106669e846eSSanjay Lal TRACE_EVENT(kvm_exit, 107669e846eSSanjay Lal TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), 108669e846eSSanjay Lal TP_ARGS(vcpu, reason), 109669e846eSSanjay Lal TP_STRUCT__entry( 110b3cffac0SJames Hogan __field(unsigned long, pc) 111669e846eSSanjay Lal __field(unsigned int, reason) 112669e846eSSanjay Lal ), 113669e846eSSanjay Lal 114669e846eSSanjay Lal TP_fast_assign( 115b3cffac0SJames Hogan __entry->pc = vcpu->arch.pc; 116669e846eSSanjay Lal __entry->reason = reason; 117669e846eSSanjay Lal ), 118669e846eSSanjay Lal 119669e846eSSanjay Lal TP_printk("[%s]PC: 0x%08lx", 1201e09e86aSJames Hogan __print_symbolic(__entry->reason, 1211e09e86aSJames Hogan kvm_trace_symbol_exit_types), 122b3cffac0SJames Hogan __entry->pc) 123669e846eSSanjay Lal ); 124669e846eSSanjay Lal 1256398da13SJames Hogan #define KVM_TRACE_MFC0 0 1266398da13SJames Hogan #define KVM_TRACE_MTC0 1 1276398da13SJames Hogan #define KVM_TRACE_DMFC0 2 1286398da13SJames Hogan #define KVM_TRACE_DMTC0 3 1296398da13SJames Hogan #define KVM_TRACE_RDHWR 4 1306398da13SJames Hogan 1316398da13SJames Hogan #define KVM_TRACE_HWR_COP0 0 1326398da13SJames Hogan #define KVM_TRACE_HWR_HWR 1 1336398da13SJames Hogan 1346398da13SJames Hogan #define KVM_TRACE_COP0(REG, SEL) ((KVM_TRACE_HWR_COP0 << 8) | \ 1356398da13SJames Hogan ((REG) << 3) | (SEL)) 1366398da13SJames Hogan #define KVM_TRACE_HWR(REG, SEL) ((KVM_TRACE_HWR_HWR << 8) | \ 1376398da13SJames Hogan ((REG) << 3) | (SEL)) 1386398da13SJames Hogan 1396398da13SJames Hogan #define kvm_trace_symbol_hwr_ops \ 1406398da13SJames Hogan { KVM_TRACE_MFC0, "MFC0" }, \ 1416398da13SJames Hogan { KVM_TRACE_MTC0, "MTC0" }, \ 1426398da13SJames Hogan { KVM_TRACE_DMFC0, "DMFC0" }, \ 1436398da13SJames Hogan { KVM_TRACE_DMTC0, "DMTC0" }, \ 1446398da13SJames Hogan { KVM_TRACE_RDHWR, "RDHWR" } 1456398da13SJames Hogan 1466398da13SJames Hogan #define kvm_trace_symbol_hwr_cop \ 1476398da13SJames Hogan { KVM_TRACE_HWR_COP0, "COP0" }, \ 1486398da13SJames Hogan { KVM_TRACE_HWR_HWR, "HWR" } 1496398da13SJames Hogan 1506398da13SJames Hogan #define kvm_trace_symbol_hwr_regs \ 1516398da13SJames Hogan { KVM_TRACE_COP0( 0, 0), "Index" }, \ 1526398da13SJames Hogan { KVM_TRACE_COP0( 2, 0), "EntryLo0" }, \ 1536398da13SJames Hogan { KVM_TRACE_COP0( 3, 0), "EntryLo1" }, \ 1546398da13SJames Hogan { KVM_TRACE_COP0( 4, 0), "Context" }, \ 1556398da13SJames Hogan { KVM_TRACE_COP0( 4, 2), "UserLocal" }, \ 1566398da13SJames Hogan { KVM_TRACE_COP0( 5, 0), "PageMask" }, \ 1576398da13SJames Hogan { KVM_TRACE_COP0( 6, 0), "Wired" }, \ 1586398da13SJames Hogan { KVM_TRACE_COP0( 7, 0), "HWREna" }, \ 1596398da13SJames Hogan { KVM_TRACE_COP0( 8, 0), "BadVAddr" }, \ 1606398da13SJames Hogan { KVM_TRACE_COP0( 9, 0), "Count" }, \ 1616398da13SJames Hogan { KVM_TRACE_COP0(10, 0), "EntryHi" }, \ 1626398da13SJames Hogan { KVM_TRACE_COP0(11, 0), "Compare" }, \ 1636398da13SJames Hogan { KVM_TRACE_COP0(12, 0), "Status" }, \ 1646398da13SJames Hogan { KVM_TRACE_COP0(12, 1), "IntCtl" }, \ 1656398da13SJames Hogan { KVM_TRACE_COP0(12, 2), "SRSCtl" }, \ 1666398da13SJames Hogan { KVM_TRACE_COP0(13, 0), "Cause" }, \ 1676398da13SJames Hogan { KVM_TRACE_COP0(14, 0), "EPC" }, \ 1686398da13SJames Hogan { KVM_TRACE_COP0(15, 0), "PRId" }, \ 1696398da13SJames Hogan { KVM_TRACE_COP0(15, 1), "EBase" }, \ 1706398da13SJames Hogan { KVM_TRACE_COP0(16, 0), "Config" }, \ 1716398da13SJames Hogan { KVM_TRACE_COP0(16, 1), "Config1" }, \ 1726398da13SJames Hogan { KVM_TRACE_COP0(16, 2), "Config2" }, \ 1736398da13SJames Hogan { KVM_TRACE_COP0(16, 3), "Config3" }, \ 1746398da13SJames Hogan { KVM_TRACE_COP0(16, 4), "Config4" }, \ 1756398da13SJames Hogan { KVM_TRACE_COP0(16, 5), "Config5" }, \ 1766398da13SJames Hogan { KVM_TRACE_COP0(16, 7), "Config7" }, \ 1776398da13SJames Hogan { KVM_TRACE_COP0(26, 0), "ECC" }, \ 1786398da13SJames Hogan { KVM_TRACE_COP0(30, 0), "ErrorEPC" }, \ 17905108709SJames Hogan { KVM_TRACE_COP0(31, 2), "KScratch1" }, \ 18005108709SJames Hogan { KVM_TRACE_COP0(31, 3), "KScratch2" }, \ 18105108709SJames Hogan { KVM_TRACE_COP0(31, 4), "KScratch3" }, \ 18205108709SJames Hogan { KVM_TRACE_COP0(31, 5), "KScratch4" }, \ 18305108709SJames Hogan { KVM_TRACE_COP0(31, 6), "KScratch5" }, \ 18405108709SJames Hogan { KVM_TRACE_COP0(31, 7), "KScratch6" }, \ 1856398da13SJames Hogan { KVM_TRACE_HWR( 0, 0), "CPUNum" }, \ 1866398da13SJames Hogan { KVM_TRACE_HWR( 1, 0), "SYNCI_Step" }, \ 1876398da13SJames Hogan { KVM_TRACE_HWR( 2, 0), "CC" }, \ 1886398da13SJames Hogan { KVM_TRACE_HWR( 3, 0), "CCRes" }, \ 1896398da13SJames Hogan { KVM_TRACE_HWR(29, 0), "ULR" } 1906398da13SJames Hogan 1916398da13SJames Hogan TRACE_EVENT(kvm_hwr, 1926398da13SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op, unsigned int reg, 1936398da13SJames Hogan unsigned long val), 1946398da13SJames Hogan TP_ARGS(vcpu, op, reg, val), 1956398da13SJames Hogan TP_STRUCT__entry( 1966398da13SJames Hogan __field(unsigned long, val) 1976398da13SJames Hogan __field(u16, reg) 1986398da13SJames Hogan __field(u8, op) 1996398da13SJames Hogan ), 2006398da13SJames Hogan 2016398da13SJames Hogan TP_fast_assign( 2026398da13SJames Hogan __entry->val = val; 2036398da13SJames Hogan __entry->reg = reg; 2046398da13SJames Hogan __entry->op = op; 2056398da13SJames Hogan ), 2066398da13SJames Hogan 2076398da13SJames Hogan TP_printk("%s %s (%s:%u:%u) 0x%08lx", 2086398da13SJames Hogan __print_symbolic(__entry->op, 2096398da13SJames Hogan kvm_trace_symbol_hwr_ops), 2106398da13SJames Hogan __print_symbolic(__entry->reg, 2116398da13SJames Hogan kvm_trace_symbol_hwr_regs), 2126398da13SJames Hogan __print_symbolic(__entry->reg >> 8, 2136398da13SJames Hogan kvm_trace_symbol_hwr_cop), 2146398da13SJames Hogan (__entry->reg >> 3) & 0x1f, 2156398da13SJames Hogan __entry->reg & 0x7, 2166398da13SJames Hogan __entry->val) 2176398da13SJames Hogan ); 2186398da13SJames Hogan 21904ebebf4SJames Hogan #define KVM_TRACE_AUX_RESTORE 0 22004ebebf4SJames Hogan #define KVM_TRACE_AUX_SAVE 1 22104ebebf4SJames Hogan #define KVM_TRACE_AUX_ENABLE 2 22204ebebf4SJames Hogan #define KVM_TRACE_AUX_DISABLE 3 22304ebebf4SJames Hogan #define KVM_TRACE_AUX_DISCARD 4 22404ebebf4SJames Hogan 22504ebebf4SJames Hogan #define KVM_TRACE_AUX_FPU 1 22604ebebf4SJames Hogan #define KVM_TRACE_AUX_MSA 2 22704ebebf4SJames Hogan #define KVM_TRACE_AUX_FPU_MSA 3 22804ebebf4SJames Hogan 22904ebebf4SJames Hogan #define kvm_trace_symbol_aux_op \ 23004ebebf4SJames Hogan { KVM_TRACE_AUX_RESTORE, "restore" }, \ 23104ebebf4SJames Hogan { KVM_TRACE_AUX_SAVE, "save" }, \ 23204ebebf4SJames Hogan { KVM_TRACE_AUX_ENABLE, "enable" }, \ 23304ebebf4SJames Hogan { KVM_TRACE_AUX_DISABLE, "disable" }, \ 23404ebebf4SJames Hogan { KVM_TRACE_AUX_DISCARD, "discard" } 23504ebebf4SJames Hogan 23604ebebf4SJames Hogan #define kvm_trace_symbol_aux_state \ 23704ebebf4SJames Hogan { KVM_TRACE_AUX_FPU, "FPU" }, \ 23804ebebf4SJames Hogan { KVM_TRACE_AUX_MSA, "MSA" }, \ 23904ebebf4SJames Hogan { KVM_TRACE_AUX_FPU_MSA, "FPU & MSA" } 24004ebebf4SJames Hogan 24104ebebf4SJames Hogan TRACE_EVENT(kvm_aux, 24204ebebf4SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op, 24304ebebf4SJames Hogan unsigned int state), 24404ebebf4SJames Hogan TP_ARGS(vcpu, op, state), 24504ebebf4SJames Hogan TP_STRUCT__entry( 24604ebebf4SJames Hogan __field(unsigned long, pc) 24704ebebf4SJames Hogan __field(u8, op) 24804ebebf4SJames Hogan __field(u8, state) 24904ebebf4SJames Hogan ), 25004ebebf4SJames Hogan 25104ebebf4SJames Hogan TP_fast_assign( 25204ebebf4SJames Hogan __entry->pc = vcpu->arch.pc; 25304ebebf4SJames Hogan __entry->op = op; 25404ebebf4SJames Hogan __entry->state = state; 25504ebebf4SJames Hogan ), 25604ebebf4SJames Hogan 25704ebebf4SJames Hogan TP_printk("%s %s PC: 0x%08lx", 25804ebebf4SJames Hogan __print_symbolic(__entry->op, 25904ebebf4SJames Hogan kvm_trace_symbol_aux_op), 26004ebebf4SJames Hogan __print_symbolic(__entry->state, 26104ebebf4SJames Hogan kvm_trace_symbol_aux_state), 26204ebebf4SJames Hogan __entry->pc) 26304ebebf4SJames Hogan ); 26404ebebf4SJames Hogan 2659887d1c7SJames Hogan TRACE_EVENT(kvm_asid_change, 2669887d1c7SJames Hogan TP_PROTO(struct kvm_vcpu *vcpu, unsigned int old_asid, 2679887d1c7SJames Hogan unsigned int new_asid), 2689887d1c7SJames Hogan TP_ARGS(vcpu, old_asid, new_asid), 2699887d1c7SJames Hogan TP_STRUCT__entry( 2709887d1c7SJames Hogan __field(unsigned long, pc) 2719887d1c7SJames Hogan __field(u8, old_asid) 2729887d1c7SJames Hogan __field(u8, new_asid) 2739887d1c7SJames Hogan ), 2749887d1c7SJames Hogan 2759887d1c7SJames Hogan TP_fast_assign( 2769887d1c7SJames Hogan __entry->pc = vcpu->arch.pc; 2779887d1c7SJames Hogan __entry->old_asid = old_asid; 2789887d1c7SJames Hogan __entry->new_asid = new_asid; 2799887d1c7SJames Hogan ), 2809887d1c7SJames Hogan 2819887d1c7SJames Hogan TP_printk("PC: 0x%08lx old: 0x%02x new: 0x%02x", 2829887d1c7SJames Hogan __entry->pc, 2839887d1c7SJames Hogan __entry->old_asid, 2849887d1c7SJames Hogan __entry->new_asid) 2859887d1c7SJames Hogan ); 2869887d1c7SJames Hogan 287669e846eSSanjay Lal #endif /* _TRACE_KVM_H */ 288669e846eSSanjay Lal 289669e846eSSanjay Lal /* This part must be outside protection */ 290669e846eSSanjay Lal #include <trace/define_trace.h> 291