win-pvdrivers

view common/include/public/arch-ia64.h @ 1106:2d392ecdd366

Fix race is xenvbd causing 30 second freeze under high load
author James Harper <james.harper@bendigoit.com.au>
date Tue Nov 11 23:08:11 2014 +1100 (2014-11-11)
parents 268fe1eb3ae2
children
line source
1 /******************************************************************************
2 * arch-ia64/hypervisor-if.h
3 *
4 * Guest OS interface to IA64 Xen.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 */
26 #ifndef __HYPERVISOR_IF_IA64_H__
27 #define __HYPERVISOR_IF_IA64_H__
29 typedef unsigned long long xen_ulong_t;
30 typedef unsigned long long xen_long_t;
32 /* Structural guest handles introduced in 0x00030201. */
33 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
34 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
35 typedef struct { type *p; } __guest_handle_ ## name
36 #else
37 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
38 typedef type * __guest_handle_ ## name
39 #endif
41 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
42 #define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
43 #define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
44 #define uint64_aligned_t uint64_t
45 #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
46 #ifdef __XEN_TOOLS__
47 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
48 #endif
50 #ifndef __ASSEMBLY__
51 /* Guest handles for primitive C types. */
52 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
53 __DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
54 __DEFINE_XEN_GUEST_HANDLE(ulong, xen_ulong_t);
55 __DEFINE_XEN_GUEST_HANDLE(u64, xen_ulong_t);
56 DEFINE_XEN_GUEST_HANDLE(char);
57 DEFINE_XEN_GUEST_HANDLE(int);
58 DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
59 DEFINE_XEN_GUEST_HANDLE(void);
61 typedef xen_ulong_t xen_pfn_t;
62 DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
63 #define PRI_xen_pfn "lx"
64 #endif
66 /* Arch specific VIRQs definition */
67 #define VIRQ_ITC VIRQ_ARCH_0 /* V. Virtual itc timer */
68 #define VIRQ_MCA_CMC VIRQ_ARCH_1 /* MCA cmc interrupt */
69 #define VIRQ_MCA_CPE VIRQ_ARCH_2 /* MCA cpe interrupt */
71 /* Maximum number of virtual CPUs in multi-processor guests. */
72 /* WARNING: before changing this, check that shared_info fits on a page */
73 #define MAX_VIRT_CPUS 64
75 #ifndef __ASSEMBLY__
77 #define INVALID_MFN (~0UL)
79 #define MEM_G (1UL << 30)
80 #define MEM_M (1UL << 20)
81 #define MEM_K (1UL << 10)
83 #define MMIO_START (3 * MEM_G)
84 #define MMIO_SIZE (512 * MEM_M)
86 #define VGA_IO_START 0xA0000UL
87 #define VGA_IO_SIZE 0x20000
89 #define LEGACY_IO_START (MMIO_START + MMIO_SIZE)
90 #define LEGACY_IO_SIZE (64*MEM_M)
92 #define IO_PAGE_START (LEGACY_IO_START + LEGACY_IO_SIZE)
93 #define IO_PAGE_SIZE PAGE_SIZE
95 #define STORE_PAGE_START (IO_PAGE_START + IO_PAGE_SIZE)
96 #define STORE_PAGE_SIZE PAGE_SIZE
98 #define BUFFER_IO_PAGE_START (STORE_PAGE_START+STORE_PAGE_SIZE)
99 #define BUFFER_IO_PAGE_SIZE PAGE_SIZE
101 #define BUFFER_PIO_PAGE_START (BUFFER_IO_PAGE_START+BUFFER_IO_PAGE_SIZE)
102 #define BUFFER_PIO_PAGE_SIZE PAGE_SIZE
104 #define IO_SAPIC_START 0xfec00000UL
105 #define IO_SAPIC_SIZE 0x100000
107 #define PIB_START 0xfee00000UL
108 #define PIB_SIZE 0x200000
110 #define GFW_START (4*MEM_G -16*MEM_M)
111 #define GFW_SIZE (16*MEM_M)
113 /* Nvram belongs to GFW memory space */
114 #define NVRAM_SIZE (MEM_K * 64)
115 #define NVRAM_START (GFW_START + 10 * MEM_M)
117 #define NVRAM_VALID_SIG 0x4650494e45584948 // "HIXENIPF"
118 struct nvram_save_addr {
119 xen_ulong_t addr;
120 xen_ulong_t signature;
121 };
123 struct pt_fpreg {
124 union {
125 xen_ulong_t bits[2];
126 long double __dummy; /* force 16-byte alignment */
127 } u;
128 };
130 struct cpu_user_regs {
131 /* The following registers are saved by SAVE_MIN: */
132 xen_ulong_t b6; /* scratch */
133 xen_ulong_t b7; /* scratch */
135 xen_ulong_t ar_csd; /* used by cmp8xchg16 (scratch) */
136 xen_ulong_t ar_ssd; /* reserved for future use (scratch) */
138 xen_ulong_t r8; /* scratch (return value register 0) */
139 xen_ulong_t r9; /* scratch (return value register 1) */
140 xen_ulong_t r10; /* scratch (return value register 2) */
141 xen_ulong_t r11; /* scratch (return value register 3) */
143 xen_ulong_t cr_ipsr; /* interrupted task's psr */
144 xen_ulong_t cr_iip; /* interrupted task's instruction pointer */
145 xen_ulong_t cr_ifs; /* interrupted task's function state */
147 xen_ulong_t ar_unat; /* interrupted task's NaT register (preserved) */
148 xen_ulong_t ar_pfs; /* prev function state */
149 xen_ulong_t ar_rsc; /* RSE configuration */
150 /* The following two are valid only if cr_ipsr.cpl > 0: */
151 xen_ulong_t ar_rnat; /* RSE NaT */
152 xen_ulong_t ar_bspstore; /* RSE bspstore */
154 xen_ulong_t pr; /* 64 predicate registers (1 bit each) */
155 xen_ulong_t b0; /* return pointer (bp) */
156 xen_ulong_t loadrs; /* size of dirty partition << 16 */
158 xen_ulong_t r1; /* the gp pointer */
159 xen_ulong_t r12; /* interrupted task's memory stack pointer */
160 xen_ulong_t r13; /* thread pointer */
162 xen_ulong_t ar_fpsr; /* floating point status (preserved) */
163 xen_ulong_t r15; /* scratch */
165 /* The remaining registers are NOT saved for system calls. */
167 xen_ulong_t r14; /* scratch */
168 xen_ulong_t r2; /* scratch */
169 xen_ulong_t r3; /* scratch */
170 xen_ulong_t r16; /* scratch */
171 xen_ulong_t r17; /* scratch */
172 xen_ulong_t r18; /* scratch */
173 xen_ulong_t r19; /* scratch */
174 xen_ulong_t r20; /* scratch */
175 xen_ulong_t r21; /* scratch */
176 xen_ulong_t r22; /* scratch */
177 xen_ulong_t r23; /* scratch */
178 xen_ulong_t r24; /* scratch */
179 xen_ulong_t r25; /* scratch */
180 xen_ulong_t r26; /* scratch */
181 xen_ulong_t r27; /* scratch */
182 xen_ulong_t r28; /* scratch */
183 xen_ulong_t r29; /* scratch */
184 xen_ulong_t r30; /* scratch */
185 xen_ulong_t r31; /* scratch */
186 xen_ulong_t ar_ccv; /* compare/exchange value (scratch) */
188 /*
189 * Floating point registers that the kernel considers scratch:
190 */
191 struct pt_fpreg f6; /* scratch */
192 struct pt_fpreg f7; /* scratch */
193 struct pt_fpreg f8; /* scratch */
194 struct pt_fpreg f9; /* scratch */
195 struct pt_fpreg f10; /* scratch */
196 struct pt_fpreg f11; /* scratch */
197 xen_ulong_t r4; /* preserved */
198 xen_ulong_t r5; /* preserved */
199 xen_ulong_t r6; /* preserved */
200 xen_ulong_t r7; /* preserved */
201 xen_ulong_t eml_unat; /* used for emulating instruction */
202 xen_ulong_t pad0; /* alignment pad */
204 };
205 typedef struct cpu_user_regs cpu_user_regs_t;
207 union vac {
208 xen_ulong_t value;
209 struct {
210 int a_int:1;
211 int a_from_int_cr:1;
212 int a_to_int_cr:1;
213 int a_from_psr:1;
214 int a_from_cpuid:1;
215 int a_cover:1;
216 int a_bsw:1;
217 xen_long_t reserved:57;
218 };
219 };
220 typedef union vac vac_t;
222 union vdc {
223 xen_ulong_t value;
224 struct {
225 int d_vmsw:1;
226 int d_extint:1;
227 int d_ibr_dbr:1;
228 int d_pmc:1;
229 int d_to_pmd:1;
230 int d_itm:1;
231 xen_long_t reserved:58;
232 };
233 };
234 typedef union vdc vdc_t;
236 struct mapped_regs {
237 union vac vac;
238 union vdc vdc;
239 xen_ulong_t virt_env_vaddr;
240 xen_ulong_t reserved1[29];
241 xen_ulong_t vhpi;
242 xen_ulong_t reserved2[95];
243 union {
244 xen_ulong_t vgr[16];
245 xen_ulong_t bank1_regs[16]; // bank1 regs (r16-r31) when bank0 active
246 };
247 union {
248 xen_ulong_t vbgr[16];
249 xen_ulong_t bank0_regs[16]; // bank0 regs (r16-r31) when bank1 active
250 };
251 xen_ulong_t vnat;
252 xen_ulong_t vbnat;
253 xen_ulong_t vcpuid[5];
254 xen_ulong_t reserved3[11];
255 xen_ulong_t vpsr;
256 xen_ulong_t vpr;
257 xen_ulong_t reserved4[76];
258 union {
259 xen_ulong_t vcr[128];
260 struct {
261 xen_ulong_t dcr; // CR0
262 xen_ulong_t itm;
263 xen_ulong_t iva;
264 xen_ulong_t rsv1[5];
265 xen_ulong_t pta; // CR8
266 xen_ulong_t rsv2[7];
267 xen_ulong_t ipsr; // CR16
268 xen_ulong_t isr;
269 xen_ulong_t rsv3;
270 xen_ulong_t iip;
271 xen_ulong_t ifa;
272 xen_ulong_t itir;
273 xen_ulong_t iipa;
274 xen_ulong_t ifs;
275 xen_ulong_t iim; // CR24
276 xen_ulong_t iha;
277 xen_ulong_t rsv4[38];
278 xen_ulong_t lid; // CR64
279 xen_ulong_t ivr;
280 xen_ulong_t tpr;
281 xen_ulong_t eoi;
282 xen_ulong_t irr[4];
283 xen_ulong_t itv; // CR72
284 xen_ulong_t pmv;
285 xen_ulong_t cmcv;
286 xen_ulong_t rsv5[5];
287 xen_ulong_t lrr0; // CR80
288 xen_ulong_t lrr1;
289 xen_ulong_t rsv6[46];
290 };
291 };
292 union {
293 xen_ulong_t reserved5[128];
294 struct {
295 xen_ulong_t precover_ifs;
296 xen_ulong_t unat; // not sure if this is needed until NaT arch is done
297 int interrupt_collection_enabled; // virtual psr.ic
298 /* virtual interrupt deliverable flag is evtchn_upcall_mask in
299 * shared info area now. interrupt_mask_addr is the address
300 * of evtchn_upcall_mask for current vcpu
301 */
302 unsigned char *interrupt_mask_addr;
303 int pending_interruption;
304 unsigned char vpsr_pp;
305 unsigned char vpsr_dfh;
306 unsigned char hpsr_dfh;
307 unsigned char hpsr_mfh;
308 xen_ulong_t reserved5_1[4];
309 int metaphysical_mode; // 1 = use metaphys mapping, 0 = use virtual
310 int banknum; // 0 or 1, which virtual register bank is active
311 xen_ulong_t rrs[8]; // region registers
312 xen_ulong_t krs[8]; // kernel registers
313 xen_ulong_t pkrs[8]; // protection key registers
314 xen_ulong_t tmp[8]; // temp registers (e.g. for hyperprivops)
315 };
316 };
317 };
318 typedef struct mapped_regs mapped_regs_t;
320 struct vpd {
321 struct mapped_regs vpd_low;
322 xen_ulong_t reserved6[3456];
323 xen_ulong_t vmm_avail[128];
324 xen_ulong_t reserved7[4096];
325 };
326 typedef struct vpd vpd_t;
328 #if 0
329 struct arch_vcpu_info {
330 };
331 typedef struct arch_vcpu_info arch_vcpu_info_t;
332 #endif
334 struct arch_shared_info {
335 /* PFN of the start_info page. */
336 xen_ulong_t start_info_pfn;
338 /* Interrupt vector for event channel. */
339 int evtchn_vector;
341 uint64_t pad[32];
342 };
343 typedef struct arch_shared_info arch_shared_info_t;
345 typedef xen_ulong_t xen_callback_t;
347 struct ia64_tr_entry {
348 xen_ulong_t pte;
349 xen_ulong_t itir;
350 xen_ulong_t vadr;
351 xen_ulong_t rid;
352 };
354 struct vcpu_extra_regs {
355 struct ia64_tr_entry itrs[8];
356 struct ia64_tr_entry dtrs[8];
357 xen_ulong_t iva;
358 xen_ulong_t dcr;
359 xen_ulong_t event_callback_ip;
360 };
362 struct vcpu_guest_context {
363 #define VGCF_EXTRA_REGS (1<<1) /* Get/Set extra regs. */
364 xen_ulong_t flags; /* VGCF_* flags */
366 struct cpu_user_regs user_regs;
367 struct vcpu_extra_regs extra_regs;
368 xen_ulong_t privregs_pfn;
369 };
370 typedef struct vcpu_guest_context vcpu_guest_context_t;
371 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
373 /* dom0 vp op */
374 #define __HYPERVISOR_ia64_dom0vp_op __HYPERVISOR_arch_0
375 /* Map io space in machine address to dom0 physical address space.
376 Currently physical assigned address equals to machine address. */
377 #define IA64_DOM0VP_ioremap 0
379 /* Convert a pseudo physical page frame number to the corresponding
380 machine page frame number. If no page is assigned, INVALID_MFN or
381 GPFN_INV_MASK is returned depending on domain's non-vti/vti mode. */
382 #define IA64_DOM0VP_phystomach 1
384 /* Convert a machine page frame number to the corresponding pseudo physical
385 page frame number of the caller domain. */
386 #define IA64_DOM0VP_machtophys 3
388 /* Reserved for future use. */
389 #define IA64_DOM0VP_iounmap 4
391 /* Unmap and free pages contained in the specified pseudo physical region. */
392 #define IA64_DOM0VP_zap_physmap 5
394 /* Assign machine page frame to dom0's pseudo physical address space. */
395 #define IA64_DOM0VP_add_physmap 6
397 /* expose the p2m table into domain */
398 #define IA64_DOM0VP_expose_p2m 7
400 /* xen perfmon */
401 #define IA64_DOM0VP_perfmon 8
403 /* gmfn version of IA64_DOM0VP_add_physmap */
404 #define IA64_DOM0VP_add_physmap_with_gmfn 9
406 /* Add an I/O port space range */
407 #define IA64_DOM0VP_add_io_space 11
409 // flags for page assignement to pseudo physical address space
410 #define _ASSIGN_readonly 0
411 #define ASSIGN_readonly (1UL << _ASSIGN_readonly)
412 #define ASSIGN_writable (0UL << _ASSIGN_readonly) // dummy flag
413 /* Internal only: memory attribute must be WC/UC/UCE. */
414 #define _ASSIGN_nocache 1
415 #define ASSIGN_nocache (1UL << _ASSIGN_nocache)
416 // tlb tracking
417 #define _ASSIGN_tlb_track 2
418 #define ASSIGN_tlb_track (1UL << _ASSIGN_tlb_track)
419 /* Internal only: associated with PGC_allocated bit */
420 #define _ASSIGN_pgc_allocated 3
421 #define ASSIGN_pgc_allocated (1UL << _ASSIGN_pgc_allocated)
423 /* This structure has the same layout of struct ia64_boot_param, defined in
424 <asm/system.h>. It is redefined here to ease use. */
425 struct xen_ia64_boot_param {
426 xen_ulong_t command_line; /* physical address of cmd line args */
427 xen_ulong_t efi_systab; /* physical address of EFI system table */
428 xen_ulong_t efi_memmap; /* physical address of EFI memory map */
429 xen_ulong_t efi_memmap_size; /* size of EFI memory map */
430 xen_ulong_t efi_memdesc_size; /* size of an EFI memory map descriptor */
431 unsigned int efi_memdesc_version; /* memory descriptor version */
432 struct {
433 unsigned short num_cols; /* number of columns on console. */
434 unsigned short num_rows; /* number of rows on console. */
435 unsigned short orig_x; /* cursor's x position */
436 unsigned short orig_y; /* cursor's y position */
437 } console_info;
438 xen_ulong_t fpswa; /* physical address of the fpswa interface */
439 xen_ulong_t initrd_start;
440 xen_ulong_t initrd_size;
441 xen_ulong_t domain_start; /* va where the boot time domain begins */
442 xen_ulong_t domain_size; /* how big is the boot domain */
443 };
445 #endif /* !__ASSEMBLY__ */
447 /* Size of the shared_info area (this is not related to page size). */
448 #define XSI_SHIFT 14
449 #define XSI_SIZE (1 << XSI_SHIFT)
450 /* Log size of mapped_regs area (64 KB - only 4KB is used). */
451 #define XMAPPEDREGS_SHIFT 12
452 #define XMAPPEDREGS_SIZE (1 << XMAPPEDREGS_SHIFT)
453 /* Offset of XASI (Xen arch shared info) wrt XSI_BASE. */
454 #define XMAPPEDREGS_OFS XSI_SIZE
456 /* Hyperprivops. */
457 #define HYPERPRIVOP_START 0x1
458 #define HYPERPRIVOP_RFI (HYPERPRIVOP_START + 0x0)
459 #define HYPERPRIVOP_RSM_DT (HYPERPRIVOP_START + 0x1)
460 #define HYPERPRIVOP_SSM_DT (HYPERPRIVOP_START + 0x2)
461 #define HYPERPRIVOP_COVER (HYPERPRIVOP_START + 0x3)
462 #define HYPERPRIVOP_ITC_D (HYPERPRIVOP_START + 0x4)
463 #define HYPERPRIVOP_ITC_I (HYPERPRIVOP_START + 0x5)
464 #define HYPERPRIVOP_SSM_I (HYPERPRIVOP_START + 0x6)
465 #define HYPERPRIVOP_GET_IVR (HYPERPRIVOP_START + 0x7)
466 #define HYPERPRIVOP_GET_TPR (HYPERPRIVOP_START + 0x8)
467 #define HYPERPRIVOP_SET_TPR (HYPERPRIVOP_START + 0x9)
468 #define HYPERPRIVOP_EOI (HYPERPRIVOP_START + 0xa)
469 #define HYPERPRIVOP_SET_ITM (HYPERPRIVOP_START + 0xb)
470 #define HYPERPRIVOP_THASH (HYPERPRIVOP_START + 0xc)
471 #define HYPERPRIVOP_PTC_GA (HYPERPRIVOP_START + 0xd)
472 #define HYPERPRIVOP_ITR_D (HYPERPRIVOP_START + 0xe)
473 #define HYPERPRIVOP_GET_RR (HYPERPRIVOP_START + 0xf)
474 #define HYPERPRIVOP_SET_RR (HYPERPRIVOP_START + 0x10)
475 #define HYPERPRIVOP_SET_KR (HYPERPRIVOP_START + 0x11)
476 #define HYPERPRIVOP_FC (HYPERPRIVOP_START + 0x12)
477 #define HYPERPRIVOP_GET_CPUID (HYPERPRIVOP_START + 0x13)
478 #define HYPERPRIVOP_GET_PMD (HYPERPRIVOP_START + 0x14)
479 #define HYPERPRIVOP_GET_EFLAG (HYPERPRIVOP_START + 0x15)
480 #define HYPERPRIVOP_SET_EFLAG (HYPERPRIVOP_START + 0x16)
481 #define HYPERPRIVOP_RSM_BE (HYPERPRIVOP_START + 0x17)
482 #define HYPERPRIVOP_GET_PSR (HYPERPRIVOP_START + 0x18)
483 #define HYPERPRIVOP_MAX (0x19)
485 /* Fast and light hypercalls. */
486 #define __HYPERVISOR_ia64_fast_eoi __HYPERVISOR_arch_1
488 /* Xencomm macros. */
489 #define XENCOMM_INLINE_MASK 0xf800000000000000UL
490 #define XENCOMM_INLINE_FLAG 0x8000000000000000UL
492 #define XENCOMM_IS_INLINE(addr) \
493 (((xen_ulong_t)(addr) & XENCOMM_INLINE_MASK) == XENCOMM_INLINE_FLAG)
494 #define XENCOMM_INLINE_ADDR(addr) \
495 ((xen_ulong_t)(addr) & ~XENCOMM_INLINE_MASK)
497 /* xen perfmon */
498 #ifdef XEN
499 #ifndef __ASSEMBLY__
500 #ifndef _ASM_IA64_PERFMON_H
502 #include <xen/list.h> // asm/perfmon.h requires struct list_head
503 #include <asm/perfmon.h>
504 // for PFM_xxx and pfarg_features_t, pfarg_context_t, pfarg_reg_t, pfarg_load_t
506 #endif /* _ASM_IA64_PERFMON_H */
508 DEFINE_XEN_GUEST_HANDLE(pfarg_features_t);
509 DEFINE_XEN_GUEST_HANDLE(pfarg_context_t);
510 DEFINE_XEN_GUEST_HANDLE(pfarg_reg_t);
511 DEFINE_XEN_GUEST_HANDLE(pfarg_load_t);
512 #endif /* __ASSEMBLY__ */
513 #endif /* XEN */
515 #endif /* __HYPERVISOR_IF_IA64_H__ */
517 /*
518 * Local variables:
519 * mode: C
520 * c-set-style: "BSD"
521 * c-basic-offset: 4
522 * tab-width: 4
523 * indent-tabs-mode: nil
524 * End:
525 */