ia64/xen-unstable

view xen/arch/x86/trace.c @ 18806:ed8524f4a044

x86: Re-initialise HPET on resume from S3

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Nov 18 15:55:14 2008 +0000 (2008-11-18)
parents 268a9f8286f3
children
line source
1 #include <xen/config.h>
2 #include <xen/init.h>
3 #include <xen/kernel.h>
4 #include <xen/lib.h>
5 #include <xen/domain.h>
6 #include <xen/sched.h>
7 #include <xen/trace.h>
9 #ifndef __x86_64__
10 #undef TRC_64_FLAG
11 #define TRC_64_FLAG 0
12 #endif
14 asmlinkage void trace_hypercall(void)
15 {
16 struct cpu_user_regs *regs = guest_cpu_user_regs();
18 #ifdef __x86_64__
19 if ( is_pv_32on64_vcpu(current) )
20 {
21 struct {
22 u32 eip,eax;
23 } __attribute__((packed)) d;
25 d.eip = regs->eip;
26 d.eax = regs->eax;
28 __trace_var(TRC_PV_HYPERCALL, 1,
29 sizeof(d), (unsigned char *)&d);
30 }
31 else
32 #endif
33 {
34 struct {
35 unsigned long eip;
36 u32 eax;
37 } __attribute__((packed)) d;
38 u32 event;
40 event = TRC_PV_HYPERCALL;
41 event |= TRC_64_FLAG;
42 d.eip = regs->eip;
43 d.eax = regs->eax;
45 __trace_var(event, 1/*tsc*/, sizeof(d), (unsigned char*)&d);
46 }
47 }
49 void __trace_pv_trap(int trapnr, unsigned long eip,
50 int use_error_code, unsigned error_code)
51 {
52 #ifdef __x86_64__
53 if ( is_pv_32on64_vcpu(current) )
54 {
55 struct {
56 unsigned eip:32,
57 trapnr:15,
58 use_error_code:1,
59 error_code:16;
60 } __attribute__((packed)) d;
62 d.eip = eip;
63 d.trapnr = trapnr;
64 d.error_code = error_code;
65 d.use_error_code=!!use_error_code;
67 __trace_var(TRC_PV_TRAP, 1,
68 sizeof(d), (unsigned char *)&d);
69 }
70 else
71 #endif
72 {
73 struct {
74 unsigned long eip;
75 unsigned trapnr:15,
76 use_error_code:1,
77 error_code:16;
78 } __attribute__((packed)) d;
79 unsigned event;
81 d.eip = eip;
82 d.trapnr = trapnr;
83 d.error_code = error_code;
84 d.use_error_code=!!use_error_code;
86 event = TRC_PV_TRAP;
87 event |= TRC_64_FLAG;
88 __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
89 }
90 }
92 void __trace_pv_page_fault(unsigned long addr, unsigned error_code)
93 {
94 unsigned long eip = guest_cpu_user_regs()->eip;
96 #ifdef __x86_64__
97 if ( is_pv_32on64_vcpu(current) )
98 {
99 struct {
100 u32 eip, addr, error_code;
101 } __attribute__((packed)) d;
103 d.eip = eip;
104 d.addr = addr;
105 d.error_code = error_code;
107 __trace_var(TRC_PV_PAGE_FAULT, 1, sizeof(d), (unsigned char *)&d);
108 }
109 else
110 #endif
111 {
112 struct {
113 unsigned long eip, addr;
114 u32 error_code;
115 } __attribute__((packed)) d;
116 unsigned event;
118 d.eip = eip;
119 d.addr = addr;
120 d.error_code = error_code;
121 event = TRC_PV_PAGE_FAULT;
122 event |= TRC_64_FLAG;
123 __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
124 }
125 }
127 void __trace_trap_one_addr(unsigned event, unsigned long va)
128 {
129 #ifdef __x86_64__
130 if ( is_pv_32on64_vcpu(current) )
131 {
132 u32 d = va;
133 __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
134 }
135 else
136 #endif
137 {
138 event |= TRC_64_FLAG;
139 __trace_var(event, 1, sizeof(va), (unsigned char *)&va);
140 }
141 }
143 void __trace_trap_two_addr(unsigned event, unsigned long va1,
144 unsigned long va2)
145 {
146 #ifdef __x86_64__
147 if ( is_pv_32on64_vcpu(current) )
148 {
149 struct {
150 u32 va1, va2;
151 } __attribute__((packed)) d;
152 d.va1=va1;
153 d.va2=va2;
154 __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
155 }
156 else
157 #endif
158 {
159 struct {
160 unsigned long va1, va2;
161 } __attribute__((packed)) d;
162 d.va1=va1;
163 d.va2=va2;
164 event |= TRC_64_FLAG;
165 __trace_var(event, 1, sizeof(d), (unsigned char *)&d);
166 }
167 }
169 void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
170 {
171 unsigned long eip = guest_cpu_user_regs()->eip;
173 /* We have a couple of different modes to worry about:
174 * - 32-on-32: 32-bit pte, 32-bit virtual addresses
175 * - pae-on-pae, pae-on-64: 64-bit pte, 32-bit virtual addresses
176 * - 64-on-64: 64-bit pte, 64-bit virtual addresses
177 * pae-on-64 is the only one that requires extra code; in all other
178 * cases, "unsigned long" is the size of a guest virtual address.
179 */
181 #ifdef __x86_64__
182 if ( is_pv_32on64_vcpu(current) )
183 {
184 struct {
185 l1_pgentry_t pte;
186 u32 addr, eip;
187 } __attribute__((packed)) d;
188 d.addr = addr;
189 d.eip = eip;
190 d.pte = npte;
192 __trace_var(TRC_PV_PTWR_EMULATION_PAE, 1,
193 sizeof(d), (unsigned char *)&d);
194 }
195 else
196 #endif
197 {
198 struct {
199 l1_pgentry_t pte;
200 unsigned long addr, eip;
201 } d;
202 unsigned event;
204 d.addr = addr;
205 d.eip = eip;
206 d.pte = npte;
208 event = ((CONFIG_PAGING_LEVELS == 3) ?
209 TRC_PV_PTWR_EMULATION_PAE : TRC_PV_PTWR_EMULATION);
210 event |= TRC_64_FLAG;
211 __trace_var(event, 1/*tsc*/, sizeof(d), (unsigned char *)&d);
212 }
213 }