ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h @ 6301:fd28bf8825a8

Fix x86/64 build by defining correct vcpu_pickle().
author kaf24@firebug.cl.cam.ac.uk
date Fri Aug 19 17:56:20 2005 +0000 (2005-08-19)
parents 47d49e8b8042
children 5e8123554d15
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * IN THE SOFTWARE.
28 */
29 /*
30 * Benjamin Liu <benjamin.liu@intel.com>
31 * Jun Nakajima <jun.nakajima@intel.com>
32 * Ported to x86-64.
33 *
34 */
36 #ifndef __HYPERCALL_H__
37 #define __HYPERCALL_H__
38 #include <asm-xen/xen-public/xen.h>
40 #define __syscall_clobber "r11","rcx","memory"
42 /*
43 * Assembler stubs for hyper-calls.
44 */
45 static inline int
46 HYPERVISOR_set_trap_table(
47 trap_info_t *table)
48 {
49 int ret;
51 __asm__ __volatile__ (
52 TRAP_INSTR
53 : "=a" (ret)
54 : "0" ((unsigned long)__HYPERVISOR_set_trap_table), "D" (table)
55 : __syscall_clobber );
57 return ret;
58 }
60 static inline int
61 HYPERVISOR_mmu_update(
62 mmu_update_t *req, int count, int *success_count, domid_t domid)
63 {
64 int ret;
66 __asm__ __volatile__ (
67 "movq %5, %%r10;" TRAP_INSTR
68 : "=a" (ret)
69 : "0" ((unsigned long)__HYPERVISOR_mmu_update), "D" (req), "S" ((long)count),
70 "d" (success_count), "g" ((unsigned long)domid)
71 : __syscall_clobber, "r10" );
73 return ret;
74 }
76 static inline int
77 HYPERVISOR_mmuext_op(
78 struct mmuext_op *op, int count, int *success_count, domid_t domid)
79 {
80 int ret;
82 __asm__ __volatile__ (
83 "movq %5, %%r10;" TRAP_INSTR
84 : "=a" (ret)
85 : "0" (__HYPERVISOR_mmuext_op), "D" (op), "S" ((long)count),
86 "d" (success_count), "g" ((unsigned long)domid)
87 : __syscall_clobber, "r10" );
89 return ret;
90 }
92 static inline int
93 HYPERVISOR_set_gdt(
94 unsigned long *frame_list, int entries)
95 {
96 int ret;
98 __asm__ __volatile__ (
99 TRAP_INSTR
100 : "=a" (ret)
101 : "0" ((unsigned long)__HYPERVISOR_set_gdt), "D" (frame_list), "S" ((long)entries)
102 : __syscall_clobber );
105 return ret;
106 }
107 static inline int
108 HYPERVISOR_stack_switch(
109 unsigned long ss, unsigned long esp)
110 {
111 int ret;
113 __asm__ __volatile__ (
114 TRAP_INSTR
115 : "=a" (ret)
116 : "0" ((unsigned long)__HYPERVISOR_stack_switch), "D" (ss), "S" (esp)
117 : __syscall_clobber );
119 return ret;
120 }
122 static inline int
123 HYPERVISOR_set_callbacks(
124 unsigned long event_address, unsigned long failsafe_address,
125 unsigned long syscall_address)
126 {
127 int ret;
129 __asm__ __volatile__ (
130 TRAP_INSTR
131 : "=a" (ret)
132 : "0" ((unsigned long)__HYPERVISOR_set_callbacks), "D" (event_address),
133 "S" (failsafe_address), "d" (syscall_address)
134 : __syscall_clobber );
136 return ret;
137 }
139 static inline int
140 HYPERVISOR_fpu_taskswitch(
141 int set)
142 {
143 int ret;
144 __asm__ __volatile__ (
145 TRAP_INSTR
146 : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_fpu_taskswitch),
147 "D" ((unsigned long) set) : __syscall_clobber );
149 return ret;
150 }
152 static inline int
153 HYPERVISOR_yield(
154 void)
155 {
156 int ret;
158 __asm__ __volatile__ (
159 TRAP_INSTR
160 : "=a" (ret)
161 : "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_yield)
162 : __syscall_clobber );
164 return ret;
165 }
167 static inline int
168 HYPERVISOR_block(
169 void)
170 {
171 int ret;
172 __asm__ __volatile__ (
173 TRAP_INSTR
174 : "=a" (ret)
175 : "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_block)
176 : __syscall_clobber );
178 return ret;
179 }
181 static inline int
182 HYPERVISOR_shutdown(
183 void)
184 {
185 int ret;
186 __asm__ __volatile__ (
187 TRAP_INSTR
188 : "=a" (ret)
189 : "0" ((unsigned long)__HYPERVISOR_sched_op),
190 "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift)))
191 : __syscall_clobber );
193 return ret;
194 }
196 static inline int
197 HYPERVISOR_reboot(
198 void)
199 {
200 int ret;
202 __asm__ __volatile__ (
203 TRAP_INSTR
204 : "=a" (ret)
205 : "0" ((unsigned long)__HYPERVISOR_sched_op),
206 "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift)))
207 : __syscall_clobber );
209 return ret;
210 }
212 static inline int
213 HYPERVISOR_suspend(
214 unsigned long srec)
215 {
216 int ret;
218 /* NB. On suspend, control software expects a suspend record in %esi. */
219 __asm__ __volatile__ (
220 TRAP_INSTR
221 : "=a" (ret)
222 : "0" ((unsigned long)__HYPERVISOR_sched_op),
223 "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift))),
224 "S" (srec)
225 : __syscall_clobber );
227 return ret;
228 }
230 /*
231 * We can have the timeout value in a single argument for the hypercall, but
232 * that will break the common code.
233 */
234 static inline long
235 HYPERVISOR_set_timer_op(
236 u64 timeout)
237 {
238 int ret;
240 __asm__ __volatile__ (
241 TRAP_INSTR
242 : "=a" (ret)
243 : "0" ((unsigned long)__HYPERVISOR_set_timer_op),
244 "D" (timeout)
245 : __syscall_clobber );
247 return ret;
248 }
250 static inline int
251 HYPERVISOR_dom0_op(
252 dom0_op_t *dom0_op)
253 {
254 int ret;
256 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
257 __asm__ __volatile__ (
258 TRAP_INSTR
259 : "=a" (ret)
260 : "0" ((unsigned long)__HYPERVISOR_dom0_op), "D" (dom0_op)
261 : __syscall_clobber );
263 return ret;
264 }
266 static inline int
267 HYPERVISOR_set_debugreg(
268 int reg, unsigned long value)
269 {
270 int ret;
272 __asm__ __volatile__ (
273 TRAP_INSTR
274 : "=a" (ret)
275 : "0" ((unsigned long)__HYPERVISOR_set_debugreg), "D" ((unsigned long)reg), "S" (value)
276 : __syscall_clobber );
278 return ret;
279 }
281 static inline unsigned long
282 HYPERVISOR_get_debugreg(
283 int reg)
284 {
285 unsigned long ret;
287 __asm__ __volatile__ (
288 TRAP_INSTR
289 : "=a" (ret)
290 : "0" ((unsigned long)__HYPERVISOR_get_debugreg), "D" ((unsigned long)reg)
291 : __syscall_clobber );
293 return ret;
294 }
296 static inline int
297 HYPERVISOR_update_descriptor(
298 unsigned long ma, unsigned long word)
299 {
300 int ret;
302 __asm__ __volatile__ (
303 TRAP_INSTR
304 : "=a" (ret)
305 : "0" ((unsigned long)__HYPERVISOR_update_descriptor), "D" (ma),
306 "S" (word)
307 : __syscall_clobber );
309 return ret;
310 }
312 static inline int
313 HYPERVISOR_dom_mem_op(
314 unsigned int op, unsigned long *extent_list,
315 unsigned long nr_extents, unsigned int extent_order)
316 {
317 int ret;
319 __asm__ __volatile__ (
320 "movq %5,%%r10; movq %6,%%r8;" TRAP_INSTR
321 : "=a" (ret)
322 : "0" ((unsigned long)__HYPERVISOR_dom_mem_op), "D" ((unsigned long)op), "S" (extent_list),
323 "d" (nr_extents), "g" ((unsigned long) extent_order), "g" ((unsigned long) DOMID_SELF)
324 : __syscall_clobber,"r8","r10");
326 return ret;
327 }
329 static inline int
330 HYPERVISOR_multicall(
331 void *call_list, int nr_calls)
332 {
333 int ret;
335 __asm__ __volatile__ (
336 TRAP_INSTR
337 : "=a" (ret)
338 : "0" ((unsigned long)__HYPERVISOR_multicall), "D" (call_list), "S" ((unsigned long)nr_calls)
339 : __syscall_clobber);
341 return ret;
342 }
344 static inline int
345 HYPERVISOR_update_va_mapping(
346 unsigned long page_nr, pte_t new_val, unsigned long flags)
347 {
348 int ret;
350 __asm__ __volatile__ (
351 TRAP_INSTR
352 : "=a" (ret)
353 : "0" ((unsigned long)__HYPERVISOR_update_va_mapping),
354 "D" (page_nr), "S" (new_val.pte), "d" (flags)
355 : __syscall_clobber);
357 return ret;
358 }
360 static inline int
361 HYPERVISOR_event_channel_op(
362 void *op)
363 {
364 int ret;
365 __asm__ __volatile__ (
366 TRAP_INSTR
367 : "=a" (ret)
368 : "0" ((unsigned long)__HYPERVISOR_event_channel_op), "D" (op)
369 : __syscall_clobber);
371 return ret;
372 }
374 static inline int
375 HYPERVISOR_xen_version(
376 int cmd)
377 {
378 int ret;
380 __asm__ __volatile__ (
381 TRAP_INSTR
382 : "=a" (ret)
383 : "0" ((unsigned long)__HYPERVISOR_xen_version), "D" ((unsigned long)cmd)
384 : __syscall_clobber);
386 return ret;
387 }
389 static inline int
390 HYPERVISOR_console_io(
391 int cmd, int count, char *str)
392 {
393 int ret;
394 __asm__ __volatile__ (
395 TRAP_INSTR
396 : "=a" (ret)
397 : "0" ((unsigned long)__HYPERVISOR_console_io), "D" ((unsigned long)cmd), "S" ((unsigned long)count), "d" (str)
398 : __syscall_clobber);
400 return ret;
401 }
403 static inline int
404 HYPERVISOR_physdev_op(
405 void *physdev_op)
406 {
407 int ret;
409 __asm__ __volatile__ (
410 TRAP_INSTR
411 : "=a" (ret)
412 : "0" ((unsigned long)__HYPERVISOR_physdev_op), "D" (physdev_op)
413 : __syscall_clobber);
415 return ret;
416 }
418 static inline int
419 HYPERVISOR_grant_table_op(
420 unsigned int cmd, void *uop, unsigned int count)
421 {
422 int ret;
424 __asm__ __volatile__ (
425 TRAP_INSTR
426 : "=a" (ret)
427 : "0" ((unsigned long)__HYPERVISOR_grant_table_op), "D" ((unsigned long)cmd), "S" ((unsigned long)uop), "d" (count)
428 : __syscall_clobber);
430 return ret;
431 }
433 static inline int
434 HYPERVISOR_update_va_mapping_otherdomain(
435 unsigned long page_nr, pte_t new_val, unsigned long flags, domid_t domid)
436 {
437 int ret;
439 __asm__ __volatile__ (
440 "movq %5, %%r10;" TRAP_INSTR
441 : "=a" (ret)
442 : "0" ((unsigned long)__HYPERVISOR_update_va_mapping_otherdomain),
443 "D" (page_nr), "S" (new_val.pte), "d" (flags), "g" ((unsigned long)domid)
444 : __syscall_clobber,"r10");
446 return ret;
447 }
449 static inline int
450 HYPERVISOR_vm_assist(
451 unsigned int cmd, unsigned int type)
452 {
453 int ret;
455 __asm__ __volatile__ (
456 TRAP_INSTR
457 : "=a" (ret)
458 : "0" ((unsigned long)__HYPERVISOR_vm_assist), "D" ((unsigned long)cmd), "S" ((unsigned long)type)
459 : __syscall_clobber);
461 return ret;
462 }
464 static inline int
465 HYPERVISOR_switch_to_user(void)
466 {
467 int ret;
468 __asm__ __volatile__ (
469 TRAP_INSTR
470 : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_switch_to_user) : __syscall_clobber );
472 return ret;
473 }
475 static inline int
476 HYPERVISOR_boot_vcpu(
477 unsigned long vcpu, vcpu_guest_context_t *ctxt)
478 {
479 int ret;
481 __asm__ __volatile__ (
482 TRAP_INSTR
483 : "=a" (ret)
484 : "0" (__HYPERVISOR_boot_vcpu), "D" (vcpu), "S" (ctxt)
485 : __syscall_clobber);
487 return ret;
488 }
490 static inline int
491 HYPERVISOR_set_segment_base(
492 int reg, unsigned long value)
493 {
494 int ret;
496 __asm__ __volatile__ (
497 TRAP_INSTR
498 : "=a" (ret)
499 : "0" ((unsigned long)__HYPERVISOR_set_segment_base), "D" ((unsigned long)reg), "S" (value)
500 : __syscall_clobber );
502 return ret;
503 }
505 static inline int
506 HYPERVISOR_vcpu_pickle(
507 int vcpu, vcpu_guest_context_t *ctxt)
508 {
509 int ret;
511 __asm__ __volatile__ (
512 TRAP_INSTR
513 : "=a" (ret)
514 : "0" ((unsigned long)__HYPERVISOR_sched_op),
515 "D" ((unsigned long)SCHEDOP_vcpu_pickle | (vcpu << SCHEDOP_vcpushift)),
516 "S" ((unsigned long)ctxt)
517 : __syscall_clobber );
519 return ret;
520 }
522 #endif /* __HYPERCALL_H__ */