diff options
author | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2011-07-22 07:46:53 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-09-25 12:17:59 -0400 |
commit | 0d460ffc0956d2dbe12ca9f5f6aa0f8701ea9d73 (patch) | |
tree | 043ba67b92ac023b36bde109f15f5cff9d1c0091 /arch/x86/kvm | |
parent | e097e5ffd69cbd7be61466e2d54c145468d48073 (diff) |
KVM: Use __print_symbolic() for vmexit tracepoints
The vmexit tracepoints format the exit_reason to make it human-readable.
Since the exit_reason depends on the instruction set (vmx or svm),
formatting is handled with ftrace_print_symbols_seq() by referring to
the appropriate exit reason table.
However, the ftrace_print_symbols_seq() function is not meant to be used
directly in tracepoints since it does not export the formatting table
which userspace tools like trace-cmd and perf use to format traces.
In practice perf dies when formatting vmexit-related events and
trace-cmd falls back to printing the numeric value (with extra
formatting code in the kvm plugin to paper over this limitation). Other
userspace consumers of vmexit-related tracepoints would be in similar
trouble.
To avoid significant changes to the kvm_exit tracepoint, this patch
moves the vmx and svm exit reason tables into arch/x86/kvm/trace.h and
selects the right table with __print_symbolic() depending on the
instruction set. Note that __print_symbolic() is designed for exporting
the formatting table to userspace and allows trace-cmd and perf to work.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/svm.c | 55 | ||||
-rw-r--r-- | arch/x86/kvm/trace.h | 106 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 44 |
3 files changed, 100 insertions, 105 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 6adb7ba13a4..2b24a88f2c6 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -3899,60 +3899,6 @@ static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) | |||
3899 | } | 3899 | } |
3900 | } | 3900 | } |
3901 | 3901 | ||
3902 | static const struct trace_print_flags svm_exit_reasons_str[] = { | ||
3903 | { SVM_EXIT_READ_CR0, "read_cr0" }, | ||
3904 | { SVM_EXIT_READ_CR3, "read_cr3" }, | ||
3905 | { SVM_EXIT_READ_CR4, "read_cr4" }, | ||
3906 | { SVM_EXIT_READ_CR8, "read_cr8" }, | ||
3907 | { SVM_EXIT_WRITE_CR0, "write_cr0" }, | ||
3908 | { SVM_EXIT_WRITE_CR3, "write_cr3" }, | ||
3909 | { SVM_EXIT_WRITE_CR4, "write_cr4" }, | ||
3910 | { SVM_EXIT_WRITE_CR8, "write_cr8" }, | ||
3911 | { SVM_EXIT_READ_DR0, "read_dr0" }, | ||
3912 | { SVM_EXIT_READ_DR1, "read_dr1" }, | ||
3913 | { SVM_EXIT_READ_DR2, "read_dr2" }, | ||
3914 | { SVM_EXIT_READ_DR3, "read_dr3" }, | ||
3915 | { SVM_EXIT_WRITE_DR0, "write_dr0" }, | ||
3916 | { SVM_EXIT_WRITE_DR1, "write_dr1" }, | ||
3917 | { SVM_EXIT_WRITE_DR2, "write_dr2" }, | ||
3918 | { SVM_EXIT_WRITE_DR3, "write_dr3" }, | ||
3919 | { SVM_EXIT_WRITE_DR5, "write_dr5" }, | ||
3920 | { SVM_EXIT_WRITE_DR7, "write_dr7" }, | ||
3921 | { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, | ||
3922 | { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, | ||
3923 | { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, | ||
3924 | { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, | ||
3925 | { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, | ||
3926 | { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, | ||
3927 | { SVM_EXIT_INTR, "interrupt" }, | ||
3928 | { SVM_EXIT_NMI, "nmi" }, | ||
3929 | { SVM_EXIT_SMI, "smi" }, | ||
3930 | { SVM_EXIT_INIT, "init" }, | ||
3931 | { SVM_EXIT_VINTR, "vintr" }, | ||
3932 | { SVM_EXIT_CPUID, "cpuid" }, | ||
3933 | { SVM_EXIT_INVD, "invd" }, | ||
3934 | { SVM_EXIT_HLT, "hlt" }, | ||
3935 | { SVM_EXIT_INVLPG, "invlpg" }, | ||
3936 | { SVM_EXIT_INVLPGA, "invlpga" }, | ||
3937 | { SVM_EXIT_IOIO, "io" }, | ||
3938 | { SVM_EXIT_MSR, "msr" }, | ||
3939 | { SVM_EXIT_TASK_SWITCH, "task_switch" }, | ||
3940 | { SVM_EXIT_SHUTDOWN, "shutdown" }, | ||
3941 | { SVM_EXIT_VMRUN, "vmrun" }, | ||
3942 | { SVM_EXIT_VMMCALL, "hypercall" }, | ||
3943 | { SVM_EXIT_VMLOAD, "vmload" }, | ||
3944 | { SVM_EXIT_VMSAVE, "vmsave" }, | ||
3945 | { SVM_EXIT_STGI, "stgi" }, | ||
3946 | { SVM_EXIT_CLGI, "clgi" }, | ||
3947 | { SVM_EXIT_SKINIT, "skinit" }, | ||
3948 | { SVM_EXIT_WBINVD, "wbinvd" }, | ||
3949 | { SVM_EXIT_MONITOR, "monitor" }, | ||
3950 | { SVM_EXIT_MWAIT, "mwait" }, | ||
3951 | { SVM_EXIT_XSETBV, "xsetbv" }, | ||
3952 | { SVM_EXIT_NPF, "npf" }, | ||
3953 | { -1, NULL } | ||
3954 | }; | ||
3955 | |||
3956 | static int svm_get_lpage_level(void) | 3902 | static int svm_get_lpage_level(void) |
3957 | { | 3903 | { |
3958 | return PT_PDPE_LEVEL; | 3904 | return PT_PDPE_LEVEL; |
@@ -4225,7 +4171,6 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
4225 | .get_mt_mask = svm_get_mt_mask, | 4171 | .get_mt_mask = svm_get_mt_mask, |
4226 | 4172 | ||
4227 | .get_exit_info = svm_get_exit_info, | 4173 | .get_exit_info = svm_get_exit_info, |
4228 | .exit_reasons_str = svm_exit_reasons_str, | ||
4229 | 4174 | ||
4230 | .get_lpage_level = svm_get_lpage_level, | 4175 | .get_lpage_level = svm_get_lpage_level, |
4231 | 4176 | ||
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 4e1716bf88a..911d2641f14 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h | |||
@@ -2,6 +2,8 @@ | |||
2 | #define _TRACE_KVM_H | 2 | #define _TRACE_KVM_H |
3 | 3 | ||
4 | #include <linux/tracepoint.h> | 4 | #include <linux/tracepoint.h> |
5 | #include <asm/vmx.h> | ||
6 | #include <asm/svm.h> | ||
5 | 7 | ||
6 | #undef TRACE_SYSTEM | 8 | #undef TRACE_SYSTEM |
7 | #define TRACE_SYSTEM kvm | 9 | #define TRACE_SYSTEM kvm |
@@ -181,6 +183,95 @@ TRACE_EVENT(kvm_apic, | |||
181 | #define KVM_ISA_VMX 1 | 183 | #define KVM_ISA_VMX 1 |
182 | #define KVM_ISA_SVM 2 | 184 | #define KVM_ISA_SVM 2 |
183 | 185 | ||
186 | #define VMX_EXIT_REASONS \ | ||
187 | { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ | ||
188 | { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, \ | ||
189 | { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, \ | ||
190 | { EXIT_REASON_PENDING_INTERRUPT, "PENDING_INTERRUPT" }, \ | ||
191 | { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, \ | ||
192 | { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, \ | ||
193 | { EXIT_REASON_CPUID, "CPUID" }, \ | ||
194 | { EXIT_REASON_HLT, "HLT" }, \ | ||
195 | { EXIT_REASON_INVLPG, "INVLPG" }, \ | ||
196 | { EXIT_REASON_RDPMC, "RDPMC" }, \ | ||
197 | { EXIT_REASON_RDTSC, "RDTSC" }, \ | ||
198 | { EXIT_REASON_VMCALL, "VMCALL" }, \ | ||
199 | { EXIT_REASON_VMCLEAR, "VMCLEAR" }, \ | ||
200 | { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, \ | ||
201 | { EXIT_REASON_VMPTRLD, "VMPTRLD" }, \ | ||
202 | { EXIT_REASON_VMPTRST, "VMPTRST" }, \ | ||
203 | { EXIT_REASON_VMREAD, "VMREAD" }, \ | ||
204 | { EXIT_REASON_VMRESUME, "VMRESUME" }, \ | ||
205 | { EXIT_REASON_VMWRITE, "VMWRITE" }, \ | ||
206 | { EXIT_REASON_VMOFF, "VMOFF" }, \ | ||
207 | { EXIT_REASON_VMON, "VMON" }, \ | ||
208 | { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, \ | ||
209 | { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, \ | ||
210 | { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, \ | ||
211 | { EXIT_REASON_MSR_READ, "MSR_READ" }, \ | ||
212 | { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, \ | ||
213 | { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, \ | ||
214 | { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, \ | ||
215 | { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, \ | ||
216 | { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, \ | ||
217 | { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, \ | ||
218 | { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, \ | ||
219 | { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, \ | ||
220 | { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, \ | ||
221 | { EXIT_REASON_WBINVD, "WBINVD" } | ||
222 | |||
223 | #define SVM_EXIT_REASONS \ | ||
224 | { SVM_EXIT_READ_CR0, "read_cr0" }, \ | ||
225 | { SVM_EXIT_READ_CR3, "read_cr3" }, \ | ||
226 | { SVM_EXIT_READ_CR4, "read_cr4" }, \ | ||
227 | { SVM_EXIT_READ_CR8, "read_cr8" }, \ | ||
228 | { SVM_EXIT_WRITE_CR0, "write_cr0" }, \ | ||
229 | { SVM_EXIT_WRITE_CR3, "write_cr3" }, \ | ||
230 | { SVM_EXIT_WRITE_CR4, "write_cr4" }, \ | ||
231 | { SVM_EXIT_WRITE_CR8, "write_cr8" }, \ | ||
232 | { SVM_EXIT_READ_DR0, "read_dr0" }, \ | ||
233 | { SVM_EXIT_READ_DR1, "read_dr1" }, \ | ||
234 | { SVM_EXIT_READ_DR2, "read_dr2" }, \ | ||
235 | { SVM_EXIT_READ_DR3, "read_dr3" }, \ | ||
236 | { SVM_EXIT_WRITE_DR0, "write_dr0" }, \ | ||
237 | { SVM_EXIT_WRITE_DR1, "write_dr1" }, \ | ||
238 | { SVM_EXIT_WRITE_DR2, "write_dr2" }, \ | ||
239 | { SVM_EXIT_WRITE_DR3, "write_dr3" }, \ | ||
240 | { SVM_EXIT_WRITE_DR5, "write_dr5" }, \ | ||
241 | { SVM_EXIT_WRITE_DR7, "write_dr7" }, \ | ||
242 | { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, \ | ||
243 | { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, \ | ||
244 | { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, \ | ||
245 | { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, \ | ||
246 | { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, \ | ||
247 | { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, \ | ||
248 | { SVM_EXIT_INTR, "interrupt" }, \ | ||
249 | { SVM_EXIT_NMI, "nmi" }, \ | ||
250 | { SVM_EXIT_SMI, "smi" }, \ | ||
251 | { SVM_EXIT_INIT, "init" }, \ | ||
252 | { SVM_EXIT_VINTR, "vintr" }, \ | ||
253 | { SVM_EXIT_CPUID, "cpuid" }, \ | ||
254 | { SVM_EXIT_INVD, "invd" }, \ | ||
255 | { SVM_EXIT_HLT, "hlt" }, \ | ||
256 | { SVM_EXIT_INVLPG, "invlpg" }, \ | ||
257 | { SVM_EXIT_INVLPGA, "invlpga" }, \ | ||
258 | { SVM_EXIT_IOIO, "io" }, \ | ||
259 | { SVM_EXIT_MSR, "msr" }, \ | ||
260 | { SVM_EXIT_TASK_SWITCH, "task_switch" }, \ | ||
261 | { SVM_EXIT_SHUTDOWN, "shutdown" }, \ | ||
262 | { SVM_EXIT_VMRUN, "vmrun" }, \ | ||
263 | { SVM_EXIT_VMMCALL, "hypercall" }, \ | ||
264 | { SVM_EXIT_VMLOAD, "vmload" }, \ | ||
265 | { SVM_EXIT_VMSAVE, "vmsave" }, \ | ||
266 | { SVM_EXIT_STGI, "stgi" }, \ | ||
267 | { SVM_EXIT_CLGI, "clgi" }, \ | ||
268 | { SVM_EXIT_SKINIT, "skinit" }, \ | ||
269 | { SVM_EXIT_WBINVD, "wbinvd" }, \ | ||
270 | { SVM_EXIT_MONITOR, "monitor" }, \ | ||
271 | { SVM_EXIT_MWAIT, "mwait" }, \ | ||
272 | { SVM_EXIT_XSETBV, "xsetbv" }, \ | ||
273 | { SVM_EXIT_NPF, "npf" } | ||
274 | |||
184 | /* | 275 | /* |
185 | * Tracepoint for kvm guest exit: | 276 | * Tracepoint for kvm guest exit: |
186 | */ | 277 | */ |
@@ -205,8 +296,9 @@ TRACE_EVENT(kvm_exit, | |||
205 | ), | 296 | ), |
206 | 297 | ||
207 | TP_printk("reason %s rip 0x%lx info %llx %llx", | 298 | TP_printk("reason %s rip 0x%lx info %llx %llx", |
208 | ftrace_print_symbols_seq(p, __entry->exit_reason, | 299 | (__entry->isa == KVM_ISA_VMX) ? |
209 | kvm_x86_ops->exit_reasons_str), | 300 | __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) : |
301 | __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS), | ||
210 | __entry->guest_rip, __entry->info1, __entry->info2) | 302 | __entry->guest_rip, __entry->info1, __entry->info2) |
211 | ); | 303 | ); |
212 | 304 | ||
@@ -512,8 +604,9 @@ TRACE_EVENT(kvm_nested_vmexit, | |||
512 | TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx " | 604 | TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx " |
513 | "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", | 605 | "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", |
514 | __entry->rip, | 606 | __entry->rip, |
515 | ftrace_print_symbols_seq(p, __entry->exit_code, | 607 | (__entry->isa == KVM_ISA_VMX) ? |
516 | kvm_x86_ops->exit_reasons_str), | 608 | __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) : |
609 | __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS), | ||
517 | __entry->exit_info1, __entry->exit_info2, | 610 | __entry->exit_info1, __entry->exit_info2, |
518 | __entry->exit_int_info, __entry->exit_int_info_err) | 611 | __entry->exit_int_info, __entry->exit_int_info_err) |
519 | ); | 612 | ); |
@@ -548,8 +641,9 @@ TRACE_EVENT(kvm_nested_vmexit_inject, | |||
548 | 641 | ||
549 | TP_printk("reason: %s ext_inf1: 0x%016llx " | 642 | TP_printk("reason: %s ext_inf1: 0x%016llx " |
550 | "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", | 643 | "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x", |
551 | ftrace_print_symbols_seq(p, __entry->exit_code, | 644 | (__entry->isa == KVM_ISA_VMX) ? |
552 | kvm_x86_ops->exit_reasons_str), | 645 | __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) : |
646 | __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS), | ||
553 | __entry->exit_info1, __entry->exit_info2, | 647 | __entry->exit_info1, __entry->exit_info2, |
554 | __entry->exit_int_info, __entry->exit_int_info_err) | 648 | __entry->exit_int_info, __entry->exit_int_info_err) |
555 | ); | 649 | ); |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e65a158dee6..e26629fbf1d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -6241,49 +6241,6 @@ static u64 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) | |||
6241 | return ret; | 6241 | return ret; |
6242 | } | 6242 | } |
6243 | 6243 | ||
6244 | #define _ER(x) { EXIT_REASON_##x, #x } | ||
6245 | |||
6246 | static const struct trace_print_flags vmx_exit_reasons_str[] = { | ||
6247 | _ER(EXCEPTION_NMI), | ||
6248 | _ER(EXTERNAL_INTERRUPT), | ||
6249 | _ER(TRIPLE_FAULT), | ||
6250 | _ER(PENDING_INTERRUPT), | ||
6251 | _ER(NMI_WINDOW), | ||
6252 | _ER(TASK_SWITCH), | ||
6253 | _ER(CPUID), | ||
6254 | _ER(HLT), | ||
6255 | _ER(INVLPG), | ||
6256 | _ER(RDPMC), | ||
6257 | _ER(RDTSC), | ||
6258 | _ER(VMCALL), | ||
6259 | _ER(VMCLEAR), | ||
6260 | _ER(VMLAUNCH), | ||
6261 | _ER(VMPTRLD), | ||
6262 | _ER(VMPTRST), | ||
6263 | _ER(VMREAD), | ||
6264 | _ER(VMRESUME), | ||
6265 | _ER(VMWRITE), | ||
6266 | _ER(VMOFF), | ||
6267 | _ER(VMON), | ||
6268 | _ER(CR_ACCESS), | ||
6269 | _ER(DR_ACCESS), | ||
6270 | _ER(IO_INSTRUCTION), | ||
6271 | _ER(MSR_READ), | ||
6272 | _ER(MSR_WRITE), | ||
6273 | _ER(MWAIT_INSTRUCTION), | ||
6274 | _ER(MONITOR_INSTRUCTION), | ||
6275 | _ER(PAUSE_INSTRUCTION), | ||
6276 | _ER(MCE_DURING_VMENTRY), | ||
6277 | _ER(TPR_BELOW_THRESHOLD), | ||
6278 | _ER(APIC_ACCESS), | ||
6279 | _ER(EPT_VIOLATION), | ||
6280 | _ER(EPT_MISCONFIG), | ||
6281 | _ER(WBINVD), | ||
6282 | { -1, NULL } | ||
6283 | }; | ||
6284 | |||
6285 | #undef _ER | ||
6286 | |||
6287 | static int vmx_get_lpage_level(void) | 6244 | static int vmx_get_lpage_level(void) |
6288 | { | 6245 | { |
6289 | if (enable_ept && !cpu_has_vmx_ept_1g_page()) | 6246 | if (enable_ept && !cpu_has_vmx_ept_1g_page()) |
@@ -7039,7 +6996,6 @@ static struct kvm_x86_ops vmx_x86_ops = { | |||
7039 | .get_mt_mask = vmx_get_mt_mask, | 6996 | .get_mt_mask = vmx_get_mt_mask, |
7040 | 6997 | ||
7041 | .get_exit_info = vmx_get_exit_info, | 6998 | .get_exit_info = vmx_get_exit_info, |
7042 | .exit_reasons_str = vmx_exit_reasons_str, | ||
7043 | 6999 | ||
7044 | .get_lpage_level = vmx_get_lpage_level, | 7000 | .get_lpage_level = vmx_get_lpage_level, |
7045 | 7001 | ||