Xen Test Framework
xen.h
Go to the documentation of this file.
1/*
2 * Xen x86 public interface
3 */
4
5#ifndef XEN_PUBLIC_ARCH_X86_XEN_H
6#define XEN_PUBLIC_ARCH_X86_XEN_H
7
8#if defined (__i386__)
9# include "xen-x86_32.h"
10#elif defined (__x86_64__)
11# include "xen-x86_64.h"
12#else
13# error Bad architecture
14#endif
15
16#include "cpuid.h"
17
18#ifndef __ASSEMBLY__
19typedef unsigned long xen_pfn_t;
20
21/*
22 * Send an array of these to HYPERVISOR_set_trap_table().
23 * Terminate the array with a sentinel entry, with traps[].address==0.
24 * The privilege level specifies which modes may enter a trap via a software
25 * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
26 * privilege levels as follows:
27 * Level == 0: Noone may enter
28 * Level == 1: Kernel may enter
29 * Level == 2: Kernel may enter
30 * Level == 3: Everyone may enter
31 */
33 uint8_t vector; /* exception vector */
34 uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
35 uint16_t cs; /* code selector */
36 unsigned long address; /* code offset */
37};
38
39/*
40 * The following is all CPU context. Note that the fpu_ctxt block is filled
41 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
42 */
44 /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
45 struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
46#define VGCF_I387_VALID (1<<0)
47#define VGCF_IN_KERNEL (1<<2)
48#define _VGCF_i387_valid 0
49#define VGCF_i387_valid (1<<_VGCF_i387_valid)
50#define _VGCF_in_kernel 2
51#define VGCF_in_kernel (1<<_VGCF_in_kernel)
52#define _VGCF_failsafe_disables_events 3
53#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
54#define _VGCF_syscall_disables_events 4
55#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
56#define _VGCF_online 5
57#define VGCF_online (1<<_VGCF_online)
58 unsigned long flags; /* VGCF_* flags */
59 struct xen_cpu_user_regs user_regs; /* User-level CPU registers */
60 struct xen_trap_info trap_ctxt[256]; /* Virtual IDT */
61 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
62 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
63 unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
64 /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
65 unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
66 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
67#ifdef __i386__
68 unsigned long event_callback_cs; /* CS:EIP of event callback */
69 unsigned long event_callback_eip;
70 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
71 unsigned long failsafe_callback_eip;
72#else
73 unsigned long event_callback_eip;
74 unsigned long failsafe_callback_eip;
75 union {
76 unsigned long syscall_callback_eip;
77 struct {
78 unsigned int event_callback_cs; /* compat CS of event cb */
79 unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */
80 };
81 };
82#endif
83 unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
84#ifdef __x86_64__
85 /* Segment base addresses. */
86 uint64_t fs_base;
87 uint64_t gs_base_kernel;
88 uint64_t gs_base_user;
89#endif
90};
92
94 /*
95 * Number of valid entries in the p2m table(s) anchored at
96 * pfn_to_mfn_frame_list_list and/or p2m_vaddr.
97 */
98 unsigned long max_pfn;
99 /*
100 * Frame containing list of mfns containing list of mfns containing p2m.
101 * A value of 0 indicates it has not yet been set up, ~0 indicates it has
102 * been set to invalid e.g. due to the p2m being too large for the 3-level
103 * p2m tree. In this case the linear mapper p2m list anchored at p2m_vaddr
104 * is to be used.
105 */
107 unsigned long nmi_reason;
108 /*
109 * Following three fields are valid if p2m_cr3 contains a value different
110 * from 0.
111 * p2m_cr3 is the root of the address space where p2m_vaddr is valid.
112 * p2m_cr3 is in the same format as a cr3 value in the vcpu register state
113 * and holds the folded machine frame number (via xen_pfn_to_cr3) of a
114 * L3 or L4 page table.
115 * p2m_vaddr holds the virtual address of the linear p2m list. All entries
116 * in the range [0...max_pfn[ are accessible via this pointer.
117 * p2m_generation will be incremented by the guest before and after each
118 * change of the mappings of the p2m list. p2m_generation starts at 0 and
119 * a value with the least significant bit set indicates that a mapping
120 * update is in progress. This allows guest external software (e.g. in Dom0)
121 * to verify that read mappings are consistent and whether they have changed
122 * since the last check.
123 * Modifying a p2m element in the linear p2m list is allowed via an atomic
124 * write only.
125 */
126 unsigned long p2m_cr3; /* cr3 value of the p2m address space */
127 unsigned long p2m_vaddr; /* virtual address of the p2m list */
128 unsigned long p2m_generation; /* generation count of p2m mapping */
129#ifdef __i386__
130 /* There's no room for this field in the generic structure. */
131 uint32_t wc_sec_hi;
132#endif
133};
134
135#endif
136
147#ifdef __ASSEMBLY__
148#define _ASM_XEN_FEP ud2a; .ascii "xen";
149#else
150#define _ASM_XEN_FEP "ud2a; .ascii \"xen\";"
151#define _BIN_XEN_FEP "\x0f\x0bxen"
152#endif
153
154#endif /* XEN_PUBLIC_ARCH_X86_XEN_H */
155
156/*
157 * Local variables:
158 * mode: C
159 * c-file-style: "BSD"
160 * c-basic-offset: 4
161 * tab-width: 4
162 * indent-tabs-mode: nil
163 * End:
164 */
unsigned long xen_pfn_t
Definition: xen.h:19
__UINT32_TYPE__ uint32_t
Definition: stdint.h:16
__UINT64_TYPE__ uint64_t
Definition: stdint.h:17
__UINT8_TYPE__ uint8_t
Definition: stdint.h:14
__UINT16_TYPE__ uint16_t
Definition: stdint.h:15
unsigned long max_pfn
Definition: xen.h:98
unsigned long p2m_generation
Definition: xen.h:128
unsigned long p2m_vaddr
Definition: xen.h:127
unsigned long p2m_cr3
Definition: xen.h:126
unsigned long nmi_reason
Definition: xen.h:107
xen_pfn_t pfn_to_mfn_frame_list_list
Definition: xen.h:106
uint16_t cs
Definition: xen.h:35
unsigned long address
Definition: xen.h:36
uint8_t flags
Definition: xen.h:34
uint8_t vector
Definition: xen.h:33
struct xen_cpu_user_regs user_regs
Definition: xen.h:59
struct xen_trap_info trap_ctxt[256]
Definition: xen.h:60
unsigned long kernel_sp
Definition: xen.h:63
unsigned long kernel_ss
Definition: xen.h:63
unsigned long gdt_ents
Definition: xen.h:62
unsigned long debugreg[8]
Definition: xen.h:66
unsigned long vm_assist
Definition: xen.h:83
unsigned long flags
Definition: xen.h:58
unsigned int failsafe_callback_cs
Definition: xen.h:79
char x[512]
Definition: xen.h:45
struct xen_vcpu_guest_context::@36 fpu_ctxt
unsigned long syscall_callback_eip
Definition: xen.h:76
unsigned int event_callback_cs
Definition: xen.h:78
unsigned long failsafe_callback_eip
Definition: xen.h:74
unsigned long event_callback_eip
Definition: xen.h:73
unsigned long ldt_base
Definition: xen.h:61
unsigned long ctrlreg[8]
Definition: xen.h:65
unsigned long gdt_frames[16]
Definition: xen.h:62
unsigned long ldt_ents
Definition: xen.h:61