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