Skip to content

Commit 46f43c6

Browse files
matosattiavikivity
authored andcommitted
KVM: powerpc: convert marker probes to event trace
[avi: make it build] [avi: fold trace-arch.h into trace.h] CC: Hollis Blanchard <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent ed85c06 commit 46f43c6

File tree

6 files changed

+126
-15
lines changed

6 files changed

+126
-15
lines changed

arch/powerpc/kvm/44x_tlb.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "timing.h"
3131

3232
#include "44x_tlb.h"
33+
#include "trace.h"
3334

3435
#ifndef PPC44x_TLBE_SIZE
3536
#define PPC44x_TLBE_SIZE PPC44x_TLB_4K
@@ -263,7 +264,7 @@ static void kvmppc_44x_shadow_release(struct kvmppc_vcpu_44x *vcpu_44x,
263264

264265
/* XXX set tlb_44x_index to stlb_index? */
265266

266-
KVMTRACE_1D(STLB_INVAL, &vcpu_44x->vcpu, stlb_index, handler);
267+
trace_kvm_stlb_inval(stlb_index);
267268
}
268269

269270
void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu)
@@ -365,8 +366,8 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr,
365366
/* Insert shadow mapping into hardware TLB. */
366367
kvmppc_44x_tlbe_set_modified(vcpu_44x, victim);
367368
kvmppc_44x_tlbwe(victim, &stlbe);
368-
KVMTRACE_5D(STLB_WRITE, vcpu, victim, stlbe.tid, stlbe.word0, stlbe.word1,
369-
stlbe.word2, handler);
369+
trace_kvm_stlb_write(victim, stlbe.tid, stlbe.word0, stlbe.word1,
370+
stlbe.word2);
370371
}
371372

372373
/* For a particular guest TLB entry, invalidate the corresponding host TLB
@@ -485,8 +486,8 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws)
485486
kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index);
486487
}
487488

488-
KVMTRACE_5D(GTLB_WRITE, vcpu, gtlb_index, tlbe->tid, tlbe->word0,
489-
tlbe->word1, tlbe->word2, handler);
489+
trace_kvm_gtlb_write(gtlb_index, tlbe->tid, tlbe->word0, tlbe->word1,
490+
tlbe->word2);
490491

491492
kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS);
492493
return EMULATE_DONE;

arch/powerpc/kvm/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o)
1010

1111
common-objs-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o)
1212

13+
CFLAGS_44x_tlb.o := -I.
14+
CFLAGS_e500_tlb.o := -I.
15+
CFLAGS_emulate.o := -I.
16+
1317
kvm-objs := $(common-objs-y) powerpc.o emulate.o
1418
obj-$(CONFIG_KVM_EXIT_TIMING) += timing.o
1519
obj-$(CONFIG_KVM) += kvm.o

arch/powerpc/kvm/e500_tlb.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "../mm/mmu_decl.h"
2424
#include "e500_tlb.h"
25+
#include "trace.h"
2526

2627
#define to_htlb1_esel(esel) (tlb1_entry_num - (esel) - 1)
2728

@@ -224,9 +225,8 @@ static void kvmppc_e500_stlbe_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
224225

225226
kvmppc_e500_shadow_release(vcpu_e500, tlbsel, esel);
226227
stlbe->mas1 = 0;
227-
KVMTRACE_5D(STLB_INVAL, &vcpu_e500->vcpu, index_of(tlbsel, esel),
228-
stlbe->mas1, stlbe->mas2, stlbe->mas3, stlbe->mas7,
229-
handler);
228+
trace_kvm_stlb_inval(index_of(tlbsel, esel), stlbe->mas1, stlbe->mas2,
229+
stlbe->mas3, stlbe->mas7);
230230
}
231231

232232
static void kvmppc_e500_tlb1_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
@@ -319,9 +319,8 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
319319
vcpu_e500->vcpu.arch.msr & MSR_PR);
320320
stlbe->mas7 = (hpaddr >> 32) & MAS7_RPN;
321321

322-
KVMTRACE_5D(STLB_WRITE, &vcpu_e500->vcpu, index_of(tlbsel, esel),
323-
stlbe->mas1, stlbe->mas2, stlbe->mas3, stlbe->mas7,
324-
handler);
322+
trace_kvm_stlb_write(index_of(tlbsel, esel), stlbe->mas1, stlbe->mas2,
323+
stlbe->mas3, stlbe->mas7);
325324
}
326325

327326
/* XXX only map the one-one case, for now use TLB0 */
@@ -535,9 +534,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
535534
gtlbe->mas3 = vcpu_e500->mas3;
536535
gtlbe->mas7 = vcpu_e500->mas7;
537536

538-
KVMTRACE_5D(GTLB_WRITE, vcpu, vcpu_e500->mas0,
539-
gtlbe->mas1, gtlbe->mas2, gtlbe->mas3, gtlbe->mas7,
540-
handler);
537+
trace_kvm_gtlb_write(vcpu_e500->mas0, gtlbe->mas1, gtlbe->mas2,
538+
gtlbe->mas3, gtlbe->mas7);
541539

542540
/* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */
543541
if (tlbe_is_host_safe(vcpu, gtlbe)) {

arch/powerpc/kvm/emulate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <asm/kvm_ppc.h>
3030
#include <asm/disassemble.h>
3131
#include "timing.h"
32+
#include "trace.h"
3233

3334
#define OP_TRAP 3
3435

@@ -419,7 +420,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
419420
}
420421
}
421422

422-
KVMTRACE_3D(PPC_INSTR, vcpu, inst, (int)vcpu->arch.pc, emulated, entryexit);
423+
trace_kvm_ppc_instr(inst, vcpu->arch.pc, emulated);
423424

424425
if (advance)
425426
vcpu->arch.pc += 4; /* Advance past emulated instruction. */

arch/powerpc/kvm/powerpc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#include "timing.h"
3232
#include "../mm/mmu_decl.h"
3333

34+
#define CREATE_TRACE_POINTS
35+
#include "trace.h"
36+
3437
gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
3538
{
3639
return gfn;

arch/powerpc/kvm/trace.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
2+
#define _TRACE_KVM_H
3+
4+
#include <linux/tracepoint.h>
5+
6+
#undef TRACE_SYSTEM
7+
#define TRACE_SYSTEM kvm
8+
#define TRACE_INCLUDE_PATH .
9+
#define TRACE_INCLUDE_FILE trace
10+
11+
/*
12+
* Tracepoint for guest mode entry.
13+
*/
14+
TRACE_EVENT(kvm_ppc_instr,
15+
TP_PROTO(unsigned int inst, unsigned long pc, unsigned int emulate),
16+
TP_ARGS(inst, pc, emulate),
17+
18+
TP_STRUCT__entry(
19+
__field( unsigned int, inst )
20+
__field( unsigned long, pc )
21+
__field( unsigned int, emulate )
22+
),
23+
24+
TP_fast_assign(
25+
__entry->inst = inst;
26+
__entry->pc = pc;
27+
__entry->emulate = emulate;
28+
),
29+
30+
TP_printk("inst %u pc 0x%lx emulate %u\n",
31+
__entry->inst, __entry->pc, __entry->emulate)
32+
);
33+
34+
TRACE_EVENT(kvm_stlb_inval,
35+
TP_PROTO(unsigned int stlb_index),
36+
TP_ARGS(stlb_index),
37+
38+
TP_STRUCT__entry(
39+
__field( unsigned int, stlb_index )
40+
),
41+
42+
TP_fast_assign(
43+
__entry->stlb_index = stlb_index;
44+
),
45+
46+
TP_printk("stlb_index %u", __entry->stlb_index)
47+
);
48+
49+
TRACE_EVENT(kvm_stlb_write,
50+
TP_PROTO(unsigned int victim, unsigned int tid, unsigned int word0,
51+
unsigned int word1, unsigned int word2),
52+
TP_ARGS(victim, tid, word0, word1, word2),
53+
54+
TP_STRUCT__entry(
55+
__field( unsigned int, victim )
56+
__field( unsigned int, tid )
57+
__field( unsigned int, word0 )
58+
__field( unsigned int, word1 )
59+
__field( unsigned int, word2 )
60+
),
61+
62+
TP_fast_assign(
63+
__entry->victim = victim;
64+
__entry->tid = tid;
65+
__entry->word0 = word0;
66+
__entry->word1 = word1;
67+
__entry->word2 = word2;
68+
),
69+
70+
TP_printk("victim %u tid %u w0 %u w1 %u w2 %u",
71+
__entry->victim, __entry->tid, __entry->word0,
72+
__entry->word1, __entry->word2)
73+
);
74+
75+
TRACE_EVENT(kvm_gtlb_write,
76+
TP_PROTO(unsigned int gtlb_index, unsigned int tid, unsigned int word0,
77+
unsigned int word1, unsigned int word2),
78+
TP_ARGS(gtlb_index, tid, word0, word1, word2),
79+
80+
TP_STRUCT__entry(
81+
__field( unsigned int, gtlb_index )
82+
__field( unsigned int, tid )
83+
__field( unsigned int, word0 )
84+
__field( unsigned int, word1 )
85+
__field( unsigned int, word2 )
86+
),
87+
88+
TP_fast_assign(
89+
__entry->gtlb_index = gtlb_index;
90+
__entry->tid = tid;
91+
__entry->word0 = word0;
92+
__entry->word1 = word1;
93+
__entry->word2 = word2;
94+
),
95+
96+
TP_printk("gtlb_index %u tid %u w0 %u w1 %u w2 %u",
97+
__entry->gtlb_index, __entry->tid, __entry->word0,
98+
__entry->word1, __entry->word2)
99+
);
100+
101+
#endif /* _TRACE_KVM_H */
102+
103+
/* This part must be outside protection */
104+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)