Xen Test Framework
xen-x86_64.h
Go to the documentation of this file.
1 #ifndef XEN_PUBLIC_ARCH_X86_XEN_X86_64_H
2 #define XEN_PUBLIC_ARCH_X86_XEN_X86_64_H
3 
4 /*
5  * 64-bit segment selectors
6  * These flat segments are in the Xen-private section of every GDT. Since these
7  * are also present in the initial GDT, many OSes will be able to avoid
8  * installing their own GDT.
9  */
10 
11 #define FLAT_RING3_CS32 0xe023 /* GDT index 260 */
12 #define FLAT_RING3_CS64 0xe033 /* GDT index 261 */
13 #define FLAT_RING3_DS32 0xe02b /* GDT index 262 */
14 #define FLAT_RING3_DS64 0x0000 /* NULL selector */
15 #define FLAT_RING3_SS32 0xe02b /* GDT index 262 */
16 #define FLAT_RING3_SS64 0xe02b /* GDT index 262 */
17 
18 #define MACH2PHYS_VIRT_START 0xFFFF800000000000UL
19 
20 /* Guest exited in SYSCALL context? Return to guest with SYSRET? */
21 #define VGCF_in_syscall 0x100
22 
23 #ifndef __ASSEMBLY__
24 
25 /* Anonymous unions include all permissible names (e.g., al/ah/ax/eax/rax). */
26 #define __DECL_REG_LOHI(which) union { \
27  uint64_t r ## which ## x; \
28  uint32_t e ## which ## x; \
29  uint16_t which ## x; \
30  struct { \
31  uint8_t which ## l; \
32  uint8_t which ## h; \
33  }; \
34 }
35 #define __DECL_REG_LO8(name) union { \
36  uint64_t r ## name; \
37  uint32_t e ## name; \
38  uint16_t name; \
39  uint8_t name ## l; \
40 }
41 #define __DECL_REG_LO16(name) union { \
42  uint64_t r ## name; \
43  uint32_t e ## name; \
44  uint16_t name; \
45 }
46 #define __DECL_REG_HI(num) union { \
47  uint64_t r ## num; \
48  uint32_t r ## num ## d; \
49  uint16_t r ## num ## w; \
50  uint8_t r ## num ## b; \
51 }
52 
53 struct xen_cpu_user_regs {
54  __DECL_REG_HI(15);
55  __DECL_REG_HI(14);
56  __DECL_REG_HI(13);
57  __DECL_REG_HI(12);
58  __DECL_REG_LO8(bp);
59  __DECL_REG_LOHI(b);
60  __DECL_REG_HI(11);
61  __DECL_REG_HI(10);
62  __DECL_REG_HI(9);
63  __DECL_REG_HI(8);
64  __DECL_REG_LOHI(a);
65  __DECL_REG_LOHI(c);
66  __DECL_REG_LOHI(d);
67  __DECL_REG_LO8(si);
68  __DECL_REG_LO8(di);
69  uint32_t error_code; /* private */
70  uint32_t entry_vector; /* private */
71  __DECL_REG_LO16(ip);
75  __DECL_REG_LO16(flags); /* rflags.IF == !saved_upcall_mask */
76  __DECL_REG_LO8(sp);
77  uint16_t ss, _pad2[3];
78  uint16_t es, _pad3[3];
79  uint16_t ds, _pad4[3];
80  uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base. */
81  uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
82 };
83 
84 #undef __DECL_REG_LOHI
85 #undef __DECL_REG_LO8
86 #undef __DECL_REG_LO16
87 #undef __DECL_REG_HI
88 
89 static inline unsigned long xen_pfn_to_cr3(unsigned long pfn)
90 {
91  return pfn << 12;
92 }
93 
94 static inline unsigned long xen_cr3_to_pfn(unsigned long cr3)
95 {
96  return cr3 >> 12;
97 }
98 
99 struct arch_vcpu_info {
100  unsigned long cr2;
101  unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
102 };
103 
104 typedef unsigned long xen_callback_t;
105 
106 #define INIT_XEN_CALLBACK(_cs, _ip) (_ip)
107 
108 #endif /* __ASSEMBLY__ */
109 
110 #endif /* XEN_PUBLIC_ARCH_X86_XEN_X86_64_H */
111 
112 /*
113  * Local variables:
114  * mode: C
115  * c-file-style: "BSD"
116  * c-basic-offset: 4
117  * tab-width: 4
118  * indent-tabs-mode: nil
119  * End:
120  */
uint8_t saved_upcall_mask
Definition: xen-x86_32.h:48
uint32_t error_code
Definition: xen-x86_64.h:69
static unsigned long xen_pfn_to_cr3(unsigned long pfn)
Definition: xen-x86_64.h:89
uint16_t _pad2
Definition: xen-x86_32.h:53
uint16_t _pad1
Definition: xen-x86_32.h:52
uint32_t entry_vector
Definition: xen-x86_64.h:70
static unsigned long xen_cr3_to_pfn(unsigned long cr3)
Definition: xen-x86_64.h:94
uint16_t _pad4
Definition: xen-x86_32.h:55
uint16_t _pad6[3]
Definition: xen-x86_64.h:81
__UINT32_TYPE__ uint32_t
Definition: stdint.h:16
uint16_t _pad5
Definition: xen-x86_32.h:56
unsigned long xen_callback_t
Definition: xen-x86_64.h:104
uint16_t _pad3
Definition: xen-x86_32.h:54
__UINT16_TYPE__ uint16_t
Definition: stdint.h:15
__UINT8_TYPE__ uint8_t
Definition: stdint.h:14