debuggers.hg

view xen/include/public/arch-x86_64.h @ 3686:5c112b235281

bitkeeper revision 1.1159.212.85 (42038b45EjUo-1JiSCHXW0Wav4TZGQ)

x86_64 progress: now entering ring 3. Need a hypercall (SYSCALL)
entry point, and some kind of DOM0 image to test against.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Fri Feb 04 14:48:37 2005 +0000 (2005-02-04)
parents 1c55bbe02576
children 393483ae9f62 aa3214cefa34
line source
1 /******************************************************************************
2 * arch-x86_64.h
3 *
4 * Guest OS interface to x86 64-bit Xen.
5 *
6 * Copyright (c) 2004, K A Fraser
7 */
9 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
10 #define __XEN_PUBLIC_ARCH_X86_64_H__
12 #ifndef PACKED
13 /* GCC-specific way to pack structure definitions (no implicit padding). */
14 #define PACKED __attribute__ ((packed))
15 #endif
17 /* Pointers are naturally 64 bits in this architecture; no padding needed. */
18 #define _MEMORY_PADDING(_X)
19 #define MEMORY_PADDING
21 /*
22 * SEGMENT DESCRIPTOR TABLES
23 */
24 /*
25 * A number of GDT entries are reserved by Xen. These are not situated at the
26 * start of the GDT because some stupid OSes export hard-coded selector values
27 * in their ABI. These hard-coded values are always near the start of the GDT,
28 * so Xen places itself out of the way.
29 *
30 * NB. The reserved range is inclusive (that is, both FIRST_RESERVED_GDT_ENTRY
31 * and LAST_RESERVED_GDT_ENTRY are reserved).
32 */
33 #define NR_RESERVED_GDT_ENTRIES 72
34 #define FIRST_RESERVED_GDT_ENTRY 256
35 #define LAST_RESERVED_GDT_ENTRY \
36 (FIRST_RESERVED_GDT_ENTRY + NR_RESERVED_GDT_ENTRIES - 1)
38 /*
39 * 64-bit segment selectors
40 * These flat segments are in the Xen-private section of every GDT. Since these
41 * are also present in the initial GDT, many OSes will be able to avoid
42 * installing their own GDT.
43 */
45 #define FLAT_RING3_CS32 0x0823 /* GDT index 260 */
46 #define FLAT_RING3_CS64 0x082b /* GDT index 261 */
47 #define FLAT_RING3_DS32 0x0833 /* GDT index 262 */
48 #define FLAT_RING3_DS64 0x0000 /* NULL selector */
49 #define FLAT_RING3_SS32 0x0833 /* GDT index 262 */
50 #define FLAT_RING3_SS64 0x0833 /* GDT index 262 */
52 #define FLAT_GUESTOS_DS64 FLAT_RING3_DS64
53 #define FLAT_GUESTOS_DS32 FLAT_RING3_DS32
54 #define FLAT_GUESTOS_DS FLAT_GUESTOS_DS64
55 #define FLAT_GUESTOS_CS64 FLAT_RING3_CS64
56 #define FLAT_GUESTOS_CS32 FLAT_RING3_CS32
57 #define FLAT_GUESTOS_CS FLAT_GUESTOS_CS64
58 #define FLAT_GUESTOS_SS64 FLAT_RING3_SS64
59 #define FLAT_GUESTOS_SS32 FLAT_RING3_SS32
60 #define FLAT_GUESTOS_SS FLAT_GUESTOS_SS64
62 #define FLAT_USER_DS64 FLAT_RING3_DS64
63 #define FLAT_USER_DS32 FLAT_RING3_DS32
64 #define FLAT_USER_DS FLAT_USER_DS64
65 #define FLAT_USER_CS64 FLAT_RING3_CS64
66 #define FLAT_USER_CS32 FLAT_RING3_CS32
67 #define FLAT_USER_CS FLAT_USER_CS64
68 #define FLAT_USER_SS64 FLAT_RING3_SS64
69 #define FLAT_USER_SS32 FLAT_RING3_SS32
70 #define FLAT_USER_SS FLAT_USER_SS64
72 /* And the trap vector is... */
73 #define TRAP_INSTR "syscall"
75 #ifndef HYPERVISOR_VIRT_START
76 #define HYPERVISOR_VIRT_START (0xFFFF800000000000UL)
77 #define HYPERVISOR_VIRT_END (0xFFFF880000000000UL)
78 #endif
80 /* The machine->physical mapping table starts at this address, read-only. */
81 #ifndef machine_to_phys_mapping
82 #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
83 #endif
85 #ifndef __ASSEMBLY__
87 /* NB. Both the following are 64 bits each. */
88 typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */
89 typedef unsigned long cpureg_t; /* Full-sized register. */
91 /*
92 * Send an array of these to HYPERVISOR_set_trap_table()
93 */
94 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
95 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
96 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
97 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
98 typedef struct {
99 u8 vector; /* 0: exception vector */
100 u8 flags; /* 1: 0-3: privilege level; 4: clear event enable? */
101 u16 cs; /* 2: code selector */
102 u32 __pad; /* 4 */
103 memory_t address; /* 8: code address */
104 } PACKED trap_info_t; /* 16 bytes */
106 typedef struct
107 {
108 unsigned long r15;
109 unsigned long r14;
110 unsigned long r13;
111 unsigned long r12;
112 union { unsigned long rbp, ebp; } PACKED;
113 union { unsigned long rbx, ebx; } PACKED;
114 unsigned long r11;
115 unsigned long r10;
116 unsigned long r9;
117 unsigned long r8;
118 union { unsigned long rax, eax; } PACKED;
119 union { unsigned long rcx, ecx; } PACKED;
120 union { unsigned long rdx, edx; } PACKED;
121 union { unsigned long rsi, esi; } PACKED;
122 union { unsigned long rdi, edi; } PACKED;
123 unsigned long _unused;
124 union { unsigned long rip, eip; } PACKED;
125 unsigned long cs;
126 union { unsigned long rflags, eflags; } PACKED;
127 union { unsigned long rsp, esp; } PACKED;
128 unsigned long ss;
129 unsigned long es;
130 unsigned long ds;
131 unsigned long fs;
132 unsigned long gs;
133 } PACKED execution_context_t;
135 typedef u64 tsc_timestamp_t; /* RDTSC timestamp */
137 /*
138 * The following is all CPU context. Note that the i387_ctxt block is filled
139 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
140 */
141 typedef struct {
142 #define ECF_I387_VALID (1<<0)
143 #define ECF_VMX_GUEST (2<<0)
144 unsigned long flags;
145 execution_context_t cpu_ctxt; /* User-level CPU registers */
146 char fpu_ctxt[512]; /* User-level FPU registers */
147 trap_info_t trap_ctxt[256]; /* Virtual IDT */
148 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
149 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
150 unsigned long guestos_ss, guestos_esp; /* Virtual TSS (only SS1/ESP1) */
151 unsigned long pt_base; /* CR3 (pagetable base) */
152 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
153 unsigned long event_callback_cs; /* CS:EIP of event callback */
154 unsigned long event_callback_eip;
155 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
156 unsigned long failsafe_callback_eip;
157 } PACKED full_execution_context_t;
159 typedef struct {
160 /* MFN of a table of MFNs that make up p2m table */
161 u64 pfn_to_mfn_frame_list;
162 } PACKED arch_shared_info_t;
164 typedef struct {
165 } PACKED arch_vcpu_info_t;
167 #endif /* !__ASSEMBLY__ */
169 #endif