Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 1 | #if !defined(_TRACE_KVMMMU_H) || defined(TRACE_HEADER_MULTI_READ) |
| 2 | #define _TRACE_KVMMMU_H |
| 3 | |
| 4 | #include <linux/tracepoint.h> |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 5 | #include <linux/ftrace_event.h> |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 6 | |
| 7 | #undef TRACE_SYSTEM |
| 8 | #define TRACE_SYSTEM kvmmmu |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 9 | |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 10 | #define KVM_MMU_PAGE_FIELDS \ |
| 11 | __field(__u64, gfn) \ |
| 12 | __field(__u32, role) \ |
| 13 | __field(__u32, root_count) \ |
Gui Jianfeng | df2fb6e | 2010-04-22 17:33:57 +0800 | [diff] [blame] | 14 | __field(bool, unsync) |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 15 | |
| 16 | #define KVM_MMU_PAGE_ASSIGN(sp) \ |
| 17 | __entry->gfn = sp->gfn; \ |
| 18 | __entry->role = sp->role.word; \ |
| 19 | __entry->root_count = sp->root_count; \ |
| 20 | __entry->unsync = sp->unsync; |
| 21 | |
| 22 | #define KVM_MMU_PAGE_PRINTK() ({ \ |
| 23 | const char *ret = p->buffer + p->len; \ |
| 24 | static const char *access_str[] = { \ |
| 25 | "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" \ |
| 26 | }; \ |
| 27 | union kvm_mmu_page_role role; \ |
| 28 | \ |
| 29 | role.word = __entry->role; \ |
| 30 | \ |
Avi Kivity | 87bc3bf | 2010-04-19 17:25:53 +0300 | [diff] [blame] | 31 | trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s" \ |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 32 | " %snxe root %u %s%c", \ |
Avi Kivity | 5b7e010 | 2010-04-14 19:20:03 +0300 | [diff] [blame] | 33 | __entry->gfn, role.level, \ |
| 34 | role.cr4_pae ? " pae" : "", \ |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 35 | role.quadrant, \ |
| 36 | role.direct ? " direct" : "", \ |
| 37 | access_str[role.access], \ |
| 38 | role.invalid ? " invalid" : "", \ |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 39 | role.nxe ? "" : "!", \ |
| 40 | __entry->root_count, \ |
| 41 | __entry->unsync ? "unsync" : "sync", 0); \ |
| 42 | ret; \ |
| 43 | }) |
| 44 | |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 45 | #define kvm_mmu_trace_pferr_flags \ |
| 46 | { PFERR_PRESENT_MASK, "P" }, \ |
| 47 | { PFERR_WRITE_MASK, "W" }, \ |
| 48 | { PFERR_USER_MASK, "U" }, \ |
| 49 | { PFERR_RSVD_MASK, "RSVD" }, \ |
| 50 | { PFERR_FETCH_MASK, "F" } |
| 51 | |
| 52 | /* |
| 53 | * A pagetable walk has started |
| 54 | */ |
| 55 | TRACE_EVENT( |
| 56 | kvm_mmu_pagetable_walk, |
| 57 | TP_PROTO(u64 addr, int write_fault, int user_fault, int fetch_fault), |
| 58 | TP_ARGS(addr, write_fault, user_fault, fetch_fault), |
| 59 | |
| 60 | TP_STRUCT__entry( |
| 61 | __field(__u64, addr) |
| 62 | __field(__u32, pferr) |
| 63 | ), |
| 64 | |
| 65 | TP_fast_assign( |
| 66 | __entry->addr = addr; |
| 67 | __entry->pferr = (!!write_fault << 1) | (!!user_fault << 2) |
| 68 | | (!!fetch_fault << 4); |
| 69 | ), |
| 70 | |
| 71 | TP_printk("addr %llx pferr %x %s", __entry->addr, __entry->pferr, |
| 72 | __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags)) |
| 73 | ); |
| 74 | |
| 75 | |
| 76 | /* We just walked a paging element */ |
| 77 | TRACE_EVENT( |
| 78 | kvm_mmu_paging_element, |
| 79 | TP_PROTO(u64 pte, int level), |
| 80 | TP_ARGS(pte, level), |
| 81 | |
| 82 | TP_STRUCT__entry( |
| 83 | __field(__u64, pte) |
| 84 | __field(__u32, level) |
| 85 | ), |
| 86 | |
| 87 | TP_fast_assign( |
| 88 | __entry->pte = pte; |
| 89 | __entry->level = level; |
| 90 | ), |
| 91 | |
| 92 | TP_printk("pte %llx level %u", __entry->pte, __entry->level) |
| 93 | ); |
| 94 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 95 | DECLARE_EVENT_CLASS(kvm_mmu_set_bit_class, |
| 96 | |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 97 | TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size), |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 98 | |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 99 | TP_ARGS(table_gfn, index, size), |
| 100 | |
| 101 | TP_STRUCT__entry( |
| 102 | __field(__u64, gpa) |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 103 | ), |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 104 | |
| 105 | TP_fast_assign( |
| 106 | __entry->gpa = ((u64)table_gfn << PAGE_SHIFT) |
| 107 | + index * size; |
| 108 | ), |
| 109 | |
| 110 | TP_printk("gpa %llx", __entry->gpa) |
| 111 | ); |
| 112 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 113 | /* We set a pte accessed bit */ |
| 114 | DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_accessed_bit, |
| 115 | |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 116 | TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size), |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 117 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 118 | TP_ARGS(table_gfn, index, size) |
| 119 | ); |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 120 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 121 | /* We set a pte dirty bit */ |
| 122 | DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_dirty_bit, |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 123 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 124 | TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size), |
| 125 | |
| 126 | TP_ARGS(table_gfn, index, size) |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 127 | ); |
| 128 | |
| 129 | TRACE_EVENT( |
| 130 | kvm_mmu_walker_error, |
| 131 | TP_PROTO(u32 pferr), |
| 132 | TP_ARGS(pferr), |
| 133 | |
| 134 | TP_STRUCT__entry( |
| 135 | __field(__u32, pferr) |
| 136 | ), |
| 137 | |
| 138 | TP_fast_assign( |
| 139 | __entry->pferr = pferr; |
| 140 | ), |
| 141 | |
| 142 | TP_printk("pferr %x %s", __entry->pferr, |
| 143 | __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags)) |
| 144 | ); |
| 145 | |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 146 | TRACE_EVENT( |
| 147 | kvm_mmu_get_page, |
| 148 | TP_PROTO(struct kvm_mmu_page *sp, bool created), |
| 149 | TP_ARGS(sp, created), |
| 150 | |
| 151 | TP_STRUCT__entry( |
| 152 | KVM_MMU_PAGE_FIELDS |
| 153 | __field(bool, created) |
| 154 | ), |
| 155 | |
| 156 | TP_fast_assign( |
| 157 | KVM_MMU_PAGE_ASSIGN(sp) |
| 158 | __entry->created = created; |
| 159 | ), |
| 160 | |
| 161 | TP_printk("%s %s", KVM_MMU_PAGE_PRINTK(), |
| 162 | __entry->created ? "new" : "existing") |
| 163 | ); |
| 164 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 165 | DECLARE_EVENT_CLASS(kvm_mmu_page_class, |
| 166 | |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 167 | TP_PROTO(struct kvm_mmu_page *sp), |
| 168 | TP_ARGS(sp), |
| 169 | |
| 170 | TP_STRUCT__entry( |
| 171 | KVM_MMU_PAGE_FIELDS |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 172 | ), |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 173 | |
| 174 | TP_fast_assign( |
| 175 | KVM_MMU_PAGE_ASSIGN(sp) |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 176 | ), |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 177 | |
| 178 | TP_printk("%s", KVM_MMU_PAGE_PRINTK()) |
| 179 | ); |
| 180 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 181 | DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_sync_page, |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 182 | TP_PROTO(struct kvm_mmu_page *sp), |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 183 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 184 | TP_ARGS(sp) |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 185 | ); |
| 186 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 187 | DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_unsync_page, |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 188 | TP_PROTO(struct kvm_mmu_page *sp), |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 189 | |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 190 | TP_ARGS(sp) |
Avi Kivity | f691fe1 | 2009-07-06 15:58:14 +0300 | [diff] [blame] | 191 | ); |
| 192 | |
Xiao Guangrong | 7775834 | 2010-06-04 21:53:54 +0800 | [diff] [blame] | 193 | DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_prepare_zap_page, |
Xiao Guangrong | 85f2067 | 2010-04-28 11:54:55 +0800 | [diff] [blame] | 194 | TP_PROTO(struct kvm_mmu_page *sp), |
| 195 | |
| 196 | TP_ARGS(sp) |
| 197 | ); |
Xiao Guangrong | 8b1fe17 | 2010-08-30 18:22:53 +0800 | [diff] [blame^] | 198 | |
| 199 | TRACE_EVENT( |
| 200 | kvm_mmu_audit, |
| 201 | TP_PROTO(struct kvm_vcpu *vcpu, int audit_point), |
| 202 | TP_ARGS(vcpu, audit_point), |
| 203 | |
| 204 | TP_STRUCT__entry( |
| 205 | __field(struct kvm_vcpu *, vcpu) |
| 206 | __field(int, audit_point) |
| 207 | ), |
| 208 | |
| 209 | TP_fast_assign( |
| 210 | __entry->vcpu = vcpu; |
| 211 | __entry->audit_point = audit_point; |
| 212 | ), |
| 213 | |
| 214 | TP_printk("vcpu:%d %s", __entry->vcpu->cpu, |
| 215 | audit_point_name[__entry->audit_point]) |
| 216 | ); |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 217 | #endif /* _TRACE_KVMMMU_H */ |
| 218 | |
Xiao Guangrong | 2ed152a | 2010-03-10 19:00:43 +0800 | [diff] [blame] | 219 | #undef TRACE_INCLUDE_PATH |
| 220 | #define TRACE_INCLUDE_PATH . |
| 221 | #undef TRACE_INCLUDE_FILE |
| 222 | #define TRACE_INCLUDE_FILE mmutrace |
| 223 | |
Avi Kivity | 0742017 | 2009-07-06 12:21:32 +0300 | [diff] [blame] | 224 | /* This part must be outside protection */ |
| 225 | #include <trace/define_trace.h> |