1 #ifndef __ASM_X86_HVM_TRACE_H__
2 #define __ASM_X86_HVM_TRACE_H__
3 
4 #include <xen/trace.h>
5 
6 #define DEFAULT_HVM_TRACE_ON  1
7 #define DEFAULT_HVM_TRACE_OFF 0
8 
9 #define DEFAULT_HVM_VMSWITCH   DEFAULT_HVM_TRACE_ON
10 #define DEFAULT_HVM_PF         DEFAULT_HVM_TRACE_ON
11 #define DEFAULT_HVM_INJECT     DEFAULT_HVM_TRACE_ON
12 #define DEFAULT_HVM_IO         DEFAULT_HVM_TRACE_ON
13 #define DEFAULT_HVM_REGACCESS  DEFAULT_HVM_TRACE_ON
14 #define DEFAULT_HVM_MISC       DEFAULT_HVM_TRACE_ON
15 #define DEFAULT_HVM_INTR       DEFAULT_HVM_TRACE_ON
16 
17 #define DO_TRC_HVM_VMENTRY     DEFAULT_HVM_VMSWITCH
18 #define DO_TRC_HVM_VMEXIT      DEFAULT_HVM_VMSWITCH
19 #define DO_TRC_HVM_VMEXIT64    DEFAULT_HVM_VMSWITCH
20 #define DO_TRC_HVM_PF_XEN      DEFAULT_HVM_PF
21 #define DO_TRC_HVM_PF_XEN64    DEFAULT_HVM_PF
22 #define DO_TRC_HVM_PF_INJECT   DEFAULT_HVM_PF
23 #define DO_TRC_HVM_PF_INJECT64 DEFAULT_HVM_PF
24 #define DO_TRC_HVM_INJ_EXC     DEFAULT_HVM_INJECT
25 #define DO_TRC_HVM_INJ_VIRQ    DEFAULT_HVM_INJECT
26 #define DO_TRC_HVM_REINJ_VIRQ  DEFAULT_HVM_INJECT
27 #define DO_TRC_HVM_INTR_WINDOW DEFAULT_HVM_INJECT
28 #define DO_TRC_HVM_IO_READ     DEFAULT_HVM_IO
29 #define DO_TRC_HVM_IO_WRITE    DEFAULT_HVM_IO
30 #define DO_TRC_HVM_CR_READ     DEFAULT_HVM_REGACCESS
31 #define DO_TRC_HVM_CR_READ64   DEFAULT_HVM_REGACCESS
32 #define DO_TRC_HVM_CR_WRITE    DEFAULT_HVM_REGACCESS
33 #define DO_TRC_HVM_CR_WRITE64  DEFAULT_HVM_REGACCESS
34 #define DO_TRC_HVM_DR_READ     DEFAULT_HVM_REGACCESS
35 #define DO_TRC_HVM_DR_WRITE    DEFAULT_HVM_REGACCESS
36 #define DO_TRC_HVM_XCR_READ64  DEFAULT_HVM_REGACCESS
37 #define DO_TRC_HVM_XCR_WRITE64 DEFAULT_HVM_REGACCESS
38 #define DO_TRC_HVM_MSR_READ    DEFAULT_HVM_REGACCESS
39 #define DO_TRC_HVM_MSR_WRITE   DEFAULT_HVM_REGACCESS
40 #define DO_TRC_HVM_RDTSC       DEFAULT_HVM_REGACCESS
41 #define DO_TRC_HVM_CPUID       DEFAULT_HVM_MISC
42 #define DO_TRC_HVM_INTR        DEFAULT_HVM_INTR
43 #define DO_TRC_HVM_NMI         DEFAULT_HVM_INTR
44 #define DO_TRC_HVM_MCE         DEFAULT_HVM_INTR
45 #define DO_TRC_HVM_SMI         DEFAULT_HVM_INTR
46 #define DO_TRC_HVM_VMMCALL     DEFAULT_HVM_MISC
47 #define DO_TRC_HVM_HLT         DEFAULT_HVM_MISC
48 #define DO_TRC_HVM_INVLPG      DEFAULT_HVM_MISC
49 #define DO_TRC_HVM_INVLPG64    DEFAULT_HVM_MISC
50 #define DO_TRC_HVM_IO_ASSIST   DEFAULT_HVM_MISC
51 #define DO_TRC_HVM_MMIO_ASSIST DEFAULT_HVM_MISC
52 #define DO_TRC_HVM_CLTS        DEFAULT_HVM_MISC
53 #define DO_TRC_HVM_LMSW        DEFAULT_HVM_MISC
54 #define DO_TRC_HVM_LMSW64      DEFAULT_HVM_MISC
55 #define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC
56 #define DO_TRC_HVM_TRAP             DEFAULT_HVM_MISC
57 #define DO_TRC_HVM_TRAP_DEBUG       DEFAULT_HVM_MISC
58 #define DO_TRC_HVM_VLAPIC           DEFAULT_HVM_MISC
59 
60 
61 #define TRC_PAR_LONG(par) ((par)&0xFFFFFFFF),((par)>>32)
62 
63 #define TRACE_2_LONG_2D(_e, d1, d2, ...) \
64     TRACE_4D(_e, d1, d2)
65 #define TRACE_2_LONG_3D(_e, d1, d2, d3, ...) \
66     TRACE_5D(_e, d1, d2, d3)
67 #define TRACE_2_LONG_4D(_e, d1, d2, d3, d4, ...) \
68     TRACE_6D(_e, d1, d2, d3, d4)
69 
70 #define HVMTRACE_ND(evt, modifier, cycles, count, d1, d2, d3, d4, d5, d6) \
71     do {                                                                  \
72         if ( unlikely(tb_init_done) && DO_TRC_HVM_ ## evt )               \
73         {                                                                 \
74             struct {                                                      \
75                 u32 d[6];                                                 \
76             } _d;                                                         \
77             _d.d[0]=(d1);                                                 \
78             _d.d[1]=(d2);                                                 \
79             _d.d[2]=(d3);                                                 \
80             _d.d[3]=(d4);                                                 \
81             _d.d[4]=(d5);                                                 \
82             _d.d[5]=(d6);                                                 \
83             __trace_var(TRC_HVM_ ## evt | (modifier), cycles,             \
84                         sizeof(*_d.d) * count, &_d);                      \
85         }                                                                 \
86     } while(0)
87 
88 #define HVMTRACE_6D(evt, d1, d2, d3, d4, d5, d6)    \
89     HVMTRACE_ND(evt, 0, 0, 6, d1, d2, d3, d4, d5, d6)
90 #define HVMTRACE_5D(evt, d1, d2, d3, d4, d5)        \
91     HVMTRACE_ND(evt, 0, 0, 5, d1, d2, d3, d4, d5,  0)
92 #define HVMTRACE_4D(evt, d1, d2, d3, d4)            \
93     HVMTRACE_ND(evt, 0, 0, 4, d1, d2, d3, d4,  0,  0)
94 #define HVMTRACE_3D(evt, d1, d2, d3)                \
95     HVMTRACE_ND(evt, 0, 0, 3, d1, d2, d3,  0,  0,  0)
96 #define HVMTRACE_2D(evt, d1, d2)                    \
97     HVMTRACE_ND(evt, 0, 0, 2, d1, d2,  0,  0,  0,  0)
98 #define HVMTRACE_1D(evt, d1)                        \
99     HVMTRACE_ND(evt, 0, 0, 1, d1,  0,  0,  0,  0,  0)
100 #define HVMTRACE_0D(evt)                            \
101     HVMTRACE_ND(evt, 0, 0, 0,  0,  0,  0,  0,  0,  0)
102 
103 #define HVMTRACE_LONG_1D(evt, d1)                  \
104                    HVMTRACE_2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32)
105 #define HVMTRACE_LONG_2D(evt, d1, d2, ...)              \
106                    HVMTRACE_3D(evt ## 64, d1, d2)
107 #define HVMTRACE_LONG_3D(evt, d1, d2, d3, ...)      \
108                    HVMTRACE_4D(evt ## 64, d1, d2, d3)
109 #define HVMTRACE_LONG_4D(evt, d1, d2, d3, d4, ...)  \
110                    HVMTRACE_5D(evt ## 64, d1, d2, d3, d4)
111 
112 #endif /* __ASM_X86_HVM_TRACE_H__ */
113 
114 /*
115  * Local variables:
116  * mode: C
117  * c-file-style: "BSD"
118  * c-basic-offset: 4
119  * tab-width: 4
120  * indent-tabs-mode: nil
121  * End:
122  */
123