1#ifndef _ASM_X86_XEN_INTERFACE_64_H
2#define _ASM_X86_XEN_INTERFACE_64_H
3
4
5
6
7
8
9
10
11#define FLAT_RING3_CS32 0xe023
12#define FLAT_RING3_CS64 0xe033
13#define FLAT_RING3_DS32 0xe02b
14#define FLAT_RING3_DS64 0x0000
15#define FLAT_RING3_SS32 0xe02b
16#define FLAT_RING3_SS64 0xe02b
17
18#define FLAT_KERNEL_DS64 FLAT_RING3_DS64
19#define FLAT_KERNEL_DS32 FLAT_RING3_DS32
20#define FLAT_KERNEL_DS FLAT_KERNEL_DS64
21#define FLAT_KERNEL_CS64 FLAT_RING3_CS64
22#define FLAT_KERNEL_CS32 FLAT_RING3_CS32
23#define FLAT_KERNEL_CS FLAT_KERNEL_CS64
24#define FLAT_KERNEL_SS64 FLAT_RING3_SS64
25#define FLAT_KERNEL_SS32 FLAT_RING3_SS32
26#define FLAT_KERNEL_SS FLAT_KERNEL_SS64
27
28#define FLAT_USER_DS64 FLAT_RING3_DS64
29#define FLAT_USER_DS32 FLAT_RING3_DS32
30#define FLAT_USER_DS FLAT_USER_DS64
31#define FLAT_USER_CS64 FLAT_RING3_CS64
32#define FLAT_USER_CS32 FLAT_RING3_CS32
33#define FLAT_USER_CS FLAT_USER_CS64
34#define FLAT_USER_SS64 FLAT_RING3_SS64
35#define FLAT_USER_SS32 FLAT_RING3_SS32
36#define FLAT_USER_SS FLAT_USER_SS64
37
38#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
39#define __HYPERVISOR_VIRT_END 0xFFFF880000000000
40#define __MACH2PHYS_VIRT_START 0xFFFF800000000000
41#define __MACH2PHYS_VIRT_END 0xFFFF804000000000
42#define __MACH2PHYS_SHIFT 3
43
44
45
46
47
48
49#define SEGBASE_FS 0
50#define SEGBASE_GS_USER 1
51#define SEGBASE_GS_KERNEL 2
52#define SEGBASE_GS_USER_SEL 3
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75#define _VGCF_in_syscall 8
76#define VGCF_in_syscall (1<<_VGCF_in_syscall)
77#define VGCF_IN_SYSCALL VGCF_in_syscall
78
79#ifndef __ASSEMBLY__
80
81struct iret_context {
82
83 uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
84
85};
86
87#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
88
89#define __DECL_REG(name) union { \
90 uint64_t r ## name, e ## name; \
91 uint32_t _e ## name; \
92}
93#else
94
95#define __DECL_REG(name) uint64_t r ## name
96#endif
97
98struct cpu_user_regs {
99 uint64_t r15;
100 uint64_t r14;
101 uint64_t r13;
102 uint64_t r12;
103 __DECL_REG(bp);
104 __DECL_REG(bx);
105 uint64_t r11;
106 uint64_t r10;
107 uint64_t r9;
108 uint64_t r8;
109 __DECL_REG(ax);
110 __DECL_REG(cx);
111 __DECL_REG(dx);
112 __DECL_REG(si);
113 __DECL_REG(di);
114 uint32_t error_code;
115 uint32_t entry_vector;
116 __DECL_REG(ip);
117 uint16_t cs, _pad0[1];
118 uint8_t saved_upcall_mask;
119 uint8_t _pad1[3];
120 __DECL_REG(flags);
121 __DECL_REG(sp);
122 uint16_t ss, _pad2[3];
123 uint16_t es, _pad3[3];
124 uint16_t ds, _pad4[3];
125 uint16_t fs, _pad5[3];
126 uint16_t gs, _pad6[3];
127};
128DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs);
129
130#undef __DECL_REG
131
132#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
133#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
134
135struct arch_vcpu_info {
136 unsigned long cr2;
137 unsigned long pad;
138};
139
140typedef unsigned long xen_callback_t;
141
142#define XEN_CALLBACK(__cs, __rip) \
143 ((unsigned long)(__rip))
144
145#endif
146
147
148#endif
149