aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2016-06-14 04:40:12 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2016-06-14 05:16:23 -0400
commit1e09e86ac13747903501004082bf1c5b7c6262b2 (patch)
treebb2370949782c373983ce38d4db64286ff2dd0bb
parent04ebebf45a6ec61a4405040ea47c4320be5ed229 (diff)
MIPS: KVM: Clean up kvm_exit trace event
Clean up the MIPS kvm_exit trace event so that the exit reasons are specified in a trace friendly way (via __print_symbolic), and so that the exit reasons that derive straight from Cause.ExcCode values map directly, allowing a single trace_kvm_exit() call to replace a bunch of individual ones. Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: kvm@vger.kernel.org Cc: linux-mips@linux-mips.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/mips/include/asm/kvm_host.h22
-rw-r--r--arch/mips/kvm/emulate.c4
-rw-r--r--arch/mips/kvm/mips.c17
-rw-r--r--arch/mips/kvm/stats.c21
-rw-r--r--arch/mips/kvm/trace.h44
5 files changed, 45 insertions, 63 deletions
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index e6273850bab6..b8cb74270746 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -125,28 +125,6 @@ struct kvm_vcpu_stat {
125 u32 halt_wakeup; 125 u32 halt_wakeup;
126}; 126};
127 127
128enum kvm_mips_exit_types {
129 WAIT_EXITS,
130 CACHE_EXITS,
131 SIGNAL_EXITS,
132 INT_EXITS,
133 COP_UNUSABLE_EXITS,
134 TLBMOD_EXITS,
135 TLBMISS_LD_EXITS,
136 TLBMISS_ST_EXITS,
137 ADDRERR_ST_EXITS,
138 ADDRERR_LD_EXITS,
139 SYSCALL_EXITS,
140 RESVD_INST_EXITS,
141 BREAK_INST_EXITS,
142 TRAP_INST_EXITS,
143 MSA_FPE_EXITS,
144 FPE_EXITS,
145 MSA_DISABLED_EXITS,
146 FLUSH_DCACHE_EXITS,
147 MAX_KVM_MIPS_EXIT_TYPES
148};
149
150struct kvm_arch_memory_slot { 128struct kvm_arch_memory_slot {
151}; 129};
152 130
diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index 8647bd97b934..fce08bda9ebc 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -775,7 +775,7 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
775 vcpu->arch.pending_exceptions); 775 vcpu->arch.pending_exceptions);
776 776
777 ++vcpu->stat.wait_exits; 777 ++vcpu->stat.wait_exits;
778 trace_kvm_exit(vcpu, WAIT_EXITS); 778 trace_kvm_exit(vcpu, KVM_TRACE_EXIT_WAIT);
779 if (!vcpu->arch.pending_exceptions) { 779 if (!vcpu->arch.pending_exceptions) {
780 vcpu->arch.wait = 1; 780 vcpu->arch.wait = 1;
781 kvm_vcpu_block(vcpu); 781 kvm_vcpu_block(vcpu);
@@ -1718,7 +1718,7 @@ enum emulation_result kvm_mips_emulate_inst(u32 cause, u32 *opc,
1718 1718
1719 case cache_op: 1719 case cache_op:
1720 ++vcpu->stat.cache_exits; 1720 ++vcpu->stat.cache_exits;
1721 trace_kvm_exit(vcpu, CACHE_EXITS); 1721 trace_kvm_exit(vcpu, KVM_TRACE_EXIT_CACHE);
1722 er = kvm_mips_emulate_cache(inst, opc, cause, run, vcpu); 1722 er = kvm_mips_emulate_cache(inst, opc, cause, run, vcpu);
1723 break; 1723 break;
1724 1724
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index c0e8f8640f2b..e9e40b9dd9be 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -1257,6 +1257,7 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
1257 1257
1258 kvm_debug("kvm_mips_handle_exit: cause: %#x, PC: %p, kvm_run: %p, kvm_vcpu: %p\n", 1258 kvm_debug("kvm_mips_handle_exit: cause: %#x, PC: %p, kvm_run: %p, kvm_vcpu: %p\n",
1259 cause, opc, run, vcpu); 1259 cause, opc, run, vcpu);
1260 trace_kvm_exit(vcpu, exccode);
1260 1261
1261 /* 1262 /*
1262 * Do a privilege check, if in UM most of these exit conditions end up 1263 * Do a privilege check, if in UM most of these exit conditions end up
@@ -1276,7 +1277,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
1276 kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc); 1277 kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc);
1277 1278
1278 ++vcpu->stat.int_exits; 1279 ++vcpu->stat.int_exits;
1279 trace_kvm_exit(vcpu, INT_EXITS);
1280 1280
1281 if (need_resched()) 1281 if (need_resched())
1282 cond_resched(); 1282 cond_resched();
@@ -1288,7 +1288,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
1288 kvm_debug("EXCCODE_CPU: @ PC: %p\n", opc); 1288 kvm_debug("EXCCODE_CPU: @ PC: %p\n", opc);
1289 1289
1290 ++vcpu->stat.cop_unusable_exits; 1290 ++vcpu->stat.cop_unusable_exits;
1291 trace_kvm_exit(vcpu, COP_UNUSABLE_EXITS);
1292 ret = kvm_mips_callbacks->handle_cop_unusable(vcpu); 1291 ret = kvm_mips_callbacks->handle_cop_unusable(vcpu);
1293 /* XXXKYMA: Might need to return to user space */ 1292 /* XXXKYMA: Might need to return to user space */
1294 if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN) 1293 if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN)
@@ -1297,7 +1296,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
1297 1296
1298 case EXCCODE_MOD: 1297 case EXCCODE_MOD:
1299 ++vcpu->stat.tlbmod_exits; 1298 ++vcpu->stat.tlbmod_exits;
1300 trace_kvm_exit(vcpu, TLBMOD_EXITS);
1301 ret = kvm_mips_callbacks->handle_tlb_mod(vcpu); 1299 ret = kvm_mips_callbacks->handle_tlb_mod(vcpu);
1302 break; 1300 break;
1303 1301
@@ -1307,7 +1305,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
1307 badvaddr); 1305 badvaddr);
1308 1306
1309 ++vcpu->stat.tlbmiss_st_exits; 1307 ++vcpu->stat.tlbmiss_st_exits;
1310 trace_kvm_exit(vcpu, TLBMISS_ST_EXITS);
1311 ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu); 1308 ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu);
1312 break; 1309 break;
1313 1310
@@ -1316,61 +1313,51 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
1316 cause, opc, badvaddr); 1313 cause, opc, badvaddr);
1317 1314
1318 ++vcpu->stat.tlbmiss_ld_exits; 1315 ++vcpu->stat.tlbmiss_ld_exits;
1319 trace_kvm_exit(vcpu, TLBMISS_LD_EXITS);
1320 ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu); 1316 ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu);
1321 break; 1317 break;
1322 1318
1323 case EXCCODE_ADES: 1319 case EXCCODE_ADES:
1324 ++vcpu->stat.addrerr_st_exits; 1320 ++vcpu->stat.addrerr_st_exits;
1325 trace_kvm_exit(vcpu, ADDRERR_ST_EXITS);
1326 ret = kvm_mips_callbacks->handle_addr_err_st(vcpu); 1321 ret = kvm_mips_callbacks->handle_addr_err_st(vcpu);
1327 break; 1322 break;
1328 1323
1329 case EXCCODE_ADEL: 1324 case EXCCODE_ADEL:
1330 ++vcpu->stat.addrerr_ld_exits; 1325 ++vcpu->stat.addrerr_ld_exits;
1331 trace_kvm_exit(vcpu, ADDRERR_LD_EXITS);
1332 ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu); 1326 ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu);
1333 break; 1327 break;
1334 1328
1335 case EXCCODE_SYS: 1329 case EXCCODE_SYS:
1336 ++vcpu->stat.syscall_exits; 1330 ++vcpu->stat.syscall_exits;
1337 trace_kvm_exit(vcpu, SYSCALL_EXITS);
1338 ret = kvm_mips_callbacks->handle_syscall(vcpu); 1331 ret = kvm_mips_callbacks->handle_syscall(vcpu);
1339 break; 1332 break;
1340 1333
1341 case EXCCODE_RI: 1334 case EXCCODE_RI:
1342 ++vcpu->stat.resvd_inst_exits; 1335 ++vcpu->stat.resvd_inst_exits;
1343 trace_kvm_exit(vcpu, RESVD_INST_EXITS);
1344 ret = kvm_mips_callbacks->handle_res_inst(vcpu); 1336 ret = kvm_mips_callbacks->handle_res_inst(vcpu);
1345 break; 1337 break;
1346 1338
1347 case EXCCODE_BP: 1339 case EXCCODE_BP:
1348 ++vcpu->stat.break_inst_exits; 1340 ++vcpu->stat.break_inst_exits;
1349 trace_kvm_exit(vcpu, BREAK_INST_EXITS);
1350 ret = kvm_mips_callbacks->handle_break(vcpu); 1341 ret = kvm_mips_callbacks->handle_break(vcpu);
1351 break; 1342 break;
1352 1343
1353 case EXCCODE_TR: 1344 case EXCCODE_TR:
1354 ++vcpu->stat.trap_inst_exits; 1345 ++vcpu->stat.trap_inst_exits;
1355 trace_kvm_exit(vcpu, TRAP_INST_EXITS);
1356 ret = kvm_mips_callbacks->handle_trap(vcpu); 1346 ret = kvm_mips_callbacks->handle_trap(vcpu);
1357 break; 1347 break;
1358 1348
1359 case EXCCODE_MSAFPE: 1349 case EXCCODE_MSAFPE:
1360 ++vcpu->stat.msa_fpe_exits; 1350 ++vcpu->stat.msa_fpe_exits;
1361 trace_kvm_exit(vcpu, MSA_FPE_EXITS);
1362 ret = kvm_mips_callbacks->handle_msa_fpe(vcpu); 1351 ret = kvm_mips_callbacks->handle_msa_fpe(vcpu);
1363 break; 1352 break;
1364 1353
1365 case EXCCODE_FPE: 1354 case EXCCODE_FPE:
1366 ++vcpu->stat.fpe_exits; 1355 ++vcpu->stat.fpe_exits;
1367 trace_kvm_exit(vcpu, FPE_EXITS);
1368 ret = kvm_mips_callbacks->handle_fpe(vcpu); 1356 ret = kvm_mips_callbacks->handle_fpe(vcpu);
1369 break; 1357 break;
1370 1358
1371 case EXCCODE_MSADIS: 1359 case EXCCODE_MSADIS:
1372 ++vcpu->stat.msa_disabled_exits; 1360 ++vcpu->stat.msa_disabled_exits;
1373 trace_kvm_exit(vcpu, MSA_DISABLED_EXITS);
1374 ret = kvm_mips_callbacks->handle_msa_disabled(vcpu); 1361 ret = kvm_mips_callbacks->handle_msa_disabled(vcpu);
1375 break; 1362 break;
1376 1363
@@ -1397,7 +1384,7 @@ skip_emul:
1397 run->exit_reason = KVM_EXIT_INTR; 1384 run->exit_reason = KVM_EXIT_INTR;
1398 ret = (-EINTR << 2) | RESUME_HOST; 1385 ret = (-EINTR << 2) | RESUME_HOST;
1399 ++vcpu->stat.signal_exits; 1386 ++vcpu->stat.signal_exits;
1400 trace_kvm_exit(vcpu, SIGNAL_EXITS); 1387 trace_kvm_exit(vcpu, KVM_TRACE_EXIT_SIGNAL);
1401 } 1388 }
1402 } 1389 }
1403 1390
diff --git a/arch/mips/kvm/stats.c b/arch/mips/kvm/stats.c
index 888bb67070ac..53f851a61554 100644
--- a/arch/mips/kvm/stats.c
+++ b/arch/mips/kvm/stats.c
@@ -11,27 +11,6 @@
11 11
12#include <linux/kvm_host.h> 12#include <linux/kvm_host.h>
13 13
14char *kvm_mips_exit_types_str[MAX_KVM_MIPS_EXIT_TYPES] = {
15 "WAIT",
16 "CACHE",
17 "Signal",
18 "Interrupt",
19 "COP0/1 Unusable",
20 "TLB Mod",
21 "TLB Miss (LD)",
22 "TLB Miss (ST)",
23 "Address Err (ST)",
24 "Address Error (LD)",
25 "System Call",
26 "Reserved Inst",
27 "Break Inst",
28 "Trap Inst",
29 "MSA FPE",
30 "FPE",
31 "MSA Disabled",
32 "D-Cache Flushes",
33};
34
35char *kvm_cop0_str[N_MIPS_COPROC_REGS] = { 14char *kvm_cop0_str[N_MIPS_COPROC_REGS] = {
36 "Index", 15 "Index",
37 "Random", 16 "Random",
diff --git a/arch/mips/kvm/trace.h b/arch/mips/kvm/trace.h
index f3ada591ca25..ffa6ee8f2025 100644
--- a/arch/mips/kvm/trace.h
+++ b/arch/mips/kvm/trace.h
@@ -17,8 +17,45 @@
17#define TRACE_INCLUDE_PATH . 17#define TRACE_INCLUDE_PATH .
18#define TRACE_INCLUDE_FILE trace 18#define TRACE_INCLUDE_FILE trace
19 19
20/* Tracepoints for VM eists */ 20/* The first 32 exit reasons correspond to Cause.ExcCode */
21extern char *kvm_mips_exit_types_str[MAX_KVM_MIPS_EXIT_TYPES]; 21#define KVM_TRACE_EXIT_INT 0
22#define KVM_TRACE_EXIT_TLBMOD 1
23#define KVM_TRACE_EXIT_TLBMISS_LD 2
24#define KVM_TRACE_EXIT_TLBMISS_ST 3
25#define KVM_TRACE_EXIT_ADDRERR_LD 4
26#define KVM_TRACE_EXIT_ADDRERR_ST 5
27#define KVM_TRACE_EXIT_SYSCALL 8
28#define KVM_TRACE_EXIT_BREAK_INST 9
29#define KVM_TRACE_EXIT_RESVD_INST 10
30#define KVM_TRACE_EXIT_COP_UNUSABLE 11
31#define KVM_TRACE_EXIT_TRAP_INST 13
32#define KVM_TRACE_EXIT_MSA_FPE 14
33#define KVM_TRACE_EXIT_FPE 15
34#define KVM_TRACE_EXIT_MSA_DISABLED 21
35/* Further exit reasons */
36#define KVM_TRACE_EXIT_WAIT 32
37#define KVM_TRACE_EXIT_CACHE 33
38#define KVM_TRACE_EXIT_SIGNAL 34
39
40/* Tracepoints for VM exits */
41#define kvm_trace_symbol_exit_types \
42 { KVM_TRACE_EXIT_INT, "Interrupt" }, \
43 { KVM_TRACE_EXIT_TLBMOD, "TLB Mod" }, \
44 { KVM_TRACE_EXIT_TLBMISS_LD, "TLB Miss (LD)" }, \
45 { KVM_TRACE_EXIT_TLBMISS_ST, "TLB Miss (ST)" }, \
46 { KVM_TRACE_EXIT_ADDRERR_LD, "Address Error (LD)" }, \
47 { KVM_TRACE_EXIT_ADDRERR_ST, "Address Err (ST)" }, \
48 { KVM_TRACE_EXIT_SYSCALL, "System Call" }, \
49 { KVM_TRACE_EXIT_BREAK_INST, "Break Inst" }, \
50 { KVM_TRACE_EXIT_RESVD_INST, "Reserved Inst" }, \
51 { KVM_TRACE_EXIT_COP_UNUSABLE, "COP0/1 Unusable" }, \
52 { KVM_TRACE_EXIT_TRAP_INST, "Trap Inst" }, \
53 { KVM_TRACE_EXIT_MSA_FPE, "MSA FPE" }, \
54 { KVM_TRACE_EXIT_FPE, "FPE" }, \
55 { KVM_TRACE_EXIT_MSA_DISABLED, "MSA Disabled" }, \
56 { KVM_TRACE_EXIT_WAIT, "WAIT" }, \
57 { KVM_TRACE_EXIT_CACHE, "CACHE" }, \
58 { KVM_TRACE_EXIT_SIGNAL, "Signal" }
22 59
23TRACE_EVENT(kvm_exit, 60TRACE_EVENT(kvm_exit,
24 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), 61 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
@@ -34,7 +71,8 @@ TRACE_EVENT(kvm_exit,
34 ), 71 ),
35 72
36 TP_printk("[%s]PC: 0x%08lx", 73 TP_printk("[%s]PC: 0x%08lx",
37 kvm_mips_exit_types_str[__entry->reason], 74 __print_symbolic(__entry->reason,
75 kvm_trace_symbol_exit_types),
38 __entry->pc) 76 __entry->pc)
39); 77);
40 78