xref: /titanic_44/usr/src/uts/common/xen/public/trace.h (revision ad09f8b827db90c9a0093f0b6382803fa64a5fd1)
1c7158ae9Stariq /******************************************************************************
2c7158ae9Stariq  * include/public/trace.h
3c7158ae9Stariq  *
4c7158ae9Stariq  * Permission is hereby granted, free of charge, to any person obtaining a copy
5c7158ae9Stariq  * of this software and associated documentation files (the "Software"), to
6c7158ae9Stariq  * deal in the Software without restriction, including without limitation the
7c7158ae9Stariq  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8c7158ae9Stariq  * sell copies of the Software, and to permit persons to whom the Software is
9c7158ae9Stariq  * furnished to do so, subject to the following conditions:
10c7158ae9Stariq  *
11c7158ae9Stariq  * The above copyright notice and this permission notice shall be included in
12c7158ae9Stariq  * all copies or substantial portions of the Software.
13c7158ae9Stariq  *
14c7158ae9Stariq  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c7158ae9Stariq  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c7158ae9Stariq  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17c7158ae9Stariq  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18c7158ae9Stariq  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19c7158ae9Stariq  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20c7158ae9Stariq  * DEALINGS IN THE SOFTWARE.
21c7158ae9Stariq  *
22c7158ae9Stariq  * Mark Williamson, (C) 2004 Intel Research Cambridge
23c7158ae9Stariq  * Copyright (C) 2005 Bin Ren
24c7158ae9Stariq  */
25c7158ae9Stariq 
26c7158ae9Stariq #ifndef __XEN_PUBLIC_TRACE_H__
27c7158ae9Stariq #define __XEN_PUBLIC_TRACE_H__
28c7158ae9Stariq 
29349b53ddSStuart Maybee #define TRACE_EXTRA_MAX    7
30349b53ddSStuart Maybee #define TRACE_EXTRA_SHIFT 28
31349b53ddSStuart Maybee 
32c7158ae9Stariq /* Trace classes */
33c7158ae9Stariq #define TRC_CLS_SHIFT 16
34c7158ae9Stariq #define TRC_GEN      0x0001f000    /* General trace            */
35c7158ae9Stariq #define TRC_SCHED    0x0002f000    /* Xen Scheduler trace      */
36c7158ae9Stariq #define TRC_DOM0OP   0x0004f000    /* Xen DOM0 operation trace */
37c7158ae9Stariq #define TRC_HVM      0x0008f000    /* Xen HVM trace            */
38c7158ae9Stariq #define TRC_MEM      0x0010f000    /* Xen memory trace         */
39349b53ddSStuart Maybee #define TRC_PV       0x0020f000    /* Xen PV traces            */
40*ad09f8b8SMark Johnson #define TRC_SHADOW   0x0040f000    /* Xen shadow tracing       */
41*ad09f8b8SMark Johnson #define TRC_PM       0x0080f000    /* Xen power management trace */
42349b53ddSStuart Maybee #define TRC_ALL      0x0ffff000
43349b53ddSStuart Maybee #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff)
44349b53ddSStuart Maybee #define TRC_HD_CYCLE_FLAG (1UL<<31)
45349b53ddSStuart Maybee #define TRC_HD_INCLUDES_CYCLE_COUNT(x) ( !!( (x) & TRC_HD_CYCLE_FLAG ) )
46349b53ddSStuart Maybee #define TRC_HD_EXTRA(x)    (((x)>>TRACE_EXTRA_SHIFT)&TRACE_EXTRA_MAX)
47c7158ae9Stariq 
48c7158ae9Stariq /* Trace subclasses */
49c7158ae9Stariq #define TRC_SUBCLS_SHIFT 12
50c7158ae9Stariq 
51c7158ae9Stariq /* trace subclasses for SVM */
52c7158ae9Stariq #define TRC_HVM_ENTRYEXIT 0x00081000   /* VMENTRY and #VMEXIT       */
53c7158ae9Stariq #define TRC_HVM_HANDLER   0x00082000   /* various HVM handlers      */
54c7158ae9Stariq 
55*ad09f8b8SMark Johnson #define TRC_SCHED_MIN       0x00021000   /* Just runstate changes */
56*ad09f8b8SMark Johnson #define TRC_SCHED_VERBOSE   0x00028000   /* More inclusive scheduling */
57*ad09f8b8SMark Johnson 
58c7158ae9Stariq /* Trace events per class */
59c7158ae9Stariq #define TRC_LOST_RECORDS        (TRC_GEN + 1)
60349b53ddSStuart Maybee #define TRC_TRACE_WRAP_BUFFER  (TRC_GEN + 2)
61349b53ddSStuart Maybee #define TRC_TRACE_CPU_CHANGE    (TRC_GEN + 3)
62c7158ae9Stariq 
63*ad09f8b8SMark Johnson #define TRC_SCHED_RUNSTATE_CHANGE   (TRC_SCHED_MIN + 1)
64*ad09f8b8SMark Johnson #define TRC_SCHED_CONTINUE_RUNNING  (TRC_SCHED_MIN + 2)
65*ad09f8b8SMark Johnson #define TRC_SCHED_DOM_ADD        (TRC_SCHED_VERBOSE +  1)
66*ad09f8b8SMark Johnson #define TRC_SCHED_DOM_REM        (TRC_SCHED_VERBOSE +  2)
67*ad09f8b8SMark Johnson #define TRC_SCHED_SLEEP          (TRC_SCHED_VERBOSE +  3)
68*ad09f8b8SMark Johnson #define TRC_SCHED_WAKE           (TRC_SCHED_VERBOSE +  4)
69*ad09f8b8SMark Johnson #define TRC_SCHED_YIELD          (TRC_SCHED_VERBOSE +  5)
70*ad09f8b8SMark Johnson #define TRC_SCHED_BLOCK          (TRC_SCHED_VERBOSE +  6)
71*ad09f8b8SMark Johnson #define TRC_SCHED_SHUTDOWN       (TRC_SCHED_VERBOSE +  7)
72*ad09f8b8SMark Johnson #define TRC_SCHED_CTL            (TRC_SCHED_VERBOSE +  8)
73*ad09f8b8SMark Johnson #define TRC_SCHED_ADJDOM         (TRC_SCHED_VERBOSE +  9)
74*ad09f8b8SMark Johnson #define TRC_SCHED_SWITCH         (TRC_SCHED_VERBOSE + 10)
75*ad09f8b8SMark Johnson #define TRC_SCHED_S_TIMER_FN     (TRC_SCHED_VERBOSE + 11)
76*ad09f8b8SMark Johnson #define TRC_SCHED_T_TIMER_FN     (TRC_SCHED_VERBOSE + 12)
77*ad09f8b8SMark Johnson #define TRC_SCHED_DOM_TIMER_FN   (TRC_SCHED_VERBOSE + 13)
78*ad09f8b8SMark Johnson #define TRC_SCHED_SWITCH_INFPREV (TRC_SCHED_VERBOSE + 14)
79*ad09f8b8SMark Johnson #define TRC_SCHED_SWITCH_INFNEXT (TRC_SCHED_VERBOSE + 15)
80c7158ae9Stariq 
81c7158ae9Stariq #define TRC_MEM_PAGE_GRANT_MAP      (TRC_MEM + 1)
82c7158ae9Stariq #define TRC_MEM_PAGE_GRANT_UNMAP    (TRC_MEM + 2)
83c7158ae9Stariq #define TRC_MEM_PAGE_GRANT_TRANSFER (TRC_MEM + 3)
84c7158ae9Stariq 
85349b53ddSStuart Maybee #define TRC_PV_HYPERCALL             (TRC_PV +  1)
86349b53ddSStuart Maybee #define TRC_PV_TRAP                  (TRC_PV +  3)
87349b53ddSStuart Maybee #define TRC_PV_PAGE_FAULT            (TRC_PV +  4)
88349b53ddSStuart Maybee #define TRC_PV_FORCED_INVALID_OP     (TRC_PV +  5)
89349b53ddSStuart Maybee #define TRC_PV_EMULATE_PRIVOP        (TRC_PV +  6)
90349b53ddSStuart Maybee #define TRC_PV_EMULATE_4GB           (TRC_PV +  7)
91349b53ddSStuart Maybee #define TRC_PV_MATH_STATE_RESTORE    (TRC_PV +  8)
92349b53ddSStuart Maybee #define TRC_PV_PAGING_FIXUP          (TRC_PV +  9)
93349b53ddSStuart Maybee #define TRC_PV_GDT_LDT_MAPPING_FAULT (TRC_PV + 10)
94349b53ddSStuart Maybee #define TRC_PV_PTWR_EMULATION        (TRC_PV + 11)
95349b53ddSStuart Maybee #define TRC_PV_PTWR_EMULATION_PAE    (TRC_PV + 12)
96349b53ddSStuart Maybee   /* Indicates that addresses in trace record are 64 bits */
97349b53ddSStuart Maybee #define TRC_64_FLAG               (0x100)
98349b53ddSStuart Maybee 
99*ad09f8b8SMark Johnson #define TRC_SHADOW_NOT_SHADOW                 (TRC_SHADOW +  1)
100*ad09f8b8SMark Johnson #define TRC_SHADOW_FAST_PROPAGATE             (TRC_SHADOW +  2)
101*ad09f8b8SMark Johnson #define TRC_SHADOW_FAST_MMIO                  (TRC_SHADOW +  3)
102*ad09f8b8SMark Johnson #define TRC_SHADOW_FALSE_FAST_PATH            (TRC_SHADOW +  4)
103*ad09f8b8SMark Johnson #define TRC_SHADOW_MMIO                       (TRC_SHADOW +  5)
104*ad09f8b8SMark Johnson #define TRC_SHADOW_FIXUP                      (TRC_SHADOW +  6)
105*ad09f8b8SMark Johnson #define TRC_SHADOW_DOMF_DYING                 (TRC_SHADOW +  7)
106*ad09f8b8SMark Johnson #define TRC_SHADOW_EMULATE                    (TRC_SHADOW +  8)
107*ad09f8b8SMark Johnson #define TRC_SHADOW_EMULATE_UNSHADOW_USER      (TRC_SHADOW +  9)
108*ad09f8b8SMark Johnson #define TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ    (TRC_SHADOW + 10)
109*ad09f8b8SMark Johnson #define TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED (TRC_SHADOW + 11)
110*ad09f8b8SMark Johnson #define TRC_SHADOW_WRMAP_BF                   (TRC_SHADOW + 12)
111*ad09f8b8SMark Johnson #define TRC_SHADOW_PREALLOC_UNPIN             (TRC_SHADOW + 13)
112*ad09f8b8SMark Johnson #define TRC_SHADOW_RESYNC_FULL                (TRC_SHADOW + 14)
113*ad09f8b8SMark Johnson #define TRC_SHADOW_RESYNC_ONLY                (TRC_SHADOW + 15)
114*ad09f8b8SMark Johnson 
115c7158ae9Stariq /* trace events per subclass */
116c7158ae9Stariq #define TRC_HVM_VMENTRY         (TRC_HVM_ENTRYEXIT + 0x01)
117c7158ae9Stariq #define TRC_HVM_VMEXIT          (TRC_HVM_ENTRYEXIT + 0x02)
118349b53ddSStuart Maybee #define TRC_HVM_VMEXIT64        (TRC_HVM_ENTRYEXIT + TRC_64_FLAG + 0x02)
119c7158ae9Stariq #define TRC_HVM_PF_XEN          (TRC_HVM_HANDLER + 0x01)
120349b53ddSStuart Maybee #define TRC_HVM_PF_XEN64        (TRC_HVM_HANDLER + TRC_64_FLAG + 0x01)
121c7158ae9Stariq #define TRC_HVM_PF_INJECT       (TRC_HVM_HANDLER + 0x02)
122349b53ddSStuart Maybee #define TRC_HVM_PF_INJECT64     (TRC_HVM_HANDLER + TRC_64_FLAG + 0x02)
123c7158ae9Stariq #define TRC_HVM_INJ_EXC         (TRC_HVM_HANDLER + 0x03)
124c7158ae9Stariq #define TRC_HVM_INJ_VIRQ        (TRC_HVM_HANDLER + 0x04)
125c7158ae9Stariq #define TRC_HVM_REINJ_VIRQ      (TRC_HVM_HANDLER + 0x05)
126c7158ae9Stariq #define TRC_HVM_IO_READ         (TRC_HVM_HANDLER + 0x06)
127c7158ae9Stariq #define TRC_HVM_IO_WRITE        (TRC_HVM_HANDLER + 0x07)
128c7158ae9Stariq #define TRC_HVM_CR_READ         (TRC_HVM_HANDLER + 0x08)
129349b53ddSStuart Maybee #define TRC_HVM_CR_READ64       (TRC_HVM_HANDLER + TRC_64_FLAG + 0x08)
130c7158ae9Stariq #define TRC_HVM_CR_WRITE        (TRC_HVM_HANDLER + 0x09)
131349b53ddSStuart Maybee #define TRC_HVM_CR_WRITE64      (TRC_HVM_HANDLER + TRC_64_FLAG + 0x09)
132c7158ae9Stariq #define TRC_HVM_DR_READ         (TRC_HVM_HANDLER + 0x0A)
133c7158ae9Stariq #define TRC_HVM_DR_WRITE        (TRC_HVM_HANDLER + 0x0B)
134c7158ae9Stariq #define TRC_HVM_MSR_READ        (TRC_HVM_HANDLER + 0x0C)
135c7158ae9Stariq #define TRC_HVM_MSR_WRITE       (TRC_HVM_HANDLER + 0x0D)
136c7158ae9Stariq #define TRC_HVM_CPUID           (TRC_HVM_HANDLER + 0x0E)
137c7158ae9Stariq #define TRC_HVM_INTR            (TRC_HVM_HANDLER + 0x0F)
138c7158ae9Stariq #define TRC_HVM_NMI             (TRC_HVM_HANDLER + 0x10)
139c7158ae9Stariq #define TRC_HVM_SMI             (TRC_HVM_HANDLER + 0x11)
140c7158ae9Stariq #define TRC_HVM_VMMCALL         (TRC_HVM_HANDLER + 0x12)
141c7158ae9Stariq #define TRC_HVM_HLT             (TRC_HVM_HANDLER + 0x13)
142c7158ae9Stariq #define TRC_HVM_INVLPG          (TRC_HVM_HANDLER + 0x14)
143349b53ddSStuart Maybee #define TRC_HVM_INVLPG64        (TRC_HVM_HANDLER + TRC_64_FLAG + 0x14)
144c7158ae9Stariq #define TRC_HVM_MCE             (TRC_HVM_HANDLER + 0x15)
145*ad09f8b8SMark Johnson #define TRC_HVM_IOPORT_READ     (TRC_HVM_HANDLER + 0x16)
146*ad09f8b8SMark Johnson #define TRC_HVM_IOMEM_READ      (TRC_HVM_HANDLER + 0x17)
147349b53ddSStuart Maybee #define TRC_HVM_CLTS            (TRC_HVM_HANDLER + 0x18)
148349b53ddSStuart Maybee #define TRC_HVM_LMSW            (TRC_HVM_HANDLER + 0x19)
149349b53ddSStuart Maybee #define TRC_HVM_LMSW64          (TRC_HVM_HANDLER + TRC_64_FLAG + 0x19)
150*ad09f8b8SMark Johnson #define TRC_HVM_INTR_WINDOW     (TRC_HVM_HANDLER + 0x20)
151*ad09f8b8SMark Johnson #define TRC_HVM_IOPORT_WRITE    (TRC_HVM_HANDLER + 0x216)
152*ad09f8b8SMark Johnson #define TRC_HVM_IOMEM_WRITE     (TRC_HVM_HANDLER + 0x217)
153*ad09f8b8SMark Johnson 
154*ad09f8b8SMark Johnson /* trace subclasses for power management */
155*ad09f8b8SMark Johnson #define TRC_PM_FREQ     0x00801000      /* xen cpu freq events */
156*ad09f8b8SMark Johnson #define TRC_PM_IDLE     0x00802000      /* xen cpu idle events */
157*ad09f8b8SMark Johnson 
158*ad09f8b8SMark Johnson /* trace events for per class */
159*ad09f8b8SMark Johnson #define TRC_PM_FREQ_CHANGE      (TRC_PM_FREQ + 0x01)
160*ad09f8b8SMark Johnson #define TRC_PM_IDLE_ENTRY       (TRC_PM_IDLE + 0x01)
161*ad09f8b8SMark Johnson #define TRC_PM_IDLE_EXIT        (TRC_PM_IDLE + 0x02)
162c7158ae9Stariq 
163c7158ae9Stariq /* This structure represents a single trace buffer record. */
164c7158ae9Stariq struct t_rec {
165349b53ddSStuart Maybee     uint32_t event:28;
166349b53ddSStuart Maybee     uint32_t extra_u32:3;         /* # entries in trailing extra_u32[] array */
167349b53ddSStuart Maybee     uint32_t cycles_included:1;   /* u.cycles or u.no_cycles? */
168349b53ddSStuart Maybee     union {
169349b53ddSStuart Maybee         struct {
170349b53ddSStuart Maybee             uint32_t cycles_lo, cycles_hi; /* cycle counter timestamp */
171349b53ddSStuart Maybee             uint32_t extra_u32[7];         /* event data items */
172349b53ddSStuart Maybee         } cycles;
173349b53ddSStuart Maybee         struct {
174349b53ddSStuart Maybee             uint32_t extra_u32[7];         /* event data items */
175349b53ddSStuart Maybee         } nocycles;
176349b53ddSStuart Maybee     } u;
177c7158ae9Stariq };
178c7158ae9Stariq 
179c7158ae9Stariq /*
180c7158ae9Stariq  * This structure contains the metadata for a single trace buffer.  The head
181c7158ae9Stariq  * field, indexes into an array of struct t_rec's.
182c7158ae9Stariq  */
183c7158ae9Stariq struct t_buf {
184349b53ddSStuart Maybee     /* Assume the data buffer size is X.  X is generally not a power of 2.
185349b53ddSStuart Maybee      * CONS and PROD are incremented modulo (2*X):
186349b53ddSStuart Maybee      *     0 <= cons < 2*X
187349b53ddSStuart Maybee      *     0 <= prod < 2*X
188349b53ddSStuart Maybee      * This is done because addition modulo X breaks at 2^32 when X is not a
189349b53ddSStuart Maybee      * power of 2:
190349b53ddSStuart Maybee      *     (((2^32 - 1) % X) + 1) % X != (2^32) % X
191349b53ddSStuart Maybee      */
192349b53ddSStuart Maybee     uint32_t cons;   /* Offset of next item to be consumed by control tools. */
193349b53ddSStuart Maybee     uint32_t prod;   /* Offset of next item to be produced by Xen.           */
194349b53ddSStuart Maybee     /*  Records follow immediately after the meta-data header.    */
195c7158ae9Stariq };
196c7158ae9Stariq 
197c7158ae9Stariq #endif /* __XEN_PUBLIC_TRACE_H__ */
198c7158ae9Stariq 
199c7158ae9Stariq /*
200c7158ae9Stariq  * Local variables:
201c7158ae9Stariq  * mode: C
202c7158ae9Stariq  * c-set-style: "BSD"
203c7158ae9Stariq  * c-basic-offset: 4
204c7158ae9Stariq  * tab-width: 4
205c7158ae9Stariq  * indent-tabs-mode: nil
206c7158ae9Stariq  * End:
207c7158ae9Stariq  */
208