Fri Dec 9 10:14:20 2011 UTC ()
re-apply merge loss


(cegger)
diff -r1.1.1.2 -r1.2 src/sys/arch/xen/include/xen-public/arch-x86/xen.h

cvs diff -r1.1.1.2 -r1.2 src/sys/arch/xen/include/xen-public/arch-x86/Attic/xen.h (switch to unified diff)

--- src/sys/arch/xen/include/xen-public/arch-x86/Attic/xen.h 2011/12/07 14:41:17 1.1.1.2
+++ src/sys/arch/xen/include/xen-public/arch-x86/Attic/xen.h 2011/12/09 10:14:20 1.2
@@ -1,202 +1,206 @@ @@ -1,202 +1,206 @@
1/* $NetBSD: xen.h,v 1.1.1.2 2011/12/07 14:41:17 cegger Exp $ */ 1/* $NetBSD: xen.h,v 1.2 2011/12/09 10:14:20 cegger Exp $ */
2/****************************************************************************** 2/******************************************************************************
3 * arch-x86/xen.h 3 * arch-x86/xen.h
4 *  4 *
5 * Guest OS interface to x86 Xen. 5 * Guest OS interface to x86 Xen.
6 *  6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to 8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the 9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is 11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions: 12 * furnished to do so, subject to the following conditions:
13 * 13 *
14 * The above copyright notice and this permission notice shall be included in 14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software. 15 * all copies or substantial portions of the Software.
16 * 16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE. 23 * DEALINGS IN THE SOFTWARE.
24 * 24 *
25 * Copyright (c) 2004-2006, K A Fraser 25 * Copyright (c) 2004-2006, K A Fraser
26 */ 26 */
27 27
28#include "../xen.h" 28#include "../xen.h"
29 29
30#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__ 30#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
31#define __XEN_PUBLIC_ARCH_X86_XEN_H__ 31#define __XEN_PUBLIC_ARCH_X86_XEN_H__
32 32
33/* Structural guest handles introduced in 0x00030201. */ 33/* Structural guest handles introduced in 0x00030201. */
34#if __XEN_INTERFACE_VERSION__ >= 0x00030201 34#if __XEN_INTERFACE_VERSION__ >= 0x00030201
35#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ 35#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
36 typedef struct { type *p; } __guest_handle_ ## name 36 typedef struct { type *p; } __guest_handle_ ## name
37#else 37#else
38#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ 38#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
39 typedef type * __guest_handle_ ## name 39 typedef type * __guest_handle_ ## name
40#endif 40#endif
41 41
42#define __DEFINE_XEN_GUEST_HANDLE(name, type) \ 42#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
43 ___DEFINE_XEN_GUEST_HANDLE(name, type); \ 43 ___DEFINE_XEN_GUEST_HANDLE(name, type); \
44 ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) 44 ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
45#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) 45#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
46#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name 46#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name
47#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) 47#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name)
48#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) 48#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0)
49#ifdef __XEN_TOOLS__ 49
 50#if __XEN_INTERFACE_VERSION__ >= 0x00030201
 51#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val)
50#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) 52#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
 53#else
 54#define set_xen_guest_handle(hnd, val) (hnd) = val
 55#define get_xen_guest_handle(val, hnd) val = (hnd)
51#endif 56#endif
52#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) 
53 57
54#if defined(__i386__) 58#if defined(__i386__)
55#include "xen-x86_32.h" 59#include "xen-x86_32.h"
56#elif defined(__x86_64__) 60#elif defined(__x86_64__)
57#include "xen-x86_64.h" 61#include "xen-x86_64.h"
58#endif 62#endif
59 63
60#ifndef __ASSEMBLY__ 64#ifndef __ASSEMBLY__
61typedef unsigned long xen_pfn_t; 65typedef unsigned long xen_pfn_t;
62#define PRI_xen_pfn "lx" 66#define PRI_xen_pfn "lx"
63#endif 67#endif
64 68
65/* 69/*
66 * SEGMENT DESCRIPTOR TABLES 70 * SEGMENT DESCRIPTOR TABLES
67 */ 71 */
68/* 72/*
69 * A number of GDT entries are reserved by Xen. These are not situated at the 73 * A number of GDT entries are reserved by Xen. These are not situated at the
70 * start of the GDT because some stupid OSes export hard-coded selector values 74 * start of the GDT because some stupid OSes export hard-coded selector values
71 * in their ABI. These hard-coded values are always near the start of the GDT, 75 * in their ABI. These hard-coded values are always near the start of the GDT,
72 * so Xen places itself out of the way, at the far end of the GDT. 76 * so Xen places itself out of the way, at the far end of the GDT.
73 */ 77 */
74#define FIRST_RESERVED_GDT_PAGE 14 78#define FIRST_RESERVED_GDT_PAGE 14
75#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096) 79#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
76#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8) 80#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
77 81
78/* Maximum number of virtual CPUs in legacy multi-processor guests. */ 82/* Maximum number of virtual CPUs in legacy multi-processor guests. */
79#define XEN_LEGACY_MAX_VCPUS 32 83#define XEN_LEGACY_MAX_VCPUS 32
80 84
81#ifndef __ASSEMBLY__ 85#ifndef __ASSEMBLY__
82 86
83typedef unsigned long xen_ulong_t; 87typedef unsigned long xen_ulong_t;
84 88
85/* 89/*
86 * Send an array of these to HYPERVISOR_set_trap_table(). 90 * Send an array of these to HYPERVISOR_set_trap_table().
87 * The privilege level specifies which modes may enter a trap via a software 91 * The privilege level specifies which modes may enter a trap via a software
88 * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate 92 * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
89 * privilege levels as follows: 93 * privilege levels as follows:
90 * Level == 0: Noone may enter 94 * Level == 0: Noone may enter
91 * Level == 1: Kernel may enter 95 * Level == 1: Kernel may enter
92 * Level == 2: Kernel may enter 96 * Level == 2: Kernel may enter
93 * Level == 3: Everyone may enter 97 * Level == 3: Everyone may enter
94 */ 98 */
95#define TI_GET_DPL(_ti) ((_ti)->flags & 3) 99#define TI_GET_DPL(_ti) ((_ti)->flags & 3)
96#define TI_GET_IF(_ti) ((_ti)->flags & 4) 100#define TI_GET_IF(_ti) ((_ti)->flags & 4)
97#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl)) 101#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
98#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2)) 102#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
99struct trap_info { 103struct trap_info {
100 uint8_t vector; /* exception vector */ 104 uint8_t vector; /* exception vector */
101 uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */ 105 uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
102 uint16_t cs; /* code selector */ 106 uint16_t cs; /* code selector */
103 unsigned long address; /* code offset */ 107 unsigned long address; /* code offset */
104}; 108};
105typedef struct trap_info trap_info_t; 109typedef struct trap_info trap_info_t;
106DEFINE_XEN_GUEST_HANDLE(trap_info_t); 110DEFINE_XEN_GUEST_HANDLE(trap_info_t);
107 111
108typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ 112typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
109 113
110/* 114/*
111 * The following is all CPU context. Note that the fpu_ctxt block is filled  115 * The following is all CPU context. Note that the fpu_ctxt block is filled
112 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used. 116 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
113 */ 117 */
114struct vcpu_guest_context { 118struct vcpu_guest_context {
115 /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */ 119 /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
116 struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */ 120 struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
117#define VGCF_I387_VALID (1<<0) 121#define VGCF_I387_VALID (1<<0)
118#define VGCF_IN_KERNEL (1<<2) 122#define VGCF_IN_KERNEL (1<<2)
119#define _VGCF_i387_valid 0 123#define _VGCF_i387_valid 0
120#define VGCF_i387_valid (1<<_VGCF_i387_valid) 124#define VGCF_i387_valid (1<<_VGCF_i387_valid)
121#define _VGCF_in_kernel 2 125#define _VGCF_in_kernel 2
122#define VGCF_in_kernel (1<<_VGCF_in_kernel) 126#define VGCF_in_kernel (1<<_VGCF_in_kernel)
123#define _VGCF_failsafe_disables_events 3 127#define _VGCF_failsafe_disables_events 3
124#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events) 128#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
125#define _VGCF_syscall_disables_events 4 129#define _VGCF_syscall_disables_events 4
126#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events) 130#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
127#define _VGCF_online 5 131#define _VGCF_online 5
128#define VGCF_online (1<<_VGCF_online) 132#define VGCF_online (1<<_VGCF_online)
129 unsigned long flags; /* VGCF_* flags */ 133 unsigned long flags; /* VGCF_* flags */
130 struct cpu_user_regs user_regs; /* User-level CPU registers */ 134 struct cpu_user_regs user_regs; /* User-level CPU registers */
131 struct trap_info trap_ctxt[256]; /* Virtual IDT */ 135 struct trap_info trap_ctxt[256]; /* Virtual IDT */
132 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */ 136 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
133 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */ 137 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
134 unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */ 138 unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
135 /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ 139 /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
136 unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */ 140 unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
137 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */ 141 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
138#ifdef __i386__ 142#ifdef __i386__
139 unsigned long event_callback_cs; /* CS:EIP of event callback */ 143 unsigned long event_callback_cs; /* CS:EIP of event callback */
140 unsigned long event_callback_eip; 144 unsigned long event_callback_eip;
141 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ 145 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
142 unsigned long failsafe_callback_eip; 146 unsigned long failsafe_callback_eip;
143#else 147#else
144 unsigned long event_callback_eip; 148 unsigned long event_callback_eip;
145 unsigned long failsafe_callback_eip; 149 unsigned long failsafe_callback_eip;
146#ifdef __XEN__ 150#ifdef __XEN__
147 union { 151 union {
148 unsigned long syscall_callback_eip; 152 unsigned long syscall_callback_eip;
149 struct { 153 struct {
150 unsigned int event_callback_cs; /* compat CS of event cb */ 154 unsigned int event_callback_cs; /* compat CS of event cb */
151 unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */ 155 unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */
152 }; 156 };
153 }; 157 };
154#else 158#else
155 unsigned long syscall_callback_eip; 159 unsigned long syscall_callback_eip;
156#endif 160#endif
157#endif 161#endif
158 unsigned long vm_assist; /* VMASST_TYPE_* bitmap */ 162 unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
159#ifdef __x86_64__ 163#ifdef __x86_64__
160 /* Segment base addresses. */ 164 /* Segment base addresses. */
161 uint64_t fs_base; 165 uint64_t fs_base;
162 uint64_t gs_base_kernel; 166 uint64_t gs_base_kernel;
163 uint64_t gs_base_user; 167 uint64_t gs_base_user;
164#endif 168#endif
165}; 169};
166typedef struct vcpu_guest_context vcpu_guest_context_t; 170typedef struct vcpu_guest_context vcpu_guest_context_t;
167DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); 171DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
168 172
169struct arch_shared_info { 173struct arch_shared_info {
170 unsigned long max_pfn; /* max pfn that appears in table */ 174 unsigned long max_pfn; /* max pfn that appears in table */
171 /* Frame containing list of mfns containing list of mfns containing p2m. */ 175 /* Frame containing list of mfns containing list of mfns containing p2m. */
172 xen_pfn_t pfn_to_mfn_frame_list_list; 176 xen_pfn_t pfn_to_mfn_frame_list_list;
173 unsigned long nmi_reason; 177 unsigned long nmi_reason;
174 uint64_t pad[32]; 178 uint64_t pad[32];
175}; 179};
176typedef struct arch_shared_info arch_shared_info_t; 180typedef struct arch_shared_info arch_shared_info_t;
177 181
178#endif /* !__ASSEMBLY__ */ 182#endif /* !__ASSEMBLY__ */
179 183
180/* 184/*
181 * Prefix forces emulation of some non-trapping instructions. 185 * Prefix forces emulation of some non-trapping instructions.
182 * Currently only CPUID. 186 * Currently only CPUID.
183 */ 187 */
184#ifdef __ASSEMBLY__ 188#ifdef __ASSEMBLY__
185#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; 189#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
186#define XEN_CPUID XEN_EMULATE_PREFIX cpuid 190#define XEN_CPUID XEN_EMULATE_PREFIX cpuid
187#else 191#else
188#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " 192#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
189#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" 193#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
190#endif 194#endif
191 195
192#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */ 196#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
193 197
194/* 198/*
195 * Local variables: 199 * Local variables:
196 * mode: C 200 * mode: C
197 * c-set-style: "BSD" 201 * c-set-style: "BSD"
198 * c-basic-offset: 4 202 * c-basic-offset: 4
199 * tab-width: 4 203 * tab-width: 4
200 * indent-tabs-mode: nil 204 * indent-tabs-mode: nil
201 * End: 205 * End:
202 */ 206 */