1 /* $NetBSD: hypercalls.h,v 1.4 2008/10/24 22:06:06 jym Exp $ */
2 /******************************************************************************
5 * Linux-specific hypervisor handling.
7 * Copyright (c) 2002-2004, K A Fraser
10 * Benjamin Liu <benjamin.liu@intel.com>
11 * Jun Nakajima <jun.nakajima@intel.com>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation; or, when distributed
16 * separately from the Linux kernel or incorporated into other
17 * software packages, subject to the following license:
19 * Permission is hereby granted, free of charge, to any person obtaining a copy
20 * of this source file (the "Software"), to deal in the Software without
21 * restriction, including without limitation the rights to use, copy, modify,
22 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
23 * and to permit persons to whom the Software is furnished to do so, subject to
24 * the following conditions:
26 * The above copyright notice and this permission notice shall be included in
27 * all copies or substantial portions of the Software.
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
38 #ifndef __HYPERCALL_H__
39 #define __HYPERCALL_H__
42 #define STR(x) __STR(x)
44 #define HYPERCALL_STR(name) \
45 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
47 #define _hypercall0(type, name) \
58 #define _hypercall1(type, name, a1) \
63 : "=a" (__res), "=D" (__ign1) \
69 #define _hypercall2(type, name, a1, a2) \
71 long __res, __ign1, __ign2; \
74 : "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
75 : "1" ((long)(a1)), "2" ((long)(a2)) \
80 #define _hypercall3(type, name, a1, a2, a3) \
82 long __res, __ign1, __ign2, __ign3; \
85 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
87 : "1" ((long)(a1)), "2" ((long)(a2)), \
93 #define _hypercall4(type, name, a1, a2, a3, a4) \
95 long __res, __ign1, __ign2, __ign3; \
99 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
101 : "1" ((long)(a1)), "2" ((long)(a2)), \
102 "3" ((long)(a3)), "g" ((long)(a4)) \
103 : "memory", "r10" ); \
107 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
109 long __res, __ign1, __ign2, __ign3; \
111 "movq %7,%%r10; movq %8,%%r8; " \
112 HYPERCALL_STR(name) \
113 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
115 : "1" ((long)(a1)), "2" ((long)(a2)), \
116 "3" ((long)(a3)), "g" ((long)(a4)), \
118 : "memory", "r10", "r8" ); \
123 HYPERVISOR_set_trap_table(
126 return _hypercall1(int, set_trap_table
, table
);
130 HYPERVISOR_mmu_update(
131 mmu_update_t
*req
, int count
, int *success_count
, domid_t domid
)
133 return _hypercall4(int, mmu_update
, req
, count
, success_count
, domid
);
137 HYPERVISOR_mmuext_op(
138 struct mmuext_op
*op
, int count
, int *success_count
, domid_t domid
)
140 return _hypercall4(int, mmuext_op
, op
, count
, success_count
, domid
);
145 unsigned long *frame_list
, int entries
)
147 return _hypercall2(int, set_gdt
, frame_list
, entries
);
151 HYPERVISOR_stack_switch(
152 unsigned long ss
, unsigned long esp
)
154 return _hypercall2(int, stack_switch
, ss
, esp
);
158 HYPERVISOR_set_callbacks(
159 unsigned long event_address
, unsigned long failsafe_address
,
160 unsigned long syscall_address
)
162 return _hypercall3(int, set_callbacks
,
163 event_address
, failsafe_address
, syscall_address
);
167 HYPERVISOR_fpu_taskswitch(
170 return _hypercall1(int, fpu_taskswitch
, set
);
174 HYPERVISOR_sched_op_compat(
175 int cmd
, unsigned long arg
)
177 return _hypercall2(int, sched_op_compat
, cmd
, arg
);
184 return _hypercall2(int, sched_op
, cmd
, arg
);
188 HYPERVISOR_set_timer_op(
191 return _hypercall1(long, set_timer_op
, timeout
);
195 HYPERVISOR_platform_op(
196 struct xen_platform_op
*platform_op
)
198 platform_op
->interface_version
= XENPF_INTERFACE_VERSION
;
199 return _hypercall1(int, platform_op
, platform_op
);
203 HYPERVISOR_set_debugreg(
204 int reg
, unsigned long value
)
206 return _hypercall2(int, set_debugreg
, reg
, value
);
209 static inline unsigned long
210 HYPERVISOR_get_debugreg(
213 return _hypercall1(unsigned long, get_debugreg
, reg
);
217 HYPERVISOR_update_descriptor(
218 unsigned long ma
, unsigned long word
)
220 return _hypercall2(int, update_descriptor
, ma
, word
);
224 HYPERVISOR_memory_op(
225 unsigned int cmd
, void *arg
)
227 return _hypercall2(int, memory_op
, cmd
, arg
);
231 HYPERVISOR_multicall(
232 multicall_entry_t
*call_list
, int nr_calls
)
234 return _hypercall2(int, multicall
, call_list
, nr_calls
);
238 HYPERVISOR_update_va_mapping(
239 unsigned long va
, unsigned long new_val
, unsigned long flags
)
241 return _hypercall3(int, update_va_mapping
, va
, new_val
, flags
);
245 HYPERVISOR_event_channel_op(void *op
)
247 return _hypercall1(int, event_channel_op
, op
);
254 return _hypercall2(int, acm_op
, cmd
, arg
);
258 HYPERVISOR_xen_version(
261 return _hypercall2(int, xen_version
, cmd
, arg
);
265 HYPERVISOR_console_io(
266 int cmd
, int count
, char *str
)
268 return _hypercall3(int, console_io
, cmd
, count
, str
);
272 HYPERVISOR_physdev_op(void *op
)
274 return _hypercall1(int, physdev_op_compat
, op
);
278 HYPERVISOR_grant_table_op(
279 unsigned int cmd
, void *uop
, unsigned int count
)
281 return _hypercall3(int, grant_table_op
, cmd
, uop
, count
);
285 HYPERVISOR_update_va_mapping_otherdomain(
286 unsigned long va
, unsigned long new_val
, unsigned long flags
,
289 return _hypercall4(int, update_va_mapping_otherdomain
, va
,
290 new_val
, flags
, domid
);
294 HYPERVISOR_vm_assist(
295 unsigned int cmd
, unsigned int type
)
297 return _hypercall2(int, vm_assist
, cmd
, type
);
302 int cmd
, int vcpuid
, void *extra_args
)
304 return _hypercall3(int, vcpu_op
, cmd
, vcpuid
, extra_args
);
308 HYPERVISOR_set_segment_base(
309 int reg
, unsigned long value
)
311 return _hypercall2(int, set_segment_base
, reg
, value
);
318 return _hypercall3(int, sched_op
, SCHEDOP_shutdown
,
319 SHUTDOWN_suspend
, srec
);
326 return _hypercall2(int, sched_op
, SCHEDOP_yield
, 0);
333 return _hypercall2(int, sched_op
, SCHEDOP_block
, 0);
340 return _hypercall2(int, sched_op
, SCHEDOP_shutdown
, SHUTDOWN_poweroff
);
347 return _hypercall2(int, sched_op
, SCHEDOP_shutdown
, SHUTDOWN_crash
);
354 return _hypercall2(int, sched_op
, SCHEDOP_shutdown
, SHUTDOWN_reboot
);
359 unsigned long op
, void *arg
)
361 return _hypercall2(int, nmi_op
, op
, arg
);
364 static inline unsigned long
368 return _hypercall2(unsigned long, hvm_op
, op
, arg
);
372 HYPERVISOR_callback_op(
375 return _hypercall2(int, callback_op
, cmd
, arg
);
379 HYPERVISOR_xenoprof_op(
382 return _hypercall2(int, xenoprof_op
, op
, arg
);
387 unsigned long op
, void *args
)
389 return _hypercall2(int, kexec_op
, op
, args
);
392 #if __XEN_INTERFACE_VERSION__ < 0x00030204
397 dom0_op
->interface_version
= DOM0_INTERFACE_VERSION
;
398 return _hypercall1(int, dom0_op
, dom0_op
);
400 #endif /* __XEN_INTERFACE_VERSION__ */
403 HYPERVISOR_machine_check(struct xen_mc
*mc
)
405 mc
->interface_version
= XEN_MCA_INTERFACE_VERSION
;
406 return _hypercall1(int, mca
, mc
);
409 #endif /* __HYPERCALL_H__ */