xen-vtx-unstable

annotate linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h @ 6568:dd668f7527cb

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Sep 01 10:16:14 2005 +0000 (2005-09-01)
parents 38312fe7ec38 f0dc15fd3c1b
children 939fd35d58da f752e0c873a6 4d899a738d59 e7c7196fa329
rev   line source
cl349@4445 1 /******************************************************************************
cl349@4445 2 * hypercall.h
cl349@4445 3 *
cl349@4445 4 * Linux-specific hypervisor handling.
cl349@4445 5 *
cl349@4445 6 * Copyright (c) 2002-2004, K A Fraser
cl349@4445 7 *
kaf24@6452 8 * 64-bit updates:
kaf24@6452 9 * Benjamin Liu <benjamin.liu@intel.com>
kaf24@6452 10 * Jun Nakajima <jun.nakajima@intel.com>
kaf24@6452 11 *
cl349@4445 12 * This file may be distributed separately from the Linux kernel, or
cl349@4445 13 * incorporated into other software packages, subject to the following license:
cl349@4445 14 *
cl349@4445 15 * Permission is hereby granted, free of charge, to any person obtaining a copy
cl349@4445 16 * of this source file (the "Software"), to deal in the Software without
cl349@4445 17 * restriction, including without limitation the rights to use, copy, modify,
cl349@4445 18 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
cl349@4445 19 * and to permit persons to whom the Software is furnished to do so, subject to
cl349@4445 20 * the following conditions:
cl349@4445 21 *
cl349@4445 22 * The above copyright notice and this permission notice shall be included in
cl349@4445 23 * all copies or substantial portions of the Software.
cl349@4445 24 *
cl349@4445 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
cl349@4445 26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
cl349@4445 27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
cl349@4445 28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
cl349@4445 29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
cl349@4445 30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
cl349@4445 31 * IN THE SOFTWARE.
cl349@4445 32 */
cl349@4445 33
cl349@4445 34 #ifndef __HYPERCALL_H__
cl349@4445 35 #define __HYPERCALL_H__
kaf24@6452 36
cl349@4445 37 #include <asm-xen/xen-public/xen.h>
cl349@4445 38
cl349@4445 39 #define __syscall_clobber "r11","rcx","memory"
cl349@4445 40
kaf24@6452 41 #define _hypercall0(type, name) \
kaf24@6452 42 ({ \
kaf24@6452 43 long __res; \
kaf24@6452 44 asm volatile ( \
kaf24@6452 45 TRAP_INSTR \
kaf24@6452 46 : "=a" (__res) \
kaf24@6452 47 : "0" (__HYPERVISOR_##name) \
kaf24@6452 48 : __syscall_clobber ); \
kaf24@6452 49 (type)__res; \
kaf24@6452 50 })
kaf24@6452 51
kaf24@6452 52 #define _hypercall1(type, name, a1) \
kaf24@6452 53 ({ \
kaf24@6452 54 long __res, __ign1; \
kaf24@6452 55 asm volatile ( \
kaf24@6452 56 TRAP_INSTR \
kaf24@6452 57 : "=a" (__res), "=D" (__ign1) \
kaf24@6452 58 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)) \
kaf24@6452 59 : __syscall_clobber ); \
kaf24@6452 60 (type)__res; \
kaf24@6452 61 })
kaf24@6452 62
kaf24@6452 63 #define _hypercall2(type, name, a1, a2) \
kaf24@6452 64 ({ \
kaf24@6452 65 long __res, __ign1, __ign2; \
kaf24@6452 66 asm volatile ( \
kaf24@6452 67 TRAP_INSTR \
kaf24@6452 68 : "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
kaf24@6452 69 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
kaf24@6452 70 "2" ((long)(a2)) \
kaf24@6452 71 : __syscall_clobber ); \
kaf24@6452 72 (type)__res; \
kaf24@6452 73 })
kaf24@6452 74
kaf24@6452 75 #define _hypercall3(type, name, a1, a2, a3) \
kaf24@6452 76 ({ \
kaf24@6452 77 long __res, __ign1, __ign2, __ign3; \
kaf24@6452 78 asm volatile ( \
kaf24@6452 79 TRAP_INSTR \
kaf24@6452 80 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
kaf24@6452 81 "=d" (__ign3) \
kaf24@6452 82 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
kaf24@6452 83 "2" ((long)(a2)), "3" ((long)(a3)) \
kaf24@6452 84 : __syscall_clobber ); \
kaf24@6452 85 (type)__res; \
kaf24@6452 86 })
kaf24@6452 87
kaf24@6452 88 #define _hypercall4(type, name, a1, a2, a3, a4) \
kaf24@6452 89 ({ \
kaf24@6452 90 long __res, __ign1, __ign2, __ign3; \
kaf24@6452 91 asm volatile ( \
kaf24@6452 92 "movq %8,%%r10; " TRAP_INSTR \
kaf24@6452 93 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
kaf24@6452 94 "=d" (__ign3) \
kaf24@6452 95 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
kaf24@6452 96 "2" ((long)(a2)), "3" ((long)(a3)), \
kaf24@6452 97 "g" ((long)(a4)) \
kaf24@6452 98 : __syscall_clobber, "r10" ); \
kaf24@6452 99 (type)__res; \
kaf24@6452 100 })
kaf24@6452 101
kaf24@6452 102 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
kaf24@6452 103 ({ \
kaf24@6452 104 long __res, __ign1, __ign2, __ign3; \
kaf24@6452 105 asm volatile ( \
kaf24@6452 106 "movq %8,%%r10; movq %9,%%r8; " TRAP_INSTR \
kaf24@6452 107 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
kaf24@6452 108 "=d" (__ign3) \
kaf24@6452 109 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
kaf24@6452 110 "2" ((long)(a2)), "3" ((long)(a3)), \
kaf24@6452 111 "g" ((long)(a4)), "g" ((long)(a5)) \
kaf24@6452 112 : __syscall_clobber, "r10", "r8" ); \
kaf24@6452 113 (type)__res; \
kaf24@6452 114 })
kaf24@6452 115
cl349@4445 116 static inline int
cl349@4445 117 HYPERVISOR_set_trap_table(
kaf24@6452 118 trap_info_t *table)
cl349@4445 119 {
kaf24@6452 120 return _hypercall1(int, set_trap_table, table);
cl349@4445 121 }
cl349@4445 122
cl349@4445 123 static inline int
cl349@4445 124 HYPERVISOR_mmu_update(
kaf24@6452 125 mmu_update_t *req, int count, int *success_count, domid_t domid)
cl349@4445 126 {
kaf24@6452 127 return _hypercall4(int, mmu_update, req, count, success_count, domid);
cl349@4492 128 }
cl349@4492 129
cl349@4492 130 static inline int
cl349@4492 131 HYPERVISOR_mmuext_op(
kaf24@6452 132 struct mmuext_op *op, int count, int *success_count, domid_t domid)
cl349@4492 133 {
kaf24@6452 134 return _hypercall4(int, mmuext_op, op, count, success_count, domid);
cl349@4445 135 }
cl349@4445 136
cl349@4445 137 static inline int
cl349@4445 138 HYPERVISOR_set_gdt(
kaf24@6452 139 unsigned long *frame_list, int entries)
cl349@4445 140 {
kaf24@6452 141 return _hypercall2(int, set_gdt, frame_list, entries);
kaf24@6452 142 }
cl349@4445 143
cl349@4445 144 static inline int
cl349@4445 145 HYPERVISOR_stack_switch(
kaf24@6452 146 unsigned long ss, unsigned long esp)
cl349@4445 147 {
kaf24@6452 148 return _hypercall2(int, stack_switch, ss, esp);
cl349@4445 149 }
cl349@4445 150
cl349@4445 151 static inline int
cl349@4445 152 HYPERVISOR_set_callbacks(
kaf24@6452 153 unsigned long event_address, unsigned long failsafe_address,
kaf24@6452 154 unsigned long syscall_address)
cl349@4445 155 {
kaf24@6452 156 return _hypercall3(int, set_callbacks,
kaf24@6452 157 event_address, failsafe_address, syscall_address);
cl349@4445 158 }
cl349@4445 159
cl349@4445 160 static inline int
cl349@4445 161 HYPERVISOR_fpu_taskswitch(
kaf24@6452 162 int set)
cl349@4445 163 {
kaf24@6452 164 return _hypercall1(int, fpu_taskswitch, set);
cl349@4445 165 }
cl349@4445 166
cl349@4445 167 static inline int
cl349@4445 168 HYPERVISOR_yield(
kaf24@6452 169 void)
cl349@4445 170 {
kaf24@6452 171 return _hypercall2(int, sched_op, SCHEDOP_yield, 0);
cl349@4445 172 }
cl349@4445 173
cl349@4445 174 static inline int
cl349@4445 175 HYPERVISOR_block(
kaf24@6452 176 void)
cl349@4445 177 {
kaf24@6452 178 return _hypercall2(int, sched_op, SCHEDOP_block, 0);
cl349@4445 179 }
cl349@4445 180
cl349@4445 181 static inline int
cl349@4445 182 HYPERVISOR_shutdown(
kaf24@6452 183 void)
cl349@4445 184 {
kaf24@6452 185 return _hypercall2(int, sched_op, SCHEDOP_shutdown |
kaf24@6452 186 (SHUTDOWN_poweroff << SCHEDOP_reasonshift), 0);
cl349@4445 187 }
cl349@4445 188
cl349@4445 189 static inline int
cl349@4445 190 HYPERVISOR_reboot(
kaf24@6452 191 void)
cl349@4445 192 {
kaf24@6452 193 return _hypercall2(int, sched_op, SCHEDOP_shutdown |
kaf24@6452 194 (SHUTDOWN_reboot << SCHEDOP_reasonshift), 0);
cl349@4445 195 }
cl349@4445 196
cl349@4445 197 static inline long
cl349@4445 198 HYPERVISOR_set_timer_op(
kaf24@6452 199 u64 timeout)
cl349@4445 200 {
kaf24@6452 201 return _hypercall1(long, set_timer_op, timeout);
cl349@4445 202 }
cl349@4445 203
cl349@4445 204 static inline int
cl349@4445 205 HYPERVISOR_dom0_op(
kaf24@6452 206 dom0_op_t *dom0_op)
cl349@4445 207 {
kaf24@6452 208 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
kaf24@6452 209 return _hypercall1(int, dom0_op, dom0_op);
cl349@4445 210 }
cl349@4445 211
cl349@4445 212 static inline int
cl349@4445 213 HYPERVISOR_set_debugreg(
kaf24@6452 214 int reg, unsigned long value)
cl349@4445 215 {
kaf24@6452 216 return _hypercall2(int, set_debugreg, reg, value);
cl349@4445 217 }
cl349@4445 218
cl349@4445 219 static inline unsigned long
cl349@4445 220 HYPERVISOR_get_debugreg(
kaf24@6452 221 int reg)
cl349@4445 222 {
kaf24@6452 223 return _hypercall1(unsigned long, get_debugreg, reg);
cl349@4445 224 }
cl349@4445 225
cl349@4445 226 static inline int
cl349@4445 227 HYPERVISOR_update_descriptor(
kaf24@6452 228 unsigned long ma, unsigned long word)
cl349@4445 229 {
kaf24@6452 230 return _hypercall2(int, update_descriptor, ma, word);
cl349@4445 231 }
cl349@4445 232
cl349@4445 233 static inline int
kaf24@6468 234 HYPERVISOR_memory_op(
kaf24@6468 235 unsigned int cmd, void *arg)
cl349@4445 236 {
kaf24@6468 237 return _hypercall2(int, memory_op, cmd, arg);
cl349@4445 238 }
cl349@4445 239
cl349@4445 240 static inline int
cl349@4445 241 HYPERVISOR_multicall(
kaf24@6452 242 void *call_list, int nr_calls)
cl349@4445 243 {
kaf24@6452 244 return _hypercall2(int, multicall, call_list, nr_calls);
cl349@4445 245 }
cl349@4445 246
cl349@4445 247 static inline int
cl349@4445 248 HYPERVISOR_update_va_mapping(
kaf24@6452 249 unsigned long va, pte_t new_val, unsigned long flags)
cl349@4445 250 {
kaf24@6452 251 return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
cl349@4445 252 }
cl349@4445 253
cl349@4445 254 static inline int
cl349@4445 255 HYPERVISOR_event_channel_op(
kaf24@6452 256 void *op)
cl349@4445 257 {
kaf24@6452 258 return _hypercall1(int, event_channel_op, op);
cl349@4445 259 }
cl349@4445 260
cl349@4445 261 static inline int
cl349@4445 262 HYPERVISOR_xen_version(
kaf24@6452 263 int cmd)
cl349@4445 264 {
kaf24@6452 265 return _hypercall1(int, xen_version, cmd);
cl349@4445 266 }
cl349@4445 267
cl349@4445 268 static inline int
cl349@4445 269 HYPERVISOR_console_io(
kaf24@6452 270 int cmd, int count, char *str)
cl349@4445 271 {
kaf24@6452 272 return _hypercall3(int, console_io, cmd, count, str);
cl349@4445 273 }
cl349@4445 274
cl349@4445 275 static inline int
cl349@4445 276 HYPERVISOR_physdev_op(
kaf24@6452 277 void *physdev_op)
cl349@4445 278 {
kaf24@6452 279 return _hypercall1(int, physdev_op, physdev_op);
cl349@4445 280 }
cl349@4445 281
cl349@4445 282 static inline int
cl349@4445 283 HYPERVISOR_grant_table_op(
kaf24@6452 284 unsigned int cmd, void *uop, unsigned int count)
cl349@4445 285 {
kaf24@6452 286 return _hypercall3(int, grant_table_op, cmd, uop, count);
cl349@4445 287 }
cl349@4445 288
cl349@4445 289 static inline int
cl349@4445 290 HYPERVISOR_update_va_mapping_otherdomain(
kaf24@6452 291 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
cl349@4445 292 {
kaf24@6452 293 return _hypercall4(int, update_va_mapping_otherdomain, va,
kaf24@6452 294 new_val.pte, flags, domid);
cl349@4445 295 }
cl349@4445 296
cl349@4445 297 static inline int
cl349@4445 298 HYPERVISOR_vm_assist(
kaf24@6452 299 unsigned int cmd, unsigned int type)
cl349@4445 300 {
kaf24@6452 301 return _hypercall2(int, vm_assist, cmd, type);
kaf24@6452 302 }
kaf24@6452 303
kaf24@6452 304 static inline int
kaf24@6452 305 HYPERVISOR_boot_vcpu(
kaf24@6452 306 unsigned long vcpu, vcpu_guest_context_t *ctxt)
kaf24@6452 307 {
kaf24@6452 308 return _hypercall2(int, boot_vcpu, vcpu, ctxt);
kaf24@6452 309 }
cl349@4445 310
kaf24@6452 311 static inline int
kaf24@6452 312 HYPERVISOR_vcpu_up(
kaf24@6452 313 int vcpu)
kaf24@6452 314 {
kaf24@6452 315 return _hypercall2(int, sched_op, SCHEDOP_vcpu_up |
kaf24@6452 316 (vcpu << SCHEDOP_vcpushift), 0);
kaf24@6452 317 }
cl349@4445 318
kaf24@6452 319 static inline int
kaf24@6452 320 HYPERVISOR_vcpu_pickle(
kaf24@6452 321 int vcpu, vcpu_guest_context_t *ctxt)
kaf24@6452 322 {
kaf24@6452 323 return _hypercall2(int, sched_op, SCHEDOP_vcpu_pickle |
kaf24@6452 324 (vcpu << SCHEDOP_vcpushift), ctxt);
cl349@4445 325 }
cl349@4445 326
cl349@4445 327 static inline int
cl349@4445 328 HYPERVISOR_switch_to_user(void)
cl349@4445 329 {
kaf24@6452 330 return _hypercall0(int, switch_to_user);
cl349@4445 331 }
cl349@4445 332
cl349@4445 333 static inline int
cl349@4445 334 HYPERVISOR_set_segment_base(
kaf24@6452 335 int reg, unsigned long value)
cl349@4445 336 {
kaf24@6452 337 return _hypercall2(int, set_segment_base, reg, value);
cl349@4445 338 }
cl349@4445 339
sos22@6277 340 static inline int
kaf24@6452 341 HYPERVISOR_suspend(
kaf24@6452 342 unsigned long srec)
sos22@6277 343 {
kaf24@6452 344 return _hypercall2(int, sched_op, SCHEDOP_shutdown |
kaf24@6452 345 (SHUTDOWN_suspend << SCHEDOP_reasonshift), srec);
sos22@6277 346 }
sos22@6277 347
cl349@4445 348 #endif /* __HYPERCALL_H__ */
kaf24@6452 349
kaf24@6452 350 /*
kaf24@6452 351 * Local variables:
kaf24@6452 352 * c-file-style: "linux"
kaf24@6452 353 * indent-tabs-mode: t
kaf24@6452 354 * c-indent-level: 8
kaf24@6452 355 * c-basic-offset: 8
kaf24@6452 356 * tab-width: 8
kaf24@6452 357 * End:
kaf24@6452 358 */