1 /******************************************************************************
4 * Linux-specific hypervisor handling.
6 * Copyright (c) 2002-2004, K A Fraser
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
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:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
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
30 * Benjamin Liu <benjamin.liu@intel.com>
31 * Jun Nakajima <jun.nakajima@intel.com>
36 #ifndef __HYPERCALL_H__
37 #define __HYPERCALL_H__
38 #include <asm-xen/xen-public/xen.h>
40 #define __syscall_clobber "r11","rcx","memory"
43 * Assembler stubs for hyper-calls.
46 HYPERVISOR_set_trap_table(
51 __asm__ __volatile__ (
54 : "0" ((unsigned long)__HYPERVISOR_set_trap_table), "D" (table)
55 : __syscall_clobber );
61 HYPERVISOR_mmu_update(
62 mmu_update_t *req, int count, int *success_count, domid_t domid)
66 __asm__ __volatile__ (
67 "movq %5, %%r10;" TRAP_INSTR
69 : "0" ((unsigned long)__HYPERVISOR_mmu_update), "D" (req), "S" ((long)count),
70 "d" (success_count), "g" ((unsigned long)domid)
71 : __syscall_clobber, "r10" );
78 struct mmuext_op *op, int count, int *success_count, domid_t domid)
82 __asm__ __volatile__ (
83 "movq %5, %%r10;" TRAP_INSTR
85 : "0" (__HYPERVISOR_mmuext_op), "D" (op), "S" ((long)count),
86 "d" (success_count), "g" ((unsigned long)domid)
87 : __syscall_clobber, "r10" );
94 unsigned long *frame_list, int entries)
98 __asm__ __volatile__ (
101 : "0" ((unsigned long)__HYPERVISOR_set_gdt), "D" (frame_list), "S" ((long)entries)
102 : __syscall_clobber );
108 HYPERVISOR_stack_switch(
109 unsigned long ss, unsigned long esp)
113 __asm__ __volatile__ (
116 : "0" ((unsigned long)__HYPERVISOR_stack_switch), "D" (ss), "S" (esp)
117 : __syscall_clobber );
123 HYPERVISOR_set_callbacks(
124 unsigned long event_address, unsigned long failsafe_address,
125 unsigned long syscall_address)
129 __asm__ __volatile__ (
132 : "0" ((unsigned long)__HYPERVISOR_set_callbacks), "D" (event_address),
133 "S" (failsafe_address), "d" (syscall_address)
134 : __syscall_clobber );
140 HYPERVISOR_fpu_taskswitch(
144 __asm__ __volatile__ (
146 : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_fpu_taskswitch),
147 "D" ((unsigned long) set) : __syscall_clobber );
158 __asm__ __volatile__ (
161 : "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_yield)
162 : __syscall_clobber );
172 __asm__ __volatile__ (
175 : "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_block)
176 : __syscall_clobber );
186 __asm__ __volatile__ (
189 : "0" ((unsigned long)__HYPERVISOR_sched_op),
190 "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift)))
191 : __syscall_clobber );
202 __asm__ __volatile__ (
205 : "0" ((unsigned long)__HYPERVISOR_sched_op),
206 "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift)))
207 : __syscall_clobber );
218 /* NB. On suspend, control software expects a suspend record in %esi. */
219 __asm__ __volatile__ (
222 : "0" ((unsigned long)__HYPERVISOR_sched_op),
223 "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift))),
225 : __syscall_clobber );
231 * We can have the timeout value in a single argument for the hypercall, but
232 * that will break the common code.
235 HYPERVISOR_set_timer_op(
240 __asm__ __volatile__ (
243 : "0" ((unsigned long)__HYPERVISOR_set_timer_op),
245 : __syscall_clobber );
256 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
257 __asm__ __volatile__ (
260 : "0" ((unsigned long)__HYPERVISOR_dom0_op), "D" (dom0_op)
261 : __syscall_clobber );
267 HYPERVISOR_set_debugreg(
268 int reg, unsigned long value)
272 __asm__ __volatile__ (
275 : "0" ((unsigned long)__HYPERVISOR_set_debugreg), "D" ((unsigned long)reg), "S" (value)
276 : __syscall_clobber );
281 static inline unsigned long
282 HYPERVISOR_get_debugreg(
287 __asm__ __volatile__ (
290 : "0" ((unsigned long)__HYPERVISOR_get_debugreg), "D" ((unsigned long)reg)
291 : __syscall_clobber );
297 HYPERVISOR_update_descriptor(
298 unsigned long ma, unsigned long word)
302 __asm__ __volatile__ (
305 : "0" ((unsigned long)__HYPERVISOR_update_descriptor), "D" (ma),
307 : __syscall_clobber );
313 HYPERVISOR_set_fast_trap(
318 __asm__ __volatile__ (
321 : "0" ((unsigned long)__HYPERVISOR_set_fast_trap), "D" ((unsigned long)idx)
322 : __syscall_clobber );
328 HYPERVISOR_dom_mem_op(
329 unsigned int op, unsigned long *extent_list,
330 unsigned long nr_extents, unsigned int extent_order)
334 __asm__ __volatile__ (
335 "movq %5,%%r10; movq %6,%%r8;" TRAP_INSTR
337 : "0" ((unsigned long)__HYPERVISOR_dom_mem_op), "D" ((unsigned long)op), "S" (extent_list),
338 "d" (nr_extents), "g" ((unsigned long) extent_order), "g" ((unsigned long) DOMID_SELF)
339 : __syscall_clobber,"r8","r10");
345 HYPERVISOR_multicall(
346 void *call_list, int nr_calls)
350 __asm__ __volatile__ (
353 : "0" ((unsigned long)__HYPERVISOR_multicall), "D" (call_list), "S" ((unsigned long)nr_calls)
354 : __syscall_clobber);
360 HYPERVISOR_update_va_mapping(
361 unsigned long page_nr, pte_t new_val, unsigned long flags)
365 __asm__ __volatile__ (
368 : "0" ((unsigned long)__HYPERVISOR_update_va_mapping),
369 "D" (page_nr), "S" (new_val.pte), "d" (flags)
370 : __syscall_clobber);
376 HYPERVISOR_event_channel_op(
380 __asm__ __volatile__ (
383 : "0" ((unsigned long)__HYPERVISOR_event_channel_op), "D" (op)
384 : __syscall_clobber);
390 HYPERVISOR_xen_version(
395 __asm__ __volatile__ (
398 : "0" ((unsigned long)__HYPERVISOR_xen_version), "D" ((unsigned long)cmd)
399 : __syscall_clobber);
405 HYPERVISOR_console_io(
406 int cmd, int count, char *str)
409 __asm__ __volatile__ (
412 : "0" ((unsigned long)__HYPERVISOR_console_io), "D" ((unsigned long)cmd), "S" ((unsigned long)count), "d" (str)
413 : __syscall_clobber);
419 HYPERVISOR_physdev_op(
424 __asm__ __volatile__ (
427 : "0" ((unsigned long)__HYPERVISOR_physdev_op), "D" (physdev_op)
428 : __syscall_clobber);
434 HYPERVISOR_grant_table_op(
435 unsigned int cmd, void *uop, unsigned int count)
439 __asm__ __volatile__ (
442 : "0" ((unsigned long)__HYPERVISOR_grant_table_op), "D" ((unsigned long)cmd), "S" ((unsigned long)uop), "d" (count)
443 : __syscall_clobber);
449 HYPERVISOR_update_va_mapping_otherdomain(
450 unsigned long page_nr, pte_t new_val, unsigned long flags, domid_t domid)
454 __asm__ __volatile__ (
455 "movq %5, %%r10;" TRAP_INSTR
457 : "0" ((unsigned long)__HYPERVISOR_update_va_mapping_otherdomain),
458 "D" (page_nr), "S" (new_val.pte), "d" (flags), "g" ((unsigned long)domid)
459 : __syscall_clobber,"r10");
465 HYPERVISOR_vm_assist(
466 unsigned int cmd, unsigned int type)
470 __asm__ __volatile__ (
473 : "0" ((unsigned long)__HYPERVISOR_vm_assist), "D" ((unsigned long)cmd), "S" ((unsigned long)type)
474 : __syscall_clobber);
480 HYPERVISOR_switch_to_user(void)
483 __asm__ __volatile__ (
485 : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_switch_to_user) : __syscall_clobber );
491 HYPERVISOR_boot_vcpu(
492 unsigned long vcpu, full_execution_context_t *ctxt)
496 __asm__ __volatile__ (
499 : "0" (__HYPERVISOR_boot_vcpu), "D" (vcpu), "S" (ctxt)
500 : __syscall_clobber);
506 HYPERVISOR_set_segment_base(
507 int reg, unsigned long value)
511 __asm__ __volatile__ (
514 : "0" ((unsigned long)__HYPERVISOR_set_segment_base), "D" ((unsigned long)reg), "S" (value)
515 : __syscall_clobber );
520 #endif /* __HYPERCALL_H__ */