blob: 40a1786f36c7e5d33e8a215f48816cfad47c81c0 [file] [log] [blame]
Avi Kivity07420172009-07-06 12:21:32 +03001#if !defined(_TRACE_KVMMMU_H) || defined(TRACE_HEADER_MULTI_READ)
2#define _TRACE_KVMMMU_H
3
4#include <linux/tracepoint.h>
Avi Kivityf691fe12009-07-06 15:58:14 +03005#include <linux/ftrace_event.h>
Avi Kivity07420172009-07-06 12:21:32 +03006
7#undef TRACE_SYSTEM
8#define TRACE_SYSTEM kvmmmu
Avi Kivity07420172009-07-06 12:21:32 +03009
Avi Kivityf691fe12009-07-06 15:58:14 +030010#define KVM_MMU_PAGE_FIELDS \
11 __field(__u64, gfn) \
12 __field(__u32, role) \
13 __field(__u32, root_count) \
Gui Jianfengdf2fb6e2010-04-22 17:33:57 +080014 __field(bool, unsync)
Avi Kivityf691fe12009-07-06 15:58:14 +030015
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 Kivity87bc3bf2010-04-19 17:25:53 +030031 trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s" \
Avi Kivityf691fe12009-07-06 15:58:14 +030032 " %snxe root %u %s%c", \
Avi Kivity5b7e0102010-04-14 19:20:03 +030033 __entry->gfn, role.level, \
34 role.cr4_pae ? " pae" : "", \
Avi Kivityf691fe12009-07-06 15:58:14 +030035 role.quadrant, \
36 role.direct ? " direct" : "", \
37 access_str[role.access], \
38 role.invalid ? " invalid" : "", \
Avi Kivityf691fe12009-07-06 15:58:14 +030039 role.nxe ? "" : "!", \
40 __entry->root_count, \
41 __entry->unsync ? "unsync" : "sync", 0); \
42 ret; \
43 })
44
Avi Kivity07420172009-07-06 12:21:32 +030045#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 */
55TRACE_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 */
77TRACE_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
95/* We set a pte accessed bit */
96TRACE_EVENT(
97 kvm_mmu_set_accessed_bit,
98 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
99 TP_ARGS(table_gfn, index, size),
100
101 TP_STRUCT__entry(
102 __field(__u64, gpa)
103 ),
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
113/* We set a pte dirty bit */
114TRACE_EVENT(
115 kvm_mmu_set_dirty_bit,
116 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
117 TP_ARGS(table_gfn, index, size),
118
119 TP_STRUCT__entry(
120 __field(__u64, gpa)
121 ),
122
123 TP_fast_assign(
124 __entry->gpa = ((u64)table_gfn << PAGE_SHIFT)
125 + index * size;
126 ),
127
128 TP_printk("gpa %llx", __entry->gpa)
129);
130
131TRACE_EVENT(
132 kvm_mmu_walker_error,
133 TP_PROTO(u32 pferr),
134 TP_ARGS(pferr),
135
136 TP_STRUCT__entry(
137 __field(__u32, pferr)
138 ),
139
140 TP_fast_assign(
141 __entry->pferr = pferr;
142 ),
143
144 TP_printk("pferr %x %s", __entry->pferr,
145 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
146);
147
Avi Kivityf691fe12009-07-06 15:58:14 +0300148TRACE_EVENT(
149 kvm_mmu_get_page,
150 TP_PROTO(struct kvm_mmu_page *sp, bool created),
151 TP_ARGS(sp, created),
152
153 TP_STRUCT__entry(
154 KVM_MMU_PAGE_FIELDS
155 __field(bool, created)
156 ),
157
158 TP_fast_assign(
159 KVM_MMU_PAGE_ASSIGN(sp)
160 __entry->created = created;
161 ),
162
163 TP_printk("%s %s", KVM_MMU_PAGE_PRINTK(),
164 __entry->created ? "new" : "existing")
165);
166
167TRACE_EVENT(
168 kvm_mmu_sync_page,
169 TP_PROTO(struct kvm_mmu_page *sp),
170 TP_ARGS(sp),
171
172 TP_STRUCT__entry(
173 KVM_MMU_PAGE_FIELDS
174 ),
175
176 TP_fast_assign(
177 KVM_MMU_PAGE_ASSIGN(sp)
178 ),
179
180 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
181);
182
183TRACE_EVENT(
184 kvm_mmu_unsync_page,
185 TP_PROTO(struct kvm_mmu_page *sp),
186 TP_ARGS(sp),
187
188 TP_STRUCT__entry(
189 KVM_MMU_PAGE_FIELDS
190 ),
191
192 TP_fast_assign(
193 KVM_MMU_PAGE_ASSIGN(sp)
194 ),
195
196 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
197);
198
199TRACE_EVENT(
200 kvm_mmu_zap_page,
201 TP_PROTO(struct kvm_mmu_page *sp),
202 TP_ARGS(sp),
203
204 TP_STRUCT__entry(
205 KVM_MMU_PAGE_FIELDS
206 ),
207
208 TP_fast_assign(
209 KVM_MMU_PAGE_ASSIGN(sp)
210 ),
211
212 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
213);
214
Avi Kivity07420172009-07-06 12:21:32 +0300215#endif /* _TRACE_KVMMMU_H */
216
Xiao Guangrong2ed152a2010-03-10 19:00:43 +0800217#undef TRACE_INCLUDE_PATH
218#define TRACE_INCLUDE_PATH .
219#undef TRACE_INCLUDE_FILE
220#define TRACE_INCLUDE_FILE mmutrace
221
Avi Kivity07420172009-07-06 12:21:32 +0300222/* This part must be outside protection */
223#include <trace/define_trace.h>