This source file includes following definitions.
- x86_mcinfo_lookup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #ifndef __XEN_PUBLIC_ARCH_X86_MCA_H__
31 #define __XEN_PUBLIC_ARCH_X86_MCA_H__
32
33
34 #define __HYPERVISOR_mca __HYPERVISOR_arch_0
35
36 #define XEN_MCA_INTERFACE_VERSION 0x01ecc003
37
38
39 #define XEN_MC_NONURGENT 0x1
40
41 #define XEN_MC_URGENT 0x2
42
43 #define XEN_MC_ACK 0x4
44
45
46 #define XEN_MC_OK 0x0
47
48 #define XEN_MC_FETCHFAILED 0x1
49
50 #define XEN_MC_NODATA 0x2
51
52 #ifndef __ASSEMBLY__
53
54 #define VIRQ_MCA VIRQ_ARCH_0
55
56
57
58
59
60
61
62 #define MC_TYPE_GLOBAL 0
63 #define MC_TYPE_BANK 1
64 #define MC_TYPE_EXTENDED 2
65 #define MC_TYPE_RECOVERY 3
66
67 struct mcinfo_common {
68 uint16_t type;
69 uint16_t size;
70 };
71
72 #define MC_FLAG_CORRECTABLE (1 << 0)
73 #define MC_FLAG_UNCORRECTABLE (1 << 1)
74 #define MC_FLAG_RECOVERABLE (1 << 2)
75 #define MC_FLAG_POLLED (1 << 3)
76 #define MC_FLAG_RESET (1 << 4)
77 #define MC_FLAG_CMCI (1 << 5)
78 #define MC_FLAG_MCE (1 << 6)
79
80
81 struct mcinfo_global {
82 struct mcinfo_common common;
83
84 uint16_t mc_domid;
85 uint16_t mc_vcpuid;
86 uint32_t mc_socketid;
87 uint16_t mc_coreid;
88 uint16_t mc_core_threadid;
89 uint32_t mc_apicid;
90 uint32_t mc_flags;
91 uint64_t mc_gstatus;
92 };
93
94
95 struct mcinfo_bank {
96 struct mcinfo_common common;
97
98 uint16_t mc_bank;
99 uint16_t mc_domid;
100 uint64_t mc_status;
101 uint64_t mc_addr;
102 uint64_t mc_misc;
103 uint64_t mc_ctrl2;
104 uint64_t mc_tsc;
105 };
106
107 struct mcinfo_msr {
108 uint64_t reg;
109 uint64_t value;
110 };
111
112
113 struct mcinfo_extended {
114 struct mcinfo_common common;
115 uint32_t mc_msrs;
116
117
118
119
120
121 struct mcinfo_msr mc_msr[sizeof(void *) * 4];
122 };
123
124
125
126
127 #define REC_ACTION_RECOVERED (0x1 << 0)
128
129 #define REC_ACTION_NONE (0x1 << 1)
130
131 #define REC_ACTION_NEED_RESET (0x1 << 2)
132
133
134
135
136
137
138
139 #define MC_ACTION_PAGE_OFFLINE (0x1 << 0)
140
141 #define MC_ACTION_CPU_OFFLINE (0x1 << 1)
142
143 #define MC_ACTION_CACHE_SHRINK (0x1 << 2)
144
145
146
147
148
149 struct page_offline_action {
150
151 uint64_t mfn;
152 uint64_t status;
153 };
154
155 struct cpu_offline_action {
156
157 uint32_t mc_socketid;
158 uint16_t mc_coreid;
159 uint16_t mc_core_threadid;
160 };
161
162 #define MAX_UNION_SIZE 16
163 struct mcinfo_recovery {
164 struct mcinfo_common common;
165 uint16_t mc_bank;
166 uint8_t action_flags;
167 uint8_t action_types;
168 union {
169 struct page_offline_action page_retire;
170 struct cpu_offline_action cpu_offline;
171 uint8_t pad[MAX_UNION_SIZE];
172 } action_info;
173 };
174
175
176 #define MCINFO_MAXSIZE 768
177 struct mc_info {
178
179 uint32_t mi_nentries;
180 uint32_t flags;
181 uint64_t mi_data[(MCINFO_MAXSIZE - 1) / 8];
182 };
183 DEFINE_GUEST_HANDLE_STRUCT(mc_info);
184
185 #define __MC_MSR_ARRAYSIZE 8
186 #define __MC_MSR_MCGCAP 0
187 #define __MC_NMSRS 1
188 #define MC_NCAPS 7
189 struct mcinfo_logical_cpu {
190 uint32_t mc_cpunr;
191 uint32_t mc_chipid;
192 uint16_t mc_coreid;
193 uint16_t mc_threadid;
194 uint32_t mc_apicid;
195 uint32_t mc_clusterid;
196 uint32_t mc_ncores;
197 uint32_t mc_ncores_active;
198 uint32_t mc_nthreads;
199 uint32_t mc_cpuid_level;
200 uint32_t mc_family;
201 uint32_t mc_vendor;
202 uint32_t mc_model;
203 uint32_t mc_step;
204 char mc_vendorid[16];
205 char mc_brandid[64];
206 uint32_t mc_cpu_caps[MC_NCAPS];
207 uint32_t mc_cache_size;
208 uint32_t mc_cache_alignment;
209 uint32_t mc_nmsrvals;
210 struct mcinfo_msr mc_msrvalues[__MC_MSR_ARRAYSIZE];
211 };
212 DEFINE_GUEST_HANDLE_STRUCT(mcinfo_logical_cpu);
213
214
215
216
217
218 #define x86_mcinfo_nentries(_mi) \
219 ((_mi)->mi_nentries)
220
221
222
223
224 #define x86_mcinfo_first(_mi) \
225 ((struct mcinfo_common *)(_mi)->mi_data)
226
227
228
229
230 #define x86_mcinfo_next(_mic) \
231 ((struct mcinfo_common *)((uint8_t *)(_mic) + (_mic)->size))
232
233
234
235
236
237 static inline void x86_mcinfo_lookup(struct mcinfo_common **ret,
238 struct mc_info *mi, uint16_t type)
239 {
240 uint32_t i;
241 struct mcinfo_common *mic;
242 bool found = 0;
243
244 if (!ret || !mi)
245 return;
246
247 mic = x86_mcinfo_first(mi);
248 for (i = 0; i < x86_mcinfo_nentries(mi); i++) {
249 if (mic->type == type) {
250 found = 1;
251 break;
252 }
253 mic = x86_mcinfo_next(mic);
254 }
255
256 *ret = found ? mic : NULL;
257 }
258
259
260
261
262 #define XEN_MC_fetch 1
263 struct xen_mc_fetch {
264
265
266
267
268
269 uint32_t flags;
270 uint32_t _pad0;
271
272 uint64_t fetch_id;
273
274
275 GUEST_HANDLE(mc_info) data;
276 };
277 DEFINE_GUEST_HANDLE_STRUCT(xen_mc_fetch);
278
279
280
281
282
283 #define XEN_MC_notifydomain 2
284 struct xen_mc_notifydomain {
285
286 uint16_t mc_domid;
287 uint16_t mc_vcpuid;
288
289
290 uint32_t flags;
291 };
292 DEFINE_GUEST_HANDLE_STRUCT(xen_mc_notifydomain);
293
294 #define XEN_MC_physcpuinfo 3
295 struct xen_mc_physcpuinfo {
296
297 uint32_t ncpus;
298 uint32_t _pad0;
299
300 GUEST_HANDLE(mcinfo_logical_cpu) info;
301 };
302
303 #define XEN_MC_msrinject 4
304 #define MC_MSRINJ_MAXMSRS 8
305 struct xen_mc_msrinject {
306
307 uint32_t mcinj_cpunr;
308 uint32_t mcinj_flags;
309 uint32_t mcinj_count;
310 uint32_t _pad0;
311 struct mcinfo_msr mcinj_msr[MC_MSRINJ_MAXMSRS];
312 };
313
314
315 #define MC_MSRINJ_F_INTERPOSE 0x1
316
317 #define XEN_MC_mceinject 5
318 struct xen_mc_mceinject {
319 unsigned int mceinj_cpunr;
320 };
321
322 struct xen_mc {
323 uint32_t cmd;
324 uint32_t interface_version;
325 union {
326 struct xen_mc_fetch mc_fetch;
327 struct xen_mc_notifydomain mc_notifydomain;
328 struct xen_mc_physcpuinfo mc_physcpuinfo;
329 struct xen_mc_msrinject mc_msrinject;
330 struct xen_mc_mceinject mc_mceinject;
331 } u;
332 };
333 DEFINE_GUEST_HANDLE_STRUCT(xen_mc);
334
335
336 struct xen_mce {
337 __u64 status;
338 __u64 misc;
339 __u64 addr;
340 __u64 mcgstatus;
341 __u64 ip;
342 __u64 tsc;
343 __u64 time;
344 __u8 cpuvendor;
345 __u8 inject_flags;
346 __u16 pad;
347 __u32 cpuid;
348 __u8 cs;
349 __u8 bank;
350 __u8 cpu;
351 __u8 finished;
352 __u32 extcpu;
353 __u32 socketid;
354 __u32 apicid;
355 __u64 mcgcap;
356 };
357
358
359
360
361
362
363
364
365 #define XEN_MCE_LOG_LEN 32
366
367 struct xen_mce_log {
368 char signature[12];
369 unsigned len;
370 unsigned next;
371 unsigned flags;
372 unsigned recordlen;
373 struct xen_mce entry[XEN_MCE_LOG_LEN];
374 };
375
376 #define XEN_MCE_OVERFLOW 0
377
378 #define XEN_MCE_LOG_SIGNATURE "MACHINECHECK"
379
380 #define MCE_GET_RECORD_LEN _IOR('M', 1, int)
381 #define MCE_GET_LOG_LEN _IOR('M', 2, int)
382 #define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)
383
384 #endif
385 #endif